性能检测参考SQL语句
时间:2021-07-01 10:21:17
帮助过:3人阅读
***** Object: StoredProcedure [dbo].[SP_CPU] Script Date: 12/09/2018 19:01:24 ******/
SET ANSI_NULLS
ON
GO
SET QUOTED_IDENTIFIER
ON
GO
CREATE Proc [dbo].
[SP_CPU]
as
SELECT TOP 10 total_worker_time
/ execution_count
/1000 AS [Avg CPU Time],
(SELECT Substring(
text, statement_start_offset
/ 2, (
CASE
WHEN statement_end_offset
= -1 THEN Len(
CONVERT(
NVARCHAR(
max),
text))
* 2
ELSE statement_end_offset
END - statement_start_offset )
/ 2)
FROM sys.Dm_exec_sql_text(sql_handle))
AS query_text,
last_execution_time,execution_count,total_worker_time,last_worker_time,min_worker_time,max_worker_time,total_elapsed_time,last_elapsed_time,min_elapsed_time,max_elapsed_time,last_logical_reads,last_logical_writes,last_physical_reads
FROM sys.dm_exec_query_stats
ORDER BY [Avg CPU Time] DESC
GO
性能检测参考SQL语句
标签:query avg min ast span har text lse arch