Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
Log in  ::  Register  ::  Not logged in
Home       Members    Calendar    Who's On

Add to briefcase

sp_spaceused returns same even after deleteing 3.5 lac records. Expand / Collapse
Posted Thursday, May 28, 2009 7:21 AM


Group: General Forum Members
Last Login: Monday, August 18, 2014 8:25 AM
Points: 1,519, Visits: 2,550
Dear All,
In one of my table there are only 2 fields.
1 autoincrement column
2 varchar column.
previously there were only 3 records.

I executed 'sp_spaceused 'tablename'' and I got the following values
Reserved - 16kb
Data - 8kb

Then I INSERTED 3.5 lac records and I got.
Reserved - 10568 KB
Data - 10528 KB

After that I DELETED all the records except the first 3. But still am getting the space used details as follows.
Reserved - 10568 KB
Data - 10528 KB

Why so.? Won't it decrease if we DELETE records..?

Post #725027
Posted Thursday, May 28, 2009 9:52 AM

Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Tuesday, August 19, 2014 2:27 PM
Points: 3,309, Visits: 6,702
Does this table have a clustered index? If not, you might see this behavior. I am not 100% sure but I have seen this happen in SQL 2000 but I have never come across this situation in SQL 2005 DB.

Post #725193
Posted Thursday, May 28, 2009 9:55 AM


Group: General Forum Members
Last Login: Monday, October 21, 2013 12:32 AM
Points: 2,556, Visits: 2,593
Taken straight from Books Online:

When updateusage is specified, the SQL Server 2005 Database Engine scans the data pages in the database and makes any required corrections to the sys.allocation_units and sys.partitions catalog views regarding the storage space used by each table. There are some situations, for example, after an index is dropped, when the space information for the table may not be current. updateusage can take some time to run on large tables or databases. Use updateusage only when you suspect incorrect values are being returned and when the process will not have an adverse effect on other users or processes in the database. If preferred, DBCC UPDATEUSAGE can be run separately.

When you drop or rebuild large indexes, or drop or truncate large tables, the Database Engine defers the actual page deallocations, and their associated locks, until after the transaction commits. Deferred drop operations do not release allocated space immediately. Therefore, the values returned by sp_spaceused immediately after dropping or truncating a large object may not reflect the actual disk space available. For more information about deferred allocations, see Dropping and Rebuilding Large Objects


Post #725201
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse