码迷,mamicode.com
首页 > 数据库 > 详细

查询Sql慢语句

时间:2020-06-23 11:38:09      阅读:93      评论:0      收藏:0      [点我收藏+]

标签:substring   arch   case when   start   fse   work   statement   sub   esc   

SELECT TOP 10 execution_count as [Number Of Executions],
total_worker_time/execution_count as [Average CPU Time],
total_elapsed_time/execution_count as [Average Elapsed 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
FROM sys.dm_exec_query_stats
ORDER BY [Average CPU Time] DESC;

查询Sql慢语句

标签:substring   arch   case when   start   fse   work   statement   sub   esc   

原文地址:https://www.cnblogs.com/sxmny/p/13181197.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!