-- SQLPLAN 확인
/* 입력하는 날짜 두 날짜의 plan 비교(date1, date2 둘다 yyyymmdd 형태로 입력) */
with date1 as (
select distinct sql_id, plan_hash_value
from dba_hist_sqlstat a inner join dba_hist_snapshot b
on (a.snap_id=b.snap_id and a.dbid=b.dbid and a.instance_number=b.instance_number)
where END_INTERVAL_TIME between to_date(:date1-7,'yyyymmdd') and to_date(:date1,'yyyymmdd')+0.99999 /* date1-7일 ~ date1까지 데이터가 before */
and PARSING_SCHEMA_NAME in('DSDBIUSR','INOUSR','ADFUSR') /* 비교가 필요한 계정 입력*/
and EXECUTIONS_DELTA>0
),
date2 as (
select distinct sql_id, plan_hash_value
from dba_hist_sqlstat a inner join dba_hist_snapshot b
on (a.snap_id=b.snap_id and a.dbid=b.dbid and a.instance_number=b.instance_number)
where END_INTERVAL_TIME between to_date(:date2,'yyyymmdd') and to_date(:date2,'yyyymmdd')+0.99999 /* date2가 after */
and PARSING_SCHEMA_NAME in('DSDBIUSR','INOUSR','ADFUSR') /* 비교가 필요한 계정 입력*/
and EXECUTIONS_DELTA>0
)
select sql_id,
date1.plan_hash_value before_plan,
date2.plan_hash_value after_plan,
decode(date1.plan_hash_value,date2.plan_hash_value,'SAME','CHECK') AS CHECK_COL
from date1 inner join date2 using (sql_id)
where decode(date1.plan_hash_value,date2.plan_hash_value,'SAME','CHECK')='CHECK'
order by 4, 1
;
'oracle' 카테고리의 다른 글
[ORACLE] osysmond.bin process high memory usage (0) | 2024.05.30 |
---|---|
[ORACLE] AWR 이용한 SQL PLAN 변경 확인 (0) | 2024.05.29 |
[ORACLE] ORA-27504,ORA-27300,ORA-27301,ORA-27302 (0) | 2023.06.23 |
[ORACLE] ORA-08104 : this index object is being online built or rebuilt (0) | 2023.06.15 |
[ORACLE] Partition Global Index (Global 추출 쿼리) (0) | 2023.06.14 |