Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
SQL Server 2005
»
Administering
»
How to free table space
66 posts, Page 1 of 7
1
2
3
4
5
»
»»
How to free table space
Rate Topic
Display Mode
Topic Options
Author
Message
miksh
miksh
Posted Monday, September 27, 2010 12:00 PM
SSC 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
getoffmyfoot
getoffmyfoot
Posted Monday, September 27, 2010 12:14 PM
Old 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
miksh
miksh
Posted Monday, September 27, 2010 12:46 PM
SSC 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
Derrick Smith
Derrick Smith
Posted Monday, September 27, 2010 12:48 PM
Mr 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
raistlinx
raistlinx
Posted Monday, September 27, 2010 12:48 PM
Valued 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
SQLRNNR
SQLRNNR
Posted Monday, September 27, 2010 12:50 PM
SSCoach
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
SQLRNNR
SQLRNNR
Posted Monday, September 27, 2010 12:51 PM
SSCoach
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
miksh
miksh
Posted Monday, September 27, 2010 1:13 PM
SSC 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
getoffmyfoot
getoffmyfoot
Posted Monday, September 27, 2010 1:24 PM
Old 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
miksh
miksh
Posted Monday, September 27, 2010 1:33 PM
SSC 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 »
66 posts, Page 1 of 7
1
2
3
4
5
»
»»
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.