개발노트

9. [MS-SQL] 과부화걸리는 쿼리 찾기 본문

DB/MS-SQL

9. [MS-SQL] 과부화걸리는 쿼리 찾기

mroh1226 2023. 5. 9. 15:21
반응형

-과부하걸리는 찾기

SELECT TOP 20 
 [Average CPU used] = total_worker_time / qs.execution_count
,[Total CPU used] = total_worker_time
,[Last CPU used] = last_worker_time
,[MAX CPU used] = max_worker_time
,[Execution count] = qs.execution_count
,[Individual Query] = SUBSTRING (qt.text,qs.statement_start_offset/2, 
         (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)
,[Parent Query] = qt.text
,DatabaseName = DB_NAME(qt.dbid)
,qs.creation_time
,qs.last_execution_time
FROM sys.dm_exec_query_stats qs
CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) as qt
ORDER BY [Average CPU used] DESC;
반응형
Comments