Introduction to the Maintenance Plan Wizard – Part 2

Woo, 2 in a row! Today I’ll be doing the second part of walking through the Maintenance Plan Wizard, Re-Organizing and Re-Building indexes.

Reorganize Index


Again, does what it says on the tin. This task kicks off an “Alter index REORGANIZE” for all the indexes in your database. It moves around the data in your index to try to put them back in the correct order. It does this by defragmenting the data at a Leaf (Smallest) level. The benefits of defragmenting in this way are that you can keep the index online so your database/index is still accessible while you are cleaning up. Still, try to schedule it for quiet times as much as possible, or more ideally, run it manually whenever you identify fragmented indexes. The general Guideline is to use Reorganize over Rebuild if your fragmentation level is < 30%. How do you find out how fragmented your indexes are? Well, this leads me off on a slight tangent.

Finding out if you have index fragmentation


This method isn’t the most optimal way to do it, but it is probably the simplest, and most legible, if you don’t want to get into using DMV’s and other low level functions. There are built in reports in SQL Management Studio which are very handy, the one you’re looking in this instance is in the screenshot below Index Physical Statistics :

Open that up and take a look, in the “Operation Recommended” column, you’ll either see a “-“, which is “I’m fine”, “Reorganize” or “Rebuild”. Very useful report if you want to get an idea of what shape your database is in. Now, back on track!
Rebuild Index

Again, very aptly named. This one however doesn’t defragment the index, it just blows it away and creates it again. This ensures you get a contiguously stored, and 100% in the correct order, index. However the overhead on this one is significantly higher, and unless you’re running Enterprise edition, the index will have to be taken offline to be rebuilt, degrading the performance of your database while the index is unavailable. This is definitely one to run in off peak times, and a little less frequently than the Reorganize job.
If you want to take a look at these in a little more depth, have a read of this Technet article. It goes into a lower level of detail as to how the operations run, and give a few guidelines too.
As always, any questions, please feel free to ask. I hope to have part 3 out tomorrow, so until then, happy reading!
Stephen

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.