历史执行Sql语句性能分析 CPU资源占用时间分析



SELECT
    HIGHEST_CPU_QUERIES.PLAN_HANDLE,
    HIGHEST_CPU_QUERIES.TOTAL_WORKER_TIME,
    Q.DBID,
    Q.OBJECTID,
    Q.NUMBER,
    Q.ENCRYPTED,
    Q.[TEXT],max_WORKER_TIME,last_execution_time
FROM
    (SELECT TOP 50
        QS.PLAN_HANDLE,
        QS.TOTAL_WORKER_TIME,
                QS.execution_count,max_WORKER_TIME,last_execution_time
    FROM
        SYS.DM_EXEC_QUERY_STATS QS where datediff(d, last_execution_time,getdate())=0
    ORDER BY QS.TOTAL_WORKER_TIME DESC) AS HIGHEST_CPU_QUERIES
    CROSS APPLY SYS.DM_EXEC_SQL_TEXT(PLAN_HANDLE) AS Q
ORDER BY HIGHEST_CPU_QUERIES.TOTAL_WORKER_TIME DESC

你可能感兴趣的:(sql语句)