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
Author
Message
Posted Thursday, May 28, 2009 7:21 AM
SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Yesterday @ 11:41 PM
Points: 1,563, Visits: 2,615
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..?


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


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Thursday, October 16, 2014 7:31 AM
Points: 2,361, Visits: 6,749
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.


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

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Thursday, October 16, 2014 5:52 AM
Points: 2,551, Visits: 2,594
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.

Note:
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



--Ramesh

Post #725201
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse