sys.dm_db_index_usage_stats (Transact-SQL)


Updated: March 7, 2016

THIS TOPIC APPLIES TO: yesSQL Server (starting with 2008)yesAzure SQL DatabaseyesAzure SQL Data Warehouse yesParallel Data Warehouse

Returns counts of different types of index operations and the time each type of operation was last performed in SQL Server.

In Azure SQL Database, dynamic management views cannot expose information that would impact database containment or expose information about other databases the user has access to. To avoid exposing this information, every row that contains data that doesn’t belong to the connected tenant is filtered out.

System_CAPS_ICON_note.jpg Note

sys.dm_db_index_usage_stats does not return information about memory-optimized indexes. For information about memory-optimized index use, see sys.dm_db_xtp_index_stats (Transact-SQL).

System_CAPS_ICON_note.jpg Note

To call this from Azure SQL Data Warehouse or Parallel Data Warehouse, use the name sys.dm_pdw_nodes_db_index_usage_stats.

Column nameData typeDescription
database_idsmallintID of the database on which the table or view is defined.
object_idintID of the table or view on which the index is defined
index_idintID of the index.
user_seeksbigintNumber of seeks by user queries.
user_scansbigintNumber of scans by user queries. This represents scans that did not use 'seek' predicate.
user_lookupsbigintNumber of bookmark lookups by user queries.
user_updatesbigintNumber of updates by user queries. This includes Insert, Delete and Updates representing number of operations done not the actual rows affected. For example, if you delete 1000 rows in one statement, this count will increment by 1
last_user_seekdatetimeTime of last user seek
last_user_scandatetimeTime of last user scan.
last_user_lookupdatetimeTime of last user lookup.
last_user_updatedatetimeTime of last user update.
system_seeksbigintNumber of seeks by system queries.
system_scansbigintNumber of scans by system queries.
system_lookupsbigintNumber of lookups by system queries.
system_updatesbigintNumber of updates by system queries.
last_system_seekdatetimeTime of last system seek.
last_system_scandatetimeTime of last system scan.
last_system_lookupdatetimeTime of last system lookup.
last_system_updatedatetimeTime of last system update.
pdw_node_idintApplies to: Azure SQL Data Warehouse, Parallel Data Warehouse

The identifier for the node that this distribution is on.

Every individual seek, scan, lookup, or update on the specified index by one query execution is counted as a use of that index and increments the corresponding counter in this view. Information is reported both for operations caused by user-submitted queries, and for operations caused by internally generated queries, such as scans for gathering statistics.

The user_updates counter indicates the level of maintenance on the index caused by insert, update, or delete operations on the underlying table or view. You can use this view to determine which indexes are used only lightly by your applications. You can also use the view to determine which indexes are incurring maintenance overhead. You may want to consider dropping indexes that incur maintenance overhead, but are not used for queries, or are only infrequently used for queries.

The counters are initialized to empty whenever the SQL Server (MSSQLSERVER) service is started. In addition, whenever a database is detached or is shut down (for example, because AUTO_CLOSE is set to ON), all rows associated with the database are removed.

When an index is used, a row is added to sys.dm_db_index_usage_stats if a row does not already exist for the index. When the row is added, its counters are initially set to zero.

During upgrade to SQL Server 2008 R2, SQL Server 2012, or SQL Server 2014, entries in sys.dm_db_index_usage_stats are removed. Beginning with SQL Server 2016, entries are retained as they were prior to SQL Server 2008 R2.

Requires VIEW SERVER STATE permission. For more information, see Dynamic Management Views and Functions (Transact-SQL).

Dynamic Management Views and Functions (Transact-SQL)
Index Related Dynamic Management Views and Functions (Transact-SQL)
sys.dm_db_index_physical_stats (Transact-SQL)
sys.dm_db_index_operational_stats (Transact-SQL)
sys.indexes (Transact-SQL)
sys.objects (Transact-SQL)
Monitor and Tune for Performance

Community Additions