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 12345»»»

How to free table space Expand / Collapse
Author
Message
Posted Monday, September 27, 2010 12:00 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Thursday, April 18, 2013 12:29 PM
Points: 30, Visits: 48
Hi all,

Below is the result when we run the sp_spaceused for a table:

name rows reserved data index_size unused
---------- ----------- ------------------ ------------------ -------------
mytable 0 8441576 KB 8439672 KB 0 1864 KB

As you see a table has 0 rows and 0 index size, but the reserved/data size is huge. How to reduce this table size?

We tried to re-index the table, and used the DBCC cleantable to reduce the size, but the reserved size wasn’t changed. We cannot truncate the table because it is one of the replicated tables. Is there a way to reduce the reserved size (it’s really an empty table) without truncating it?
Post #993883
Posted Monday, September 27, 2010 12:14 PM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Tuesday, February 12, 2013 1:09 PM
Points: 335, Visits: 391
You could do a DBCC shrinkdb... but that would be a database-wide shrink which may not be desirable.

You could also drop/create table...
Post #993895
Posted Monday, September 27, 2010 12:46 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Thursday, April 18, 2013 12:29 PM
Points: 30, Visits: 48
Hmm.... very brutal solution. Anything else possible for SQL 2005?
Btw, Shrink Dtabase/File Task dialog in Mgmt Studio shows that the only 3GB could be freed but that table has 8GB free. Why? Could shrinking really do the trick?
Post #993917
Posted Monday, September 27, 2010 12:48 PM


Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: 2 days ago @ 1:04 PM
Points: 574, Visits: 684
Try a DBCC DBREINDEX(tablename)
Post #993918
Posted Monday, September 27, 2010 12:48 PM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Tuesday, February 19, 2013 8:30 PM
Points: 59, Visits: 406
If the table has 0 rows in it then why not just drop and recreate it to the size you want?
Post #993919
Posted Monday, September 27, 2010 12:50 PM


SSCoach

SSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoach

Group: General Forum Members
Last Login: 2 days ago @ 1:07 PM
Points: 18,733, Visits: 12,332
raistlinx (9/27/2010)
If the table has 0 rows in it then why not just drop and recreate it to the size you want?



Downstream effects can be brutal.




Jason AKA CirqueDeSQLeil
I have given a name to my pain...
MCM SQL Server 2008


SQL RNNR

Posting Performance Based Questions - Gail Shaw
Posting Data Etiquette - Jeff Moden
Hidden RBAR - Jeff Moden
VLFs and the Tran Log - Kimberly Tripp
Post #993922
Posted Monday, September 27, 2010 12:51 PM


SSCoach

SSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoach

Group: General Forum Members
Last Login: 2 days ago @ 1:07 PM
Points: 18,733, Visits: 12,332
Did you recently perform a delete operation on this table that removed all records? Or ever?


Try doing an index rebuild for the indexes on the table. Update statistics and DBCC updateusage.




Jason AKA CirqueDeSQLeil
I have given a name to my pain...
MCM SQL Server 2008


SQL RNNR

Posting Performance Based Questions - Gail Shaw
Posting Data Etiquette - Jeff Moden
Hidden RBAR - Jeff Moden
VLFs and the Tran Log - Kimberly Tripp
Post #993923
Posted Monday, September 27, 2010 1:13 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Thursday, April 18, 2013 12:29 PM
Points: 30, Visits: 48
CirquedeSQLeil (9/27/2010)
Did you recently perform a delete operation on this table that removed all records? Or ever?

Yes we did. Recently we kept data allocating ~1.5GB and now decided to delete all the records daily using DELETE.


Try doing an index rebuild for the indexes on the table. Update statistics and DBCC updateusage.

We rebuilt all the indexes and updating staistics daily as well as tried DBCC CLEANTABLE but nothing helped. We'll try DBCC updateusage, thanks for advice.
Post #993950
Posted Monday, September 27, 2010 1:24 PM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Tuesday, February 12, 2013 1:09 PM
Points: 335, Visits: 391
Yea, the drop/create table is brutal... however what about drop/creating all the indexes if they won't shrink? if the table has 0 rows that seems like a pretty safe option, no?
Post #993958
Posted Monday, September 27, 2010 1:33 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Thursday, April 18, 2013 12:29 PM
Points: 30, Visits: 48
CirquedeSQLeil (9/27/2010)
Update statistics and DBCC updateusage.

Well, it didn't help.
Post #993969
« Prev Topic | Next Topic »

Add to briefcase 12345»»»

Permissions Expand / Collapse