Eu tenho uma consulta fácil que pode me mostrar os 10 principais tempos decorridos por query_plan_hash e query_hash :
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
Como posso calcular:
- total_worker_time
- total_tempo_decorrido
- leituras_lógicas_totais
em minutos em vez de milissegundos?