SQL Index Usage

25 June,2007 by Jack Vamvas

Use this T-SQL Script to retrieve SQL  indexes that haven't been used. For a wider view on table and index usage read SQL Server – Find last time of update on a table

select object_name(object_id), index_id, user_seeks, user_scans, user_lookups 
from sys.dm_db_index_usage_stats 
order by object_id, index_id 

---All indexes which haven’t been used yet can be retrieved with the following statement: 

select object_name(object_id), i.name 
from sys.indexes i 
where  i.index_id NOT IN (select s.index_id 
                          from sys.dm_db_index_usage_stats s 
                          where s.object_id=i.object_id and 
                          i.index_id=s.index_id and 
                          database_id =  DB_id(db_name())) 
order by object_name(object_id) asc 

Read More on Index Management

Top 5 SQL Server DMV for Index Analysis

List all indexes of all tables


Author: Jack Vamvas (http://www.sqlserver-dba.com)


Share:

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment on SQL Index Usage


sqlserver-dba.com | SQL Server Performance Tuning | SQL Server DBA:Everything | FAQ | Contact|Copyright & Disclaimer