What is Index Maintenance and how do I do it? How frequently do I have to do it?
What are the benefits?
This is related to a transaction table which is subject to frequently modifications; all DML operations will be run on that table.
What is Index Maintenance and how do I do it? How frequently do I
Share
I second everything that Jonathan said – except for the frequency of index maintenance.
Well, if you happen to have a poorly designed index (such as a clustered index on a GUID key), you might actually need to do it at least every night – or even during the day, too.
As a general rule of thumb: if your index fragmentation is below 5%, all is fine. If you have fragmentation between 5% and approx. 30%, you should do an index reorganization:
If your index has index fragmentation of more than 30%, you need to rebuild it completely:
Rebuilding an index can be disruptive – try to do it at off-hours, e.g. during the night.
In order to determine index fragmentation, you can use this DMV query:
Michelle Ufford has a great automatic index defrag script – highly recommended! Or then you should look into setting up SQL Server maintenance plans which can run e.g. every night and clean up your indices.
Marc