SELECT TOP(5) DB_NAME(T.[DBID]) AS [DATABASE NAME]
,T.[TEXT]AS[QUERY TEXT]
,QS.TOTAL_WORKER_TIME -- 총 CPU시간
,QS.MIN_WORKER_TIME -- 단일실행 중, 최소 CPU시간
,QS.MAX_WORKER_TIME -- 단일실행 중, 최대 CPU시간
,QS.TOTAL_ELAPSED_TIME -- 총 쿼리수행 시간
,QS.EXECUTION_COUNT -- 실행된 횟수
,QS.TOTAL_LOGICAL_READS -- 논리적 읽기
,QS.TOTAL_WORKER_TIME/QS.EXECUTION_COUNT AS [AVG WORKER TIME]
,QS.TOTAL_ELAPSED_TIME/QS.EXECUTION_COUNT AS [AVG ELAPSED TIME]
,QS.TOTAL_LOGICAL_READS/QS.EXECUTION_COUNT AS [AVG LOGICAL READS]
,QS.TOTAL_PHYSICAL_READS/QS.EXECUTION_COUNT AS [AVG PHYSICAL READS]
,QP.QUERY_PLAN
,QS.CREATION_TIME
FROM SYS.DM_EXEC_QUERY_STATS AS QS WITH (NOLOCK)
CROSS APPLY SYS.DM_EXEC_SQL_TEXT(PLAN_HANDLE) AS T
CROSS APPLY SYS.DM_EXEC_QUERY_PLAN(PLAN_HANDLE) AS QP
ORDER BY QS.TOTAL_WORKER_TIME DESC OPTION (RECOMPILE);