数据库索引优化

1.使用以下方法可以获取到缺失索引的表的详细信息:

 

  SELECT  TOP 10
          [Total Cost]  = ROUND(avg_total_user_cost * avg_user_impact * (user_seeks + user_scans),0)
        , avg_user_impact
         , TableName = statement
        , [EqualityUsage] = equality_columns
         , [InequalityUsage] = inequality_columns
        , [Include Cloumns] = included_columns
 FROM        sys.dm_db_missing_index_groups g
  INNER JOIN    sys.dm_db_missing_index_group_stats s         ON s.group_handle = g.index_group_handle
 INNER JOIN    sys.dm_db_missing_index_details d
        ON d.index_handle = g.index_handle
 ORDER BY [Total Cost] DESC;

2.结果如图:

EqualityUsage :用 = 查询列

InequalityUsage:用<> 查询的列

Include Cloumns:用 in 查询的列

 

可根据以上查询结果建立相应的索引

 

你可能感兴趣的:(数据库索引优化)