Table size does not add up

  • Hi,

    I've recently run into a very strange problem with one of our CRM databases.

    In particular one of our tables has grown to 60Gb (data size), as can be confirmed by the file size, and results of sp_spaceused.

    However there are only 515,000 rows in the table, with only 3 large columns (text, nvarchar(max)).

    Doing a select sum(datalength(col_name)) from bigtable on all columns only adds up to 12Gb!

    By duplicating the table, migrating the data across, then dropping the original, the space then adds up. But this is a major inconvenience.

    Does anyone have any ideas where all this space has gone?!

    Thanks

  • Reserved Space is part of the table allocation. This is unused space cause by fragmentation (i.e page splits) and extra growth allocation.

    The probability of survival is inversely proportional to the angle of arrival.

  • Thanks for the reply, how can this space be recovered?

  • By doing what you did, basically.

    The probability of survival is inversely proportional to the angle of arrival.

  • You periodically do maintenance to clean up the fragmentation and pack things together (remember your fillfactor here). It's just the way things are that a heavily used table might store extra space in there.

  • By maintenance do you mean drop and recreate the table as we did?

    Or is there another way?

  • Rebuilding the clustered index will do this as well. Not sure if it's quicker than making a copy of the table and renaming, but you essentially need to move all rows around.

Viewing 7 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply