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;
--Execution results
--Result description, only 2, 3 columns, total Write and total Reads
If total Reads equals 0, indicating that the index does not work, it is recommended to delete the current index
SQL Server Query Index usage