标签:
SELECT OBJECT_NAME(s.[object_id]) AS [Table Name] ,
i.name AS [Index Name] ,
i.index_id ,
user_updates AS [Total Writes] ,
user_seeks + user_scans + user_lookups AS [Total Reads] ,
user_updates - ( user_seeks + user_scans + user_lookups )
AS [Difference]
FROM sys.dm_db_index_usage_stats AS s WITH ( NOLOCK )
INNER JOIN sys.indexes AS i WITH ( NOLOCK )
ON s.[object_id] = i.[object_id]
AND i.index_id = s.index_id
WHERE OBJECTPROPERTY(s.[object_id], ‘IsUserTable‘) = 1
AND s.database_id = DB_ID()
AND user_updates > ( user_seeks + user_scans + user_lookups )
AND i.index_id > 1 --and OBJECT_NAME(s.[object_id])=‘Lot‘
ORDER BY [Difference] DESC ,
[Total Writes] DESC ,
[Total Reads] ASC ;
--执行结果
--结果描述,只介绍倒数2,3列, Total Write 与 Total Reads
如果 Total Reads 等于 0,说明索引没起作用,建议删除当前索引
标签:
原文地址:http://www.cnblogs.com/dong-1984dd/p/4895400.html