|
There is a table with a Clustered Index and a Non- Clustered Index. Now I want to rebuild the Index's. Which Index has to be rebuilt 1st and Why ?
(comments are locked)
|
|
Sorry to say that but it is not true that non clustered indexes are rebuild when you're rebuilding the clustered index. Take a look here (Myth 3) and here You will affect all non clustered indexes if you DROP and RECREATE your clustered index or if you change the definition of the CI. But to answer the question itself: there's no special order when defragmenting/rebuilding an index. Just make sure that you do not affect any running workload, e.g. shift your maintenance to off-hours. Regards Dirk You are correct, for some reason I read the question as creating a clustered index when non-clustered indexes are present, which will rebuild the non-clustered indexes. Need more coffee...
Sep 29 '12 at 01:05 PM
Scot Hauder
No problem :)
Sep 29 '12 at 01:10 PM
DirkHondong
(comments are locked)
|
|
Neither has to be rebuilt first. If you rebuild the non-clustered first and then the clustered you are wasting time since rebuilding the clustered index will rebuild all non-clustered indexes. So the answer is, if you have to rebuild the clustered index, then only rebuild it.
(comments are locked)
|
|
In my opinion there is a certain order that fragmentation should be dealt with - leaving the clustered/non-clustered details to one side and considering that all indexes are equal, then;
If it is a large index (this may well coincide with it being on a big/busy table in your system). Defragmenting this may take a long time and, depending on your SQL Server edition, may cause a performance hit while the table is locked. If the index is highly fragmented and has recently been defragmented then this may point to the index being inappropriately configured in some (things like fill factor, clustering column etc), if it has built up over a long time then a simply defrag may well fix things for a long time to come. Hope this helps
(comments are locked)
|

