본문 바로가기
[DATABASE] ORACLE/SQL Tuning

리터럴(Literal) SQL

by 기미차니 2022. 1. 4.
반응형

오라클 리터럴(Literal) SQL 및 성능정보 확인

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
SELECT *
FROM ( SELECT ( SELECT parsing_schema_name FROM v$sqlarea WHERE sql_id=a.max_sql_id ) as schema
            , ( SELECT module FROM v$sqlarea WHERE sql_id=a.max_sql_id ) as module
            , a.max_sql_id
            , a.plan_cnt
            , a.literal_sql_cnt
            , a.execution_cnt
            , buffer_gets
            , buffer_gets_per
            , cpu_time
            , cpu_time_per
            , elapsed
            , elapsed_per
            , SUBSTR((SELECT sql_fulltext FROM v$sqlarea WHERE sql_id = a.max_sql_id),1,300) sql_text
       FROM ( SELECT force_matching_signature
                   , COUNT(exact_matching_signature) literal_sql_cnt
                   , SUM(executions) execution_cnt
                   , MAX(sql_id) max_sql_id
                   , COUNT(DISTINCT plan_hash_value) plan_cnt
                   , SUM(buffer_gets) buffer_gets
                   , TRUNC(SUM(buffer_gets)/SUM(executions)) buffer_gets_per
                   , ROUND(SUM(cpu_time)/10000002) cpu_time
                   , ROUND(SUM(cpu_time)/SUM(executions)/10000002) cpu_time_per
                   , ROUND(SUM(elapsed_time)/10000002) elapsed
                   , ROUND(SUM(elapsed_time)/SUM(executions)/10000002) elapsed_per
              FROM v$sql
              WHERE parsing_schema_name NOT IN ('SYS','SYSTEM','SYSMAN')
              AND executions > 0
              GROUP BY force_matching_signature
              HAVING COUNT(exact_matching_signature) >= 2
       ) a
       ORDER BY literal_sql_cnt DESC 
WHERE rownum <= 100
;
cs
반응형

댓글