--Querying the 50 most CPU-intensive queries
SELECT TOP 50
DB_NAME(dbid) AS DBNAME,
OBJECT_NAME(objectid,dbid) as OBJECTNAME,
total_worker_time/execution_count/1000/1000 AS [CPU Average execution (sec)],
SUBSTRING(st.text, (qs.statement_start_offset/2)+1,
((CASE qs.statement_end_offset
WHEN -1 THEN DATALENGTH(st.text)
ELSE qs.statement_end_offset
END - qs.statement_start_offset)/2) + 1) N'Execution Statements'
,st.text N'Full Words'
,total_worker_time/1000/1000 AS [Total CPU time consumed (seconds)]
,execution_count [number of runs]
,qs.total_worker_time/qs.execution_count/1000/1000 AS [average_execution_time_of_CPU(sec)]
,last_execution_time AS [last execution time]
,max_worker_time /1000/1000 AS [max_execution_time(sec)]
,total_physical_reads N 'total_physical_reads'
,total_logical_reads/execution_count N'number of logical reads per execution'
,total_logical_reads N'total_logical_reads'
,total_logical_writes N'total_logical_writes'
,*
FROM sys.dm_exec_query_stats AS qs
CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) AS st
WHERE last_execution_time> dateadd(minute,-100,getdate())
ORDER BY total_worker_time/execution_count DESC;
GO
Read More:
- MySQL Build table error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL ser
- Dbeaver connects hive to solve the problem that hive custom UDF functions cannot be used in SQL queries in dbeaver
- MYSQL Insert Data Error: check the manual that corresponds to your MySQL server version for the right syntax
- MySQL Change password failure prompt: ERROR 1064(42000):You have an error in your SQL syntax: check the corresponds to your M
- How to Solve can‘t connect to local mysql server through socket ‘/var/lib/mysql/mysql.sock‘
- MYSQL Use cmd to change root password error: ERROR 1064 (42000): You have an error in your SQL syntax; check the manual tha
- MYSQL syntax Error: check the manual that corresponds to your
- How to Fix MySQL ERROR 1130 (HY000): Host ‘XXXX’ is not allowed to connect to this MySQL server
- Mysql 8.0.13 Enabling remote access (ERROR 1064 (42000): You have an error in your SQL syntax; check the manual th)
- How to Solve MYSQL Error: Failed to start MySQL 8.0 database server
- [Solved] MySQL Install Error: GPG check FAILED
- MySql Install Error: Can‘t connect to local MySQL server through socket ‘/tmp/mysql.sock‘
- How to Solve Mysql8 load data error
- MYSQL: How to Use ifnull()
- Mysql Flashback Warning: C:\Program Files\MySQL\MySQL Server 8.0\bin\mysql.exe
- MySQL: How to Turn on Functions
- How to Solve mysql [Err] 1067-Invalid default value for
- [Solved] ERROR 2002 (HY000): Can’t connect to local MySQL server through socket’/var/lib/mysql/mysql.sock’ (2)
- How to Solve MYSQL into outfile Error13
- Docker: How to Solve MYSQL8 & Navicat remote connection error