1
如果下面查詢中使用dm_exec_procedure_stats的[Total Duration(s)]列給我查詢返回其結果所需的平均時間,是否有人可以confim?我擔心這只是這些查詢返回結果的時間中的一個因素,因爲它們顯得太低。sys.dm_exec_procedure_stats - 我是否正確解釋
感謝大家花時間看看。
任何幫助或提醒,將不勝感激
SELECT SUBSTRING(qt.TEXT, CHARINDEX('USP_', qt.TEXT, 1), CHARINDEX(']', qt.TEXT, CHARINDEX('USP_', qt.TEXT, 1)) - CHARINDEX('USP_', qt.TEXT, 1)) AS Procedure_Name,
qt.TEXT,
CAST(total_elapsed_time/1000000.0 AS DECIMAL(28, 2)) AS [Total Duration (s)],
CASE
WHEN execution_count = 0 THEN 0
ELSE CAST(total_worker_time * 100.0/total_elapsed_time AS DECIMAL(28, 2))
END AS [% CPU],
CASE
WHEN execution_count = 0 THEN 0
ELSE CAST((total_elapsed_time - total_worker_time) * 100.0/total_elapsed_time AS DECIMAL(28, 2))
END AS [% Waiting],
execution_count,
CASE
WHEN execution_count = 0 THEN 0
ELSE CAST(total_elapsed_time/1000000.0/execution_count AS DECIMAL(28, 2))
END AS [Average Duration (s)],
sql_handle,
plan_handle,
object_id,
total_elapsed_time,
total_worker_time,
execution_count,
total_physical_reads,
total_logical_reads,
total_logical_writes
FROM sys.dm_exec_procedure_stats qs
CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) AS qt
WHERE qt.text LIKE '%USP%'
ORDER BY 1