Malcolm Daughtree (5/13/2009)
Please correct me if this is incorrect but, there are two types of index Maintenenace
1. rebuilding an Index and;
2. Re-organizing an Index
And the difference is signifigant. When you Re-organise an Index it only reorganises the index - within the existing index pages it will not change the Physical fragmentation of the Index. The index will still be scattered all over the data file - cause thats where it stores it, and you will probably not see any performance gains and the index will still be fragmented-physically, logically it will not be. Remember though that the slowest part of any RDBS is the swinging arm on the disk drive. This also is the reason you can re-organise an index 'On-line'. When you REBUILD an index, you physically remove the index from the data and rebuild the index within the Data File, usually this is contiguous. But here is the kicker if your Data file is heavily fragmented - Usually caused by the Autogrowth set to on - The index may still be and you will need to use other techniques to reduce fragmentation. The one I suggest is to do some Capacity planning on the Database and estimate the growth for a reasonable period- - say 9-12 Months and grow the Database in one go and turn Auto-growth off. I would rather automate the checking and alerting of database conditions than set and forget activities that will ultimately be forgotten and you come to work one day to a full disk drive, a suspect database and a boss none too pleased.
I think I got that right.
You are almost there.
Reorganising an index can indeed reduce fragmentation however only within the intermediate levels (index pages/rather than data pages in the case of a clustered index) of the index tree structure.
This is why the effectiveness is considered to be limited and why the recommended practice is to consider reorganisation of an index only when the fragmentation level is below a certain threshold.
Page splits etc. can still occur within the intermediate levels of an index and so there is the possibility to reduce/remove these through reorganisation of an index.
Take a look at the following MSDN reference for an explanation of the clustered index physical structure, there's a couple of nice pictures too ;-)http://msdn.microsoft.com/en-us/library/ms177443.aspx
Hope this helps.
John Sansom (@sqlBrit
) | www.johnsansom.com