Using DMVs to find out the index usage history- SQL Server Index Usage
Posted by Karthick P.K on July 6, 2010
SQL Server 2005 ships with a set of DMVs that can help you identify the missing indexes for your workload, Analyze the effectiveness of the existing ones and help find out index fragmentation.
Using DMVs to find out the index usage history
Over a period of time, you could create a lot of indexes on your tables and modify existing ones. However, in SQL 2000, you couldn’t estimate how effective were each of these indexes. Poorly design indexes could lead to performance overhead instead of enhancing performance.
In SQL 2005, you can query the sys.dm_db_index_usage_stats DMV to find out the indexes that have NEVER been used since the last start of SQL Server. You can use the following query to find that out:
In the output, you will ALL the indexes that have never been used by any sort of workload on your server, since the last start of SQL Server.
For indexes that have NEVER been used (either for a SELECT or a DML statement), all columns will be NULL
For indexes that have NEVER been used (for a SELECT), but had to be updated due to a DML statement, the user_updates column will be >0, while other columns will be 0. It is these indexes that could cause severe performance overhead for your DML statements and might be worth dropping.
Give ample time for SQL Server to get exposed to all the workload after a restart, before running this query.
Using DMVs to find out missing indexes
When the query optimizer generates a query plan, it analyzes what are the best indexes for a particular filter condition. If the best indexes do not exist, the query optimizer generates a suboptimal query plan, but still stores information about these indexes. The missing indexes feature enables you to access information about these indexes so you can decide whether they should be implemented.
For more information on how to use this feature, please visit the following link
Using DMVs to find out index fragmentation
The sys.dm_db_index_physical_stats dynamic management function replaces the DBCC SHOWCONTIG statement.
You can learn more about using this DMV to identify fragmentation, correcting it and possibly automating this activity for your server by visiting the following link: