SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Sum of data and index space used not equal to fileproperty() spaceused


Sum of data and index space used not equal to fileproperty() spaceused

Author
Message
Ivan R.
Ivan R.
SSC Rookie
SSC Rookie (45 reputation)SSC Rookie (45 reputation)SSC Rookie (45 reputation)SSC Rookie (45 reputation)SSC Rookie (45 reputation)SSC Rookie (45 reputation)SSC Rookie (45 reputation)SSC Rookie (45 reputation)

Group: General Forum Members
Points: 45 Visits: 279
Hi -- I'm doing a SSMA migration from Sybase to SQL and i'm midway to finishing. I'm just curious why the sum data and index space used has a huge discrepancy with what is reported in sys.database_files using fileproperty() SpaceUsed function?

The sum in Object Explorer details is just 370 GB which is very close to the 500 GB size from Sybase. The file however is reported as 1.7 TB + already.

I'm aware of DBCC UPDATEUSAGE and i'll run this after it completes, but i'm really curious why this is the case Smile


select name
, size/128 as 'size_mb'
,FILEPROPERTY(name, 'SpaceUsed')/128 as'spaceused'
from sys.database_files

name size_mb spaceused
international 576512 575779
international_log 512 75
international2 576512 575883
international3 576512 575932
Alexander Zhang
Alexander Zhang
SSC Rookie
SSC Rookie (48 reputation)SSC Rookie (48 reputation)SSC Rookie (48 reputation)SSC Rookie (48 reputation)SSC Rookie (48 reputation)SSC Rookie (48 reputation)SSC Rookie (48 reputation)SSC Rookie (48 reputation)

Group: General Forum Members
Points: 48 Visits: 64
It's a surprise to me if fragmentation caused this. Is data compressed in Sybase, but not in SQL Server?

GASQL.com - Focus on Database and Cloud
Ivan R.
Ivan R.
SSC Rookie
SSC Rookie (45 reputation)SSC Rookie (45 reputation)SSC Rookie (45 reputation)SSC Rookie (45 reputation)SSC Rookie (45 reputation)SSC Rookie (45 reputation)SSC Rookie (45 reputation)SSC Rookie (45 reputation)

Group: General Forum Members
Points: 45 Visits: 279
Thanks mate. I was surprised too that it turns out to be fragmentation. A quick alter table rebuild cleared the excess reserved sp_spaceused. It's still the same number of rows.

I used a batch size of 500 rows as anything higher seems to cause an issue with the older version of SSMA i'm stuck with.

Before



After


Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum








































































































































































SQLServerCentral


Search