NemoMaximus
Programmer
I'm running SQL Server 2005 and one of my databases is eating up space and I have no idea why... My calculations of the required space is just not saying the same thing as the SQL Server reports. Have a look at this:
EXEC sp_spaceused MyTableName
Returns
-------
Name = MyTableName
Rows = 14674175
Reserved = 22898464 KB
Data = 18169480 KB
Index_size = 4669704 KB
Unused = 59280 KB
Now, have a look at the table structure:
field_01 Type=uniqueidentifier Length=16
field_02 Type=uniqueidentifier Length=16
field_03 Type=uniqueidentifier Length=16
field_04 Type=datetime Length=8
field_05 Type=datetime Length=8
field_06 Type=numeric Length=13
field_07 Type=char Length=1
field_08 Type=char Length=1
field_09 Type=char Length=3
field_10 Type=char Length=1
field_11 Type=char Length=1
field_12 Type=numeric Length=5
field_13 Type=numeric Length=13
field_14 Type=char Length=1
field_15 Type=bit Length=1
field_16 Type=timestamp Length=8
field_17 Type=_deduction numeric Length=13
field_18 Type=_deducted char Length=1
field_19 Type=char Length=3
field_20 Type=numeric Length=5
field_21 Type=numeric Length=13
field_22 Type=numeric Length=13
field_23 Type=numeric Length=13
field_24 Type=int Length=4
field_25 Type=numeric Length=5
field_26 Type=numeric Length=13
Total length = 195 bytes
So according to my calculations the space used for the table should be:
14674175 x 195 = 2,861,464,125 bytes or 2,861,464 KB
But sp_spaceused is reporting the the space used is 18,169,480 KB, more than 6 times what it should be according to my calculations. How is this possible?
One thought that I have... I'm deleting about 700000 of these records every day and recalculates them. Could it be that the deleted records are still there taking up space? And if so, how do I get rid of them?
Please help
EXEC sp_spaceused MyTableName
Returns
-------
Name = MyTableName
Rows = 14674175
Reserved = 22898464 KB
Data = 18169480 KB
Index_size = 4669704 KB
Unused = 59280 KB
Now, have a look at the table structure:
field_01 Type=uniqueidentifier Length=16
field_02 Type=uniqueidentifier Length=16
field_03 Type=uniqueidentifier Length=16
field_04 Type=datetime Length=8
field_05 Type=datetime Length=8
field_06 Type=numeric Length=13
field_07 Type=char Length=1
field_08 Type=char Length=1
field_09 Type=char Length=3
field_10 Type=char Length=1
field_11 Type=char Length=1
field_12 Type=numeric Length=5
field_13 Type=numeric Length=13
field_14 Type=char Length=1
field_15 Type=bit Length=1
field_16 Type=timestamp Length=8
field_17 Type=_deduction numeric Length=13
field_18 Type=_deducted char Length=1
field_19 Type=char Length=3
field_20 Type=numeric Length=5
field_21 Type=numeric Length=13
field_22 Type=numeric Length=13
field_23 Type=numeric Length=13
field_24 Type=int Length=4
field_25 Type=numeric Length=5
field_26 Type=numeric Length=13
Total length = 195 bytes
So according to my calculations the space used for the table should be:
14674175 x 195 = 2,861,464,125 bytes or 2,861,464 KB
But sp_spaceused is reporting the the space used is 18,169,480 KB, more than 6 times what it should be according to my calculations. How is this possible?
One thought that I have... I'm deleting about 700000 of these records every day and recalculates them. Could it be that the deleted records are still there taking up space? And if so, how do I get rid of them?
Please help