sys 계정으로 들어가서 느린 쿼리를 골라 낸다.
SELECT * FROM(
SELECT ROUND(ELAPSED_TIME/EXECUTIONS/1000000,3) AS ELAPSED_TIME
, LAST_ACTIVE_TIME
, SQL_TEXT
FROM V$SQL
WHERE parsing_schema_name = 'SWING'
AND LAST_ACTIVE_TIME >= TO_DATE('20110706', 'YYYYMMDD')
)
WHERE ELAPSED_TIME > 5
order by LAST_ACTIVE_TIME desc;
SELECT ROUND(ELAPSED_TIME/EXECUTIONS/1000000,3) AS ELAPSED_TIME
, LAST_ACTIVE_TIME
, SQL_TEXT
FROM V$SQL
WHERE parsing_schema_name = 'SWING'
AND LAST_ACTIVE_TIME >= TO_DATE('20110706', 'YYYYMMDD')
)
WHERE ELAPSED_TIME > 5
order by LAST_ACTIVE_TIME desc;
전체적으로 통계를 보고 느린 쿼리만 집중 튜닝한다. 아마 운영 중에나 가능할 것 같다.
SELECT
COUNT(*) AS SQL개수
, COUNT(DISTINCT SUBSTR(SQL_TEXT, 1 , 100)) AS SQL유니크개수
, SUM(EXECUTIONS) AS 수행횟수
, ROUND(AVG(ELAPSED_TIME/EXECUTIONS/ 1000000), 2) AS 평균수행시간
, COUNT(CASE WHEN ELAPSED_TIME/EXECUTIONS/1000000 >= 10 THEN 1 END) AS 악성10초이상쿼리
, ROUND(MAX(ELAPSED_TIME/EXECUTIONS/1000000), 2) AS 최대소요시간
FROM V$SQL
WHERE PARSING_SCHEMA_NAME = 'SWING'
AND LAST_ACTIVE_TIME >= TO_DATE('20110706', 'YYYYMMDD')
COUNT(*) AS SQL개수
, COUNT(DISTINCT SUBSTR(SQL_TEXT, 1 , 100)) AS SQL유니크개수
, SUM(EXECUTIONS) AS 수행횟수
, ROUND(AVG(ELAPSED_TIME/EXECUTIONS/ 1000000), 2) AS 평균수행시간
, COUNT(CASE WHEN ELAPSED_TIME/EXECUTIONS/1000000 >= 10 THEN 1 END) AS 악성10초이상쿼리
, ROUND(MAX(ELAPSED_TIME/EXECUTIONS/1000000), 2) AS 최대소요시간
FROM V$SQL
WHERE PARSING_SCHEMA_NAME = 'SWING'
AND LAST_ACTIVE_TIME >= TO_DATE('20110706', 'YYYYMMDD')