Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase ««12

Rebuilding indexes Expand / Collapse
Author
Message
Posted Wednesday, May 13, 2009 4:41 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Wednesday, November 2, 2011 9:50 PM
Points: 189, Visits: 335
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.

IMHO

I think I got that right.

CodeOn



Post #716554
Posted Thursday, May 14, 2009 1:44 AM


Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Saturday, August 23, 2014 6:03 AM
Points: 351, Visits: 1,556
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.

IMHO

I think I got that right.

CodeOn





Hi Malcolm,

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
Post #716690
Posted Thursday, May 14, 2009 6:06 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Wednesday, November 2, 2011 9:50 PM
Points: 189, Visits: 335
John,
Thanks for the info, yes that helped. It is a balancing act between Pages used, Physical fargmnetation of the Datafile, Pad Index / fill factors and the like. Ahhh ! but that why we are DBA's.

CodeOn
Post #717499
« Prev Topic | Next Topic »

Add to briefcase ««12

Permissions Expand / Collapse