mssql 비용이 많이드는 쿼리 검색
sys.dm_exec_query_stats(Transact-SQL) 참고
SELECT
SUBSTRING(qt.TEXT, (qs.statement_start_offset/2)+1,
((
CASE qs.statement_end_offset
WHEN -1 THEN DATALENGTH(qt.TEXT)
ELSE qs.statement_end_offset
END - qs.statement_start_offset)/2)+1) 수행쿼리,
qs.execution_count 쿼리계획이_마지막컴파일후_실행횟수,
qs.total_logical_reads 쿼리계획이_컴파일후_실행될때_수행한_총논리적읽기수,
qs.last_logical_reads 마지막_수행한_논리적읽기수,
qs.total_logical_writes 쿼리계획이_컴파일후_실행될때_수행한_총논리적쓰기수,
qs.last_logical_writes 마지막_수행한_논리적쓰기수,
qs.total_worker_time [쿼리계획이_컴파일후_실행될때_사용된_총CPU시간(마이크로초)],
qs.last_worker_time [마지막_실행될때_사용된_CPU시간(마이크로초)],
qs.total_elapsed_time/1000000 [실행완료하는데 소요된 총 경과시간(마이크로초)_초로변환],
qs.last_elapsed_time/1000000 [최근 실행완료하는데 소요된 경과시간(마이크로초)_초로변환],
qs.last_execution_time 해당쿼리가_마지막으로_실행된_시간,
qp.query_plan 실행계획
FROM sys.dm_exec_query_stats qs
CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) qt
CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) qp
ORDER BY qs.last_worker_time DESC
-- ORDER BY qs.total_logical_reads DESC
-- ORDER BY qs.total_logical_writes DESC
-- ORDER BY qs.total_worker_time DESC