1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| select db_name(US.database_id)
, object_name(US.object_id)
, I.name as IndexName
, OS.leaf_allocation_count
, OS.nonleaf_allocation_count
, OS.leaf_page_merge_count
, OS.leaf_insert_count
, OS.leaf_delete_count
, OS.leaf_update_count
, *
from sys.dm_db_index_usage_stats US
join sys.indexes I
on I.object_id = US.object_id
and I.index_id = US.index_id
join sys.dm_db_index_operational_stats(db_id(), null, null, null) OS
on OS.object_id = I.object_id and OS.index_id = I.Index_id
where I.type <> 0 -- not heap
and object_name(US.object_id) not like 'sys%'
and i.type = 1 --pour n'avoir que les tables, pour avoir tous les index mettre cette ligne en commentaire
order by OS.leaf_allocation_count desc,
OS.nonleaf_allocation_count desc,
OS.leaf_page_merge_count desc,
US.User_updates desc,
US.User_Seeks desc,
US.User_Scans desc,
US.User_Lookups desc |
Partager