【sqlserver】 統計索引使用次數

renjixinchina發表於2012-08-31
declare @dbid int
select @dbid = db_id()
select bjectname=object_name(s.object_id), s.object_id, indexname=i.name, i.index_id
            , user_seeks, user_scans, user_lookups, user_updates
from sys.dm_db_index_usage_stats s,
            sys.indexes i
where database_id = @dbid and objectproperty(s.object_id,'IsUserTable') = 1
and i.object_id = s.object_id
and i.index_id = s.index_id
order by (user_seeks + user_scans + user_lookups + user_updates) asc

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/15747463/viewspace-742392/,如需轉載,請註明出處,否則將追究法律責任。

相關文章