Thursday, 26 September 2013

Index Rebuild versus Reorganize: What’s the difference?


In a nutshell, you should rebuild when an index is over 30% fragmented and reorganize when an index is between 10% and 30% fragmented. If fragmentation is below 10%, you can probably just leave that index alone. Rebuilding takes more server resources (and uses locks unless you use the ONLINE option available in 2005 Enterprise and Development editions), so reorg when possible. Syntax below to rebuild or reorg all 
indexes on a table named tTable follows…

REBUILD
ALTER INDEX ALL ON dbo.tTable REBUILD
GO

REORGANIZE
ALTER INDEX ALL ON dbo.tTable REORGANIZE
GO


No comments: