SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Best Index Rebuild/Reorganize and Update Statistics Strategy


Best Index Rebuild/Reorganize and Update Statistics Strategy

Author
Message
GilaMonster
GilaMonster
SSC Guru
SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)

Group: General Forum Members
Points: 91905 Visits: 45285
SQL_Surfer (7/21/2013)
Any idea why DB grows to 10GB more after index maintenance?


Because SQL had to rebuild the indexes somewhere, if there wasn't space for the new indexes, the file would have grown to make space.

Should I opt for shrinkfile?


If you want to completely undo everything that the index rebuild did, leave your indexes more fragmented than before you started, sure.

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


SQL_Surfer
SQL_Surfer
Say Hey Kid
Say Hey Kid (685 reputation)Say Hey Kid (685 reputation)Say Hey Kid (685 reputation)Say Hey Kid (685 reputation)Say Hey Kid (685 reputation)Say Hey Kid (685 reputation)Say Hey Kid (685 reputation)Say Hey Kid (685 reputation)

Group: General Forum Members
Points: 685 Visits: 1086
Thanks Gail. Should I expect 10GB growth everytime I rebuild the index? This happened on only one DB that had snapshot. But I dropped snapshot before rebuilding index.
GilaMonster
GilaMonster
SSC Guru
SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)

Group: General Forum Members
Points: 91905 Visits: 45285
SQL_Surfer (7/21/2013)
Thanks Gail. Should I expect 10GB growth everytime I rebuild the index?


No, you should expect the file to grow if there's not enough free space for new indexes to be created. If there is enough free space, then there's enough free space and there's no need to grow the file.

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


Jeff Moden
Jeff Moden
SSC Guru
SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)

Group: General Forum Members
Points: 91064 Visits: 41151
Just to add to what has already been said...

You don't actually need to take a full backup to get thing back to a normal Point-In-time backup status after going to the Bulk Logged or even the SIMPLE recovery mode. You can simply change back to the FULL recovery mode if in Bulk Logged and you only need to do a DIFF backup if you were in the SIMPLE recovery mode. Of course, I do a FULL backup on my relatively small (only 200GB) databases every night anyway. Just remember that even in the Bulk Logged mode, a Point-In-Time restore can't be done for any log file where you were in the Bulk Logged mode. You can only use the whole logfile backup or not during those time frames.

You can save a whole lot of "growth" during index rebuilds if you partition (Table Partition or Partitioned View) the large tables and related indexes because they'll be treated as much smaller individual units. It takes a bit to set them up and a bit to setup the code for automatic maintenance on them but it's well worth it. If you do some "tricks" with using different file groups on the partitions, it can also allow for "Piecemeal Restores" where you can get the core of a database backup up and running very quickly (not initially loading large log/audit tables, for example) and then loading larger less important data over time after the initial restore.

Partitioning can also be a real time save for both index maintenance and backups. For example, if you have large audit tables, you don't have to rebuild the indexes on the temporally stagnant partitions (I divide them up by month) and you don't have to back them up but once or twice if they're in a separate file group for each partition.

--Jeff Moden

RBAR is pronounced ree-bar and is a Modenism for Row-By-Agonizing-Row.
First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column.
If you think its expensive to hire a professional to do the job, wait until you hire an amateur. -- Red Adair

Helpful Links:
How to post code problems
How to post performance problems
Forum FAQs
GilaMonster
GilaMonster
SSC Guru
SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)

Group: General Forum Members
Points: 91905 Visits: 45285
Jeff Moden (7/21/2013)
You can simply change back to the FULL recovery mode if in Bulk Logged ....


You can, but a log backup right before or after the switch is strongly recommended (doesn't really matter the order)
http://www.sqlservercentral.com/articles/Recovery+Model/89664/

Just remember that even in the Bulk Logged mode, a Point-In-Time restore can't be done for any log file where you were in the Bulk Logged mode. You can only use the whole logfile backup or not during those time frames.


A point in time restore can be done while in bulk-logged recovery, unless that log backup contains a minimally logged operation. Only log backups that contain minimally logged operations must be restored in full. If a log backup contains no minimally logged operations, then you can restore to any point within that, just as in full recovery.

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


Jeff Moden
Jeff Moden
SSC Guru
SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)

Group: General Forum Members
Points: 91064 Visits: 41151
GilaMonster (7/21/2013)
Jeff Moden (7/21/2013)
You can simply change back to the FULL recovery mode if in Bulk Logged ....


You can, but a log backup right before or after the switch is strongly recommended (doesn't really matter the order)
http://www.sqlservercentral.com/articles/Recovery+Model/89664/

Just remember that even in the Bulk Logged mode, a Point-In-Time restore can't be done for any log file where you were in the Bulk Logged mode. You can only use the whole logfile backup or not during those time frames.


A point in time restore can be done while in bulk-logged recovery, unless that log backup contains a minimally logged operation. Only log backups that contain minimally logged operations must be restored in full. If a log backup contains no minimally logged operations, then you can restore to any point within that, just as in full recovery.


Apologies for the late response. Thanks for the clarification on the ability to do PIT restores while in the bulk-logged mode if there are no minimally logged operations.

--Jeff Moden

RBAR is pronounced ree-bar and is a Modenism for Row-By-Agonizing-Row.
First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column.
If you think its expensive to hire a professional to do the job, wait until you hire an amateur. -- Red Adair

Helpful Links:
How to post code problems
How to post performance problems
Forum FAQs
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