Friday, February 19, 2010

Update Statistics Before or After an Index Rebuild

http://benchmarkitconsulting.com/colin-stasiuk/2009/02/11/update-statistics-before-or-after-an-index-rebuild/


http://blog.sqlauthority.com/2010/01/25/sql-server-find-statistics-update-date-update-statistics/


Show Statistics:

DBCC SHOW_STATISTICS ('Table_Name', Index_Name) WITH STAT_HEADER


Update Table Statistics:

Update Statistics dbo.aou_order with FULLSCAN


Rebuild Index offline:

Standard Edition only supports offline,
Enterprise Edition supports online and offline rebuild.

ALTER INDEX PK_aou_order ON dbo.aou_order REBUILD with (online=off)


SQL 2000 Rebuild Index method:

DBCC DBREINDEX ("aou_order", PK_aou_order);


Check Indexes fragmentation of Tables using DBCC :


DBCC SHOWCONTIG ('aou_order')

Check Indexes fragmentation of Tables using DMs:

USE uwscal
GO
SELECT object_id, index_id, avg_fragmentation_in_percent, page_count
FROM sys.dm_db_index_physical_stats(DB_ID('uwscal'), OBJECT_ID('aou_order'), NULL, NULL, NULL);


SELECT *
FROM sys.dm_db_index_physical_stats(DB_ID('uwscal'), NULL, NULL, NULL , NULL);

No comments:

Post a Comment