Difference between Index Rebuild Vs Index Reorganize with example T-SQL.
1. Index Rebuild drops the existing Index and Recreates the index from scratch.
2. Index Reorganize physically reorganizes the leaf nodes of the index.
3. Rebuild the Index when an index is over 30% fragmented.
4. Reorganize the Index when an index is between 10% and 30% fragmented.
5. If fragmentation is below 10%, no action required.
Rebuilding takes more server resources and uses locks unless you use the ONLINE option available in 2005 Enterprise and Development editions.
6. Always prefer to do Reorganize the Index.
2. Index Reorganize physically reorganizes the leaf nodes of the index.
3. Rebuild the Index when an index is over 30% fragmented.
4. Reorganize the Index when an index is between 10% and 30% fragmented.
5. If fragmentation is below 10%, no action required.
Rebuilding takes more server resources and uses locks unless you use the ONLINE option available in 2005 Enterprise and Development editions.
6. Always prefer to do Reorganize the Index.
T-SQL for Rebuilding all Indexes of a particular table.
USE AdventureWorks;
GO
ALTER INDEX ALL ON HumanResources.Employee REBUILD
GO
GO
ALTER INDEX ALL ON HumanResources.Employee REBUILD
GO
T-SQL for Reorganize all Indexes of a particular table.
USE AdventureWorks;
GO
ALTER INDEX ALL ON HumanResources.Employee REORGANIZE
GO
GO
ALTER INDEX ALL ON HumanResources.Employee REORGANIZE
GO
No comments:
Post a Comment