INDEX REORGANIZE vs REBUILD
INDEX REORGANIZE vs REBUILD is a SQL statement in the Indexes category. REORGANIZE defragments index pages (online operation, minimal locking). REBUILD recreates the index completely. The syntax is ALTER INDEX ... REORGANIZE (low frag) vs REBUILD (high frag). It returns index maintenance decision. A typical example: -- Reorganize: light defragmentation ALTER INDEX idx_name ON employees REORGANIZE; -- Online operation: table remains accessible -- Best for fragmentation 5-30% -- Rebuild: full recreation ALTER INDEX idx_name ON employees REBUILD; -- Offline by default (table locked) -- WITH (ONLINE = ON) for minimal locking (Enterprise) -- Best for fragmentation >30% -- Rebuild ALL indexes: ALTER INDEX ALL ON employees REBUILD; -- Rebuild with FILLFACTOR: ALTER INDEX ALL ON employees… A close relative is CREATE INDEX, which creates an index on one or more columns to speed up query performance. A close relative is DROP INDEX, which removes an existing index from a table.