Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Rebuilding indexes


Rebuilding indexes

Author
Message
Malcolm Daughtree
Malcolm Daughtree
SSC-Enthusiastic
SSC-Enthusiastic (189 reputation)SSC-Enthusiastic (189 reputation)SSC-Enthusiastic (189 reputation)SSC-Enthusiastic (189 reputation)SSC-Enthusiastic (189 reputation)SSC-Enthusiastic (189 reputation)SSC-Enthusiastic (189 reputation)SSC-Enthusiastic (189 reputation)

Group: General Forum Members
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
:-P
John.Sansom
John.Sansom
SSC-Addicted
SSC-Addicted (433 reputation)SSC-Addicted (433 reputation)SSC-Addicted (433 reputation)SSC-Addicted (433 reputation)SSC-Addicted (433 reputation)SSC-Addicted (433 reputation)SSC-Addicted (433 reputation)SSC-Addicted (433 reputation)

Group: General Forum Members
Points: 433 Visits: 1558
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
:-P




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
Malcolm Daughtree
Malcolm Daughtree
SSC-Enthusiastic
SSC-Enthusiastic (189 reputation)SSC-Enthusiastic (189 reputation)SSC-Enthusiastic (189 reputation)SSC-Enthusiastic (189 reputation)SSC-Enthusiastic (189 reputation)SSC-Enthusiastic (189 reputation)SSC-Enthusiastic (189 reputation)SSC-Enthusiastic (189 reputation)

Group: General Forum Members
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
:-P
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