标签:span add ast serve sys where fse text color
SELECT TOP 10 st.text AS SQL_Full, SUBSTRING( st.text, (qs.statement_start_offset / 2) + 1, ((CASE statement_end_offset WHEN -1 THEN DATALENGTH(st.text) ELSE qs.statement_end_offset END - qs.statement_start_offset ) / 2 ) + 1 ) AS SQL_Part, --统计对应的部分语句 CAST(((qs.total_elapsed_time / 1000000.0) / qs.execution_count) AS DECIMAL(28, 2)) AS [平均消耗秒数], CAST(qs.last_elapsed_time / 1000000.0 AS DECIMAL(28, 2)) AS [最后完成消耗秒数], qs.last_execution_time AS [最后执行时间], CAST(qs.min_elapsed_time / 1000000.0 AS DECIMAL(28, 2)) AS [最小消耗秒数], CAST(qs.max_elapsed_time / 1000000.0 AS DECIMAL(28, 2)) AS [最大消耗秒数], CAST(qs.total_elapsed_time / 1000000.0 AS DECIMAL(28, 2)) AS [总消耗秒数], (qs.execution_count) AS [总执行次数], creation_time AS [编译计划的时间], CAST(qs.last_worker_time / 1000000.0 AS DECIMAL(28, 2)) AS [最后完成占用CPU秒数], qp.query_plan FROM sys.dm_exec_query_stats qs CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) AS st CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) qp WHERE qs.last_execution_time > DATEADD(n, -30, GETDATE()) ORDER BY qs.last_worker_time DESC;
标签:span add ast serve sys where fse text color
原文地址:https://www.cnblogs.com/IIXS/p/13042609.html