March 19, 2015 at 3:35 pm
hi ,
Is it possible to reclaim space after rebuilding indexes(shrinking is not an option).
Thank you advance
March 19, 2015 at 4:28 pm
May I know why shrinking is not an option here? Is it because db in simple recovery mode
March 19, 2015 at 4:32 pm
Shrinking will fragment indexes
March 19, 2015 at 9:51 pm
Barcelona10 (3/19/2015)
hi ,Is it possible to reclaim space after rebuilding indexes(shrinking is not an option).
Thank you advance
No. Not directly. And the indirect method is a huge PITA.
Are you trying to do this on file groups other than the PRIMARY filegroup, a partitioned table with multiple file groups, or just the PRIMARY filegroup?
You could try a shrink with truncate only (which will not re-frag your indexes) but you have to get pretty lucky there.
--Jeff Moden
Change is inevitable... Change for the better is not.
March 20, 2015 at 9:58 am
Shrink does not always fragment indexes; it certainly does not always fragment every index. You can shrink as much as you really need and then rebuild/reorg any index that needs it.
SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".
March 20, 2015 at 10:00 am
Barcelona10 (3/19/2015)
Shrinking will fragment indexes
I'm not saying shrinking is a good idea, but if you rebuild your indexes after shrinking, they will not be fragmented.
For best practices on asking questions, please read the following article: Forum Etiquette: How to post data/code on a forum to get the best help[/url]
March 20, 2015 at 1:08 pm
After rebuilding indexes(PRIMARY file group) shrinking fragmenting my indexes(at least i checked 10-15 of them).
rebuild----defrag
shink------frag.
rebuild----defrag
shink------frag......
I have not tried partial shrinking then just do index reorganize(instead of rebuilding).
I'll try and i'll post the results.
thank you all
March 20, 2015 at 1:10 pm
rebuild----defrag(space issue)
shink------frag.
rebuild----defrag(space issue)
shink------frag.....
March 20, 2015 at 1:33 pm
Barcelona10 (3/20/2015)
rebuild----defrag(space issue)shink------frag.
rebuild----defrag(space issue)
shink------frag.....
DROP DATABASE ---- No issues!
March 21, 2015 at 12:42 pm
Alexander Suprun (3/20/2015)
Barcelona10 (3/20/2015)
rebuild----defrag(space issue)shink------frag.
rebuild----defrag(space issue)
shink------frag.....
DROP DATABASE ---- No issues!
Well that just made me LOL. 😎
March 21, 2015 at 2:46 pm
Barcelona10 (3/20/2015)
rebuild----defrag(space issue)shink------frag.
rebuild----defrag(space issue)
shink------frag.....
Just to be sure, if you shrink the database, do a REORGANIZE instead of a REBUILD (reorg is done in place rather than separately so causes nearly no growth), and the a shrink with "TRUNCATE ONLY", you should be good. Well, except maybe for the B-TREE of the indexes. You'd have to test to see if your queries require the B-TREE to be nicely defragged, as well. In many cases, the answer will be "it didn't matter".
Just remember that REORGANIZE is ALWAYS full logged. Unless you're in the SIMPLE recovery model, Reorging the whole database is like copying the whole database to the log file and more.
--Jeff Moden
Change is inevitable... Change for the better is not.
March 23, 2015 at 10:37 am
Thank you very much Jeff.
I'll test your suggestions as well.
Viewing 12 posts - 1 through 11 (of 11 total)
You must be logged in to reply to this topic. Login to reply