Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reorganise index vs Rebuild Index in Sql Server Maintenance plan

In the SSW rules to better SQL Server Database there is an example of a full database maintenance plan: SSW. In the example they run both a Reorganize Index and then a Rebuild Index and then Update Statistics. Is there any point to this? I thought Reorganize Index was a fast but less effective version of Rebuild Index? and that an index rebuild would also update the statistics automatically (on the clustered index at least).

like image 705
BTB Avatar asked Aug 11 '08 07:08

BTB


People also ask

Should you rebuild or reorganize indexes?

If you have an index maintenance routine that always rebuilds and never considers reorganizing, you should reconsider. It's usually better to reorganize a lightly fragmented index and rebuild a more heavily fragmented index – to save time and resources.

What is the difference between index rebuild and index reorganize in SQL Server?

Index reorganization is a process where the SQL Server goes through the existing index and cleans it up. Index rebuild is a heavy-duty process where an index is deleted and then recreated from scratch with an entirely new structure, free from all piled up fragments and empty-space pages.

How do I rebuild an index maintenance plan in SQL Server?

The option is under the Management node of SQL Server management studio. Right-click on Maintenance Plans and select New Maintenance Plan… Provide the appropriate name of the maintenance plan. Drag and drop the index rebuild task from the maintenance plan toolbox.

Which index maintenance task discards the entire index and recreate?

An index rebuild simply drops and recreates the index which means that index rebuild will solve both the internal and external fragmentation.


1 Answers

The reorganize and rebuild are different things.

Reorganize: it's a defrag for indexes. Takes the existing index(es) and defragments the existing pages. However if the pages are not in a contiguous manner, they stays like before. Only the content of the pages are changing.

Rebuild: actually it drops the index and rebuilds it from scratch. It means that you will get a completely new index, with defragmented and contiguous pages.

Moreover with rebuild you can change partitioning or file groups, but with reorganize you can defrag not only the whole index, but also only one partition of the index.

The update statistics is automatic on clustered indexes, but not on the non-clustered ones.

like image 56
Biri Avatar answered Oct 05 '22 11:10

Biri