Sql-server – Index manteinance: does the order of processing make a difference

indexperformancesql server

I have an 800GB SQL Server Enterprise database with very bad performance. So, based on a few scripts I found online I'm creating a job on my SQL database to maintain our indexes. Most of my tables have a clustered index and 3 or 4 non-clustered.

  • Does it make any difference the order in which the indexes are being
    rebuild/reorganized?
  • Is it the same if I first reorganize the clustered index and then the
    nonclustered ones or if I do it the other way?

Best Answer

Does it make any difference the order in which the indexes are being rebuild/reorganized?

As commented by @Dan Guzman it does not matter. But if your rebuilding and free disk space is limited I suggest you start from small to bigger ones (among the one qualify based on whatever criteria you are using). Reason explained here:

Disk Space Requirements for Index DDL Operations.

Very good tips for other considerations.

Should You Rebuild or Reorganize Indexes on Large Tables? (Dear SQL DBA Episode 19) by Kendra Little.

Is it the same if I first reorganize the clustered index and then the nonclustered ones or if I do it the other way?

Yes it same because the clustered keys, which are the record locators in the NC indexes, aren’t changed because you rebuild the index.