SQL Server - 确定缺失的索引 - DMV

时间:2010-07-23 11:38:45

标签: sql-server tsql

我使用以下查询来确定缺少的索引:

select 
    db_name(d.database_id) as DatabaseName, 
    object_name(d.object_id) TableName, 
    d.index_handle as IndexHandle,
    d.equality_columns as EqualityColumns, 
    d.inequality_columns as InequalityColumns, 
    d.included_columns as IncludedColumns, 
    d.statement as Object, 
    gs.user_seeks as PossibleUserSeeks,
    gs.user_scans as PossibleUserScans,
    gs.last_user_seek as LastPossibleUserSeek,
    gs.last_user_scan as LastPossibleUserScan,
    gs.system_seeks as PossibleSystemSeeks,
    gs.system_scans as PossibleSystemScans
from  
    sys.dm_db_missing_index_groups g
    join sys.dm_db_missing_index_group_stats gs on gs.group_handle = g.index_group_handle
    join sys.dm_db_missing_index_details d on g.index_handle = d.index_handle
where  
    d.database_id =  d.database_id and 
    d.object_id =  d.object_id And
    DB_NAME(d.database_id) = 'MESProduction'

我的问题是'd.index_handle'。 MSDN将此列描述如下:Identifies a particular missing index. The identifier is unique across the server. index_handle is the key of this table.如果缺少索引,如何识别它?当它说“这是这张桌子的关键”时它意味着什么?

非常感谢。

0 个答案:

没有答案