sqlserver 索引优化 CPU占用过高 执行分析 服务器检查[转]

时间:2021-07-08 03:42:40

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;

微软名字起的也很直白,直接叫missing_index,就是sqlserver 经过分析认为这些字段处理和查询是最耗时的,最好在 EqualityUsage上包含的字段上加个非聚集索引.前几个用时是后几名的好几个数量级.加了索引立马飞起.

转自[https://www.cnblogs.com/qiaqia-liu/p/10687619.html], 谢谢原作者.