How do I find out what is hammering my SQL Server?

后端 未结 6 2099
闹比i
闹比i 2020-12-07 08:45

My SQL Server CPU has been at around 90% for the most part of today.

I am not in a position to be able to restart it due to it being in constant use.

Is it p

6条回答
  •  轮回少年
    2020-12-07 09:19

    This query uses DMV's to identify the most costly queries by CPU

    SELECT TOP 20
        qs.sql_handle,
        qs.execution_count,
        qs.total_worker_time AS Total_CPU,
        total_CPU_inSeconds = --Converted from microseconds
            qs.total_worker_time/1000000,
        average_CPU_inSeconds = --Converted from microseconds
            (qs.total_worker_time/1000000) / qs.execution_count,
        qs.total_elapsed_time,
        total_elapsed_time_inSeconds = --Converted from microseconds
            qs.total_elapsed_time/1000000,
        st.text,
        qp.query_plan
    FROM
        sys.dm_exec_query_stats AS qs
    CROSS APPLY 
        sys.dm_exec_sql_text(qs.sql_handle) AS st
    CROSS APPLY
        sys.dm_exec_query_plan (qs.plan_handle) AS qp
    ORDER BY 
        qs.total_worker_time DESC
    

    For a complete explanation see: How to identify the most costly SQL Server queries by CPU

提交回复
热议问题