[索引使用状况]
select DB_NAME(database_id) 'dbname',so.name 'objname',si.name 'indexname',
si.type_desc 'indextype',si.is_primary_key 'PK',
ius.user_seeks+ius.user_scans+ius.user_lookups '用户使用索引次数',
ius.system_seeks+ius.system_scans+ius.system_lookups '系统使用索引次数'
from sys.dm_db_index_usage_stats ius
inner join sys.objects so on ius.object_id=so.object_id
inner join sys.indexes si on ius.object_id=si.object_id
and ius.index_id=si.index_id
where so.is_ms_shipped=0
--and ius.user_seeks+ius.user_scans+ius.user_lookups+
--ius.system_seeks+ius.system_scans+ius.system_lookups=0
--and si.type<>1 and si.is_primary_key=0
select DB_NAME(database_id) 'dbname',so.name 'objname',si.name 'indexname',
si.type_desc 'indextype',si.is_primary_key 'PK',
ius.user_seeks+ius.user_scans+ius.user_lookups '用户使用索引次数',
ius.system_seeks+ius.system_scans+ius.system_lookups '系统使用索引次数'
from sys.dm_db_index_usage_stats ius
inner join sys.objects so on ius.object_id=so.object_id
inner join sys.indexes si on ius.object_id=si.object_id
and ius.index_id=si.index_id
where so.is_ms_shipped=0
--and ius.user_seeks+ius.user_scans+ius.user_lookups+
--ius.system_seeks+ius.system_scans+ius.system_lookups=0
--and si.type<>1 and si.is_primary_key=0
来源:https://www.cnblogs.com/duncannjm/archive/2012/08/16/2642611.html