我有一个简单的查询,可以通过 query_plan_hash 和 query_hash显示前 10 个经过的时间:
PRINT '-- top 10 elapsed time by query_plan_hash and query_hash --'
SELECT TOP 10 query_plan_hash
,query_hash
,sum(execution_count) AS 'execution_count'
,sum(total_worker_time) AS 'total_worker_time'
,SUM(total_elapsed_time) AS 'total_elapsed_time'
,SUM(total_logical_reads) AS 'total_logical_reads'
,max(REPLACE(REPLACE(REPLACE(SUBSTRING(CONVERT(NVARCHAR(4000), st.[text]), qs.statement_start_offset / 2 + 1, CASE
WHEN qs.statement_end_offset = - 1
THEN LEN(st.[text])
ELSE qs.statement_end_offset / 2 - qs.statement_start_offset / 2 + 1
END), CHAR(13), ' '), CHAR(10), ' '), CHAR(09), ' ')) AS sample_statement_text
FROM sys.dm_exec_query_stats AS qs
CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) AS st
GROUP BY query_plan_hash
,query_hash
ORDER BY sum(total_elapsed_time) DESC;
GO
我如何计算:
- 总工作时间
- 总经过时间
- 逻辑读取总数
以分钟而不是毫秒为单位?