查找索引碎片和重建索引

来源:互联网 发布:linux运维要学什么 编辑:程序博客网 时间:2024/06/07 00:31
SELECT a.index_id,name,avg_fragmentation_in_percent
FROM sys.dm_db_index_physical_stats (DB_ID(N'iWOMTrackData'), OBJECT_ID(N'HumanResources.Employee'), NULL, NULL, NULL) AS a
    JOIN sys.indexes AS b ON a.object_id = b.object_id AND a.index_id = b.index_id order by avg_fragmentation_in_percent desc; 
GO
ALTER INDEX IX_Item_Title_BID_State_Item_ID ON SEC_Item REBUILD;
go
原创粉丝点击