查询耗费CPU最多的SQL语句
来源:互联网 发布:追信魔盒在线制作软件 编辑:程序博客网 时间:2024/05/16 07:10
SELECT
TOP
10
total_worker_time/execution_count
AS
avg_cpu_cost, plan_handle,
execution_count,
(
SELECT
SUBSTRING
(text, statement_start_offset/2 + 1,
(
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
[avg_cpu_cost]
DESC
--得到最耗时的前N条T-SQL语句
--适用于SQL SERVER 2005及其以上版本
--给N赋初值为30
declare @n int set @n=30
;with maco as
(
select top (@n)
plan_handle,
sum(total_worker_time) as total_worker_time ,
sum(execution_count) as execution_count ,
count(1) as sql_count
from sys.dm_exec_query_stats group by plan_handle
order by sum(total_worker_time) desc
)
select t.text ,
a.total_worker_time ,
a.execution_count ,
a.sql_count
from maco a
cross apply sys.dm_exec_sql_text(plan_handle) t
0 0
- 查询耗费CPU最多的SQL语句
- 监控消耗CPU最多的语句
- SQL Server中查询CPU占用高的SQL语句
- SQL Server中查询CPU占用高的SQL语句
- SQL Server中查询CPU占用高的SQL语句
- SQL Server中查询CPU占用高的SQL语句
- SQL执行中占CPU资源最多的前10条查询
- oracle 实时查询最耗CPU资源的SQL语句
- oracle 实时查询最耗CPU资源的SQL语句
- oracle 实时查询最耗CPU资源的SQL语句
- col 命令+查询最消耗cpu资源的SQL语句
- oracle实时查询最耗CPU资源的SQL语句
- Oracle查询当前高CPU消耗的SQL语句
- oracle 实时查询最耗CPU资源的SQL语句
- oracle 实时查询最耗CPU资源的SQL语句
- ORALE实时查询最消耗CPU资源的SQL语句
- oracle 实时查询最耗CPU资源的SQL语句
- SQL 查询重复出现次数最多的记录,按出现频率排序(SQL语句)
- Android的NDK开发(1)————Android JNI简介与调用流程
- XPOSED源码研究之XposedInstaller(1)从manifest开始XposedApp
- metasploit常用命令
- 2015多校第一场1002(单调队列、STL multiset、)
- PCIe SSD 加速MongoDB
- 查询耗费CPU最多的SQL语句
- quick cocos2d-x 与android实现更换头像
- iphone开发具备条件以及一些vim常见指令的意思
- Linux 下 自动删除N天前文件
- XPOSED源码研究之XposedInstaller(2)从manifest开始WelcomeActivity
- Redis介绍
- C#.NET WebApi返回各种类型(图片转二进制流或byte /json数据/字符串)
- [Elasticsearch] 聚合的测试数据 2
- LoaderManager使用详解(一)---没有Loader之前的世界