Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Shrink database after archiving


Shrink database after archiving

Author
Message
Sqlsavy
Sqlsavy
SSC Veteran
SSC Veteran (240 reputation)SSC Veteran (240 reputation)SSC Veteran (240 reputation)SSC Veteran (240 reputation)SSC Veteran (240 reputation)SSC Veteran (240 reputation)SSC Veteran (240 reputation)SSC Veteran (240 reputation)

Group: General Forum Members
Points: 240 Visits: 858
We've archived massive chunk of data from two databases on a SQL instanace. Now want to shrink the database to free up disk space.

If I run DBCC SHRINKDATABASE command for both databases simultaneously would that work? or will block each othere?
GilaMonster
GilaMonster
SSC-Forever
SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)

Group: General Forum Members
Points: 47297 Visits: 44392
It'll work.

Use ShrinkFile, not ShrinkDB and just shrink the files that have lots of free space in them. Don't shrink as small as possible, leave some free space in the DB. Rebuild your indexes afterwards


Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass


ScottPletcher
ScottPletcher
Hall of Fame
Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)

Group: General Forum Members
Points: 3946 Visits: 6686
Of course don't rebuild needlessly; check the stats and only rebuild those indexes that require it.

Also, with a reasonably well-tuned tempdb, you should strongly consider using the:
SORT_IN_TEMPDB = ON
option. This can help reduce fragmentation of the data file as well.

Even then, you may get a nasty suprise -- after you rebuild the indexes, the db file might be close to the same size it was originally! So be sure to check after rebuilding.

SQL DBA,SQL Server MVP('07, '08, '09)

Prosecutor James Blackburn, in closing argument in the "Fatal Vision" murders trial: "If in the future, you should cry a tear, cry one for them [the murder victims]. If in the future, you should say a prayer, say one for them. And if in the future, you should light a candle, light one for them."
CapnHector
CapnHector
SSC Eights!
SSC Eights! (917 reputation)SSC Eights! (917 reputation)SSC Eights! (917 reputation)SSC Eights! (917 reputation)SSC Eights! (917 reputation)SSC Eights! (917 reputation)SSC Eights! (917 reputation)SSC Eights! (917 reputation)

Group: General Forum Members
Points: 917 Visits: 1789
ScottPletcher (11/26/2012)
Of course don't rebuild needlessly; check the stats and only rebuild those indexes that require it.

Also, with a reasonably well-tuned tempdb, you should strongly consider using the:
SORT_IN_TEMPDB = ON
option. This can help reduce fragmentation of the data file as well.

Even then, you may get a nasty suprise -- after you rebuild the indexes, the db file might be close to the same size it was originally! So be sure to check after rebuilding.


i think "SORT_IN_TEMPDB = ON" is enterprise only (although i may be completely wrong and only an online rebuild is enterprise only) also i would go ahead and rebuild all the indexes after you shrink the DB file as shrinking the DB file may mess with every index in the DB. just make the rebuild time part of the maintenance down time if you can afford it.


For faster help in answering any problems Please read How to post data/code on a forum to get the best help - Jeff Moden for the best way to ask your question.

For performance Issues see how we like them posted here: How to Post Performance Problems - Gail Shaw

Need to Split some strings? Jeff Moden's DelimitedSplit8K
Jeff Moden's Cross tab and Pivots Part 1
Jeff Moden's Cross tab and Pivots Part 2
Sqlsavy
Sqlsavy
SSC Veteran
SSC Veteran (240 reputation)SSC Veteran (240 reputation)SSC Veteran (240 reputation)SSC Veteran (240 reputation)SSC Veteran (240 reputation)SSC Veteran (240 reputation)SSC Veteran (240 reputation)SSC Veteran (240 reputation)

Group: General Forum Members
Points: 240 Visits: 858
Thank you all for the helpul/quick inputsSmile much appreciated!
ScottPletcher
ScottPletcher
Hall of Fame
Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)

Group: General Forum Members
Points: 3946 Visits: 6686
capnhector (11/26/2012)
ScottPletcher (11/26/2012)
Of course don't rebuild needlessly; check the stats and only rebuild those indexes that require it.

Also, with a reasonably well-tuned tempdb, you should strongly consider using the:
SORT_IN_TEMPDB = ON
option. This can help reduce fragmentation of the data file as well.

Even then, you may get a nasty suprise -- after you rebuild the indexes, the db file might be close to the same size it was originally! So be sure to check after rebuilding.


i think "SORT_IN_TEMPDB = ON" is enterprise only (although i may be completely wrong and only an online rebuild is enterprise only) also i would go ahead and rebuild all the indexes after you shrink the DB file as shrinking the DB file may mess with every index in the DB. just make the rebuild time part of the maintenance down time if you can afford it.



SORT_IN_TEMPDB = ON does not require Enterprise Edition.

Yes, the shrink may/might have affected all indexes -- or it may/might have affected none, or only a single, small index. Rebuilding a large index that didn't require it is not only a large waste of resources, but it would also increase data space used, reducing the gains from the shrink, which was the whole point to begin with.

SQL DBA,SQL Server MVP('07, '08, '09)

Prosecutor James Blackburn, in closing argument in the "Fatal Vision" murders trial: "If in the future, you should cry a tear, cry one for them [the murder victims]. If in the future, you should say a prayer, say one for them. And if in the future, you should light a candle, light one for them."
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search