Aug 8, 2012

Index Rebuild and Index Reorganize

Index Rebuild
This process drops the existing Index and Recreates the index

Rebuild all indexes for the respective table
ALTER INDEX ALL ON < table name > REBUILD;

Rebuild specific indexes for the specific table
ALTER INDEX < Index Name > ON < Table Name > REBUILD;

Index Reorganize
This process physically reorganizes the leaf nodes of the index.

Reorganize all indexes for the specified table
ALTER INDEX ALL ON < table name > REORGANIZE;

Reorganize a specific index
ALTER INDEX < Index Name > ON < Table Name > REORGANIZE;

Recommendation: Index should be rebuild when index fragmentation is great than 40%. Index should be reorganized when index fragmentation is between 10% to 40%. Index rebuilding process uses more CPU and it locks the database resources. SQL Server development version and Enterprise version has option ONLINE, which can be turned on when Index is rebuilt. ONLINE option will keep index available during the rebuilding.

No comments:

Post a Comment