MS-SQL > dm_exec_query_stats , dm_exec_sql_text - CPU »ç¿ë·®ÀÌ ¸¹Àº Äõ¸®¹®À» ã¾Æ¶ó.
µî·ÏÀÏ : 2017-07-03 19:55
Á¶È¸¼ö : 91,202
»ç¿ë·®ÀÌ ¸¹Àº Äõ¸®¹®À» ã°í ½ÍÀ» °æ¿ì »ç¿ëÇϼ¼¿ä.
SELECT TOP 10
REPLACE(CONVERT(VARCHAR(20), CONVERT(MONEY,qs.total_worker_time / qs.execution_count/1000),1),'.00','')
as [Avg CPU Time(ms)]
,qs.execution_count
,substring (qt.text,
qs.statement_start_offset/2+1,
(case when qs.statement_end_offset = -1 then len (convert (nvarchar(max), qt.text)) * 2
else qs.statement_end_offset end - qs.statement_start_offset)/2) as query_text
,qt.dbid
,sd.name
,qt.objectid
,qt.number
,qt.encrypted
,qt.text
,sr.session_id
,sr.command
,sr.status
,sr.last_wait_type
,sr.wait_resource
,sq.query_plan
,fs.text
FROM sys.dm_exec_query_stats qs
CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) as qt
CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) as sq
LEFT OUTER JOIN sys.databases as sd on qt.dbid = sd.database_id
LEFT OUTER JOIN sys.dm_exec_requests as sr on qs.sql_handle = sr.sql_handle
OUTER APPLY sys.fn_get_sql(sr.sql_handle) AS fs
ORDER BY qs.total_worker_time / qs.execution_count DESC