sys.dm_db_missing_index_details - Returns indexes the optimizer considers are missing.
sys.dm_db_missing_index_columns - Returns the columns for a missing index.
sys.dm_db_missing_index_group_stats - Returns usage and access details for the missing indexes similar to sys.dm_db_index_usage_stats
The following query returns a prioritized list of the missing indexes in the current database:
SELECT so.name
, (avg_total_user_cost * avg_user_impact) * (user_seeks + user_scans) as Impact
, mid.equality_columns
, mid.inequality_columns
, mid.included_columns
FROM sys.dm_db_missing_index_group_stats AS migs
INNER JOIN sys.dm_db_missing_index_groups AS mig ON migs.group_handle = mig.index_group_handle
INNER JOIN sys.dm_db_missing_index_details AS mid ON mig.index_handle = mid.index_handle
INNER JOIN sys.objects so WITH (nolock) ON mid.object_id = so.object_id
WHERE migs.group_handle IN (
SELECT TOP (5000) group_handle
FROM sys.dm_db_missing_index_group_stats WITH (nolock)
ORDER BY (avg_total_user_cost * avg_user_impact) * (user_seeks + user_scans) DESC)
http://msdn.microsoft.com/en-us/library/ms345434.aspx
http://msdn.microsoft.com/en-us/library/ms345434.aspx
No comments:
Post a Comment