SQL Server Query Index usage

Source: Internet
Author: User
Tags sql server query

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.