sqlselect * from DBA_HIST_SQLTEXT where sql_id ='4b6z0rh5jrktx';
select * from DBA_HIST_SQL_PLAN where sql_id ='4b6z0rh5jrktx' order by plan_hash_value, id;
select * from DBA_HIST_SQLSTAT where sql_id ='4b6z0rh5jrktx';
select * from v$sql where sql_id ='4b6z0rh5jrktx';
select sql_id, plan_hash_value, id, count(*) from dba_hist_sql_plan group by sql_id, plan_hash_value, id
having count(*) > 1;
WRH$_SQL_PLAN
select * from(
select a.aid, b.bid from
(select distinct sql_id as aid from DBA_HIST_SQLTEXT) A full outer join
(select sql_id as bid from DBA_HIST_SQLSTAT ) B
on a.aid = b.bid) c
where c.bid is null;
select * from(
select a.aid, b.bid from
(select distinct sql_id as aid from sys.WRH$_SQLTEXT) A full outer join
(select sql_id as bid from sys.WRH$_SQLSTAT ) B
on a.aid = b.bid) c
where c.bid is null;
select * from sys.WRH$_SQLTEXT where sql_id ='6rjdxthsp2yd4';
select * from sys.WRH$_SQLSTAT where sql_id ='6rjdxthsp2yd4';
select * from sys.WRH$_SQL_PLAN where sql_id ='6rjdxthsp2yd4';
select *
FROM WRM$_SNAPSHOT sn, WRH$_SQLSTAT sql
WHERE sn.snap_id = sql.snap_id
AND sn.dbid = sql.dbid
AND sn.instance_number = sql.instance_number
AND sn.status = 0;
select * From dba_hist_snapshot where snap_id = 96410 order by 1 desc;
select * From sys.WRH$_SQLTEXT b where not exists(select 'x' from sys.WRH$_SQLstat a where a.sql_id = b.sql_id);
select * From dba_objects where object_name='AWR_ROOT_SQLTEXT';
select * From dict where table_name='AWR_ROOT_SQLTEXT';
select sql_id, plan_hash_value, count(*)
from DBA_HIST_SQLSTAT s
where s.parsing_schema_name = 'KALMHS'
group by sql_id, plan_hash_value order by 1
;
----------------------
-- sql_id 추출
----------------------
select sql_id, sql_text, replace(dbms_lob.substr(sql_text, 20, 1), chr(10), ' '),
(select command_name from DBA_HIST_SQLCOMMAND_NAME where command_type=t.command_type) type
from DBA_HIST_SQLTEXT T
where exists (select 'EXIST'
from DBA_HIST_SQLSTAT S
where t.sql_id = s.sql_id
and s.parsing_schema_name = 'KALMHS');
;
select * from (
select t.sql_id,
t.sql_text,
replace(dbms_lob.substr(t.sql_text, 20, 1), chr(10), ' '),
(select command_name from DBA_HIST_SQLCOMMAND_NAME where command_type=t.command_type) type,
p.plan_hash_value
from DBA_HIST_SQLTEXT T,
(select sql_id, plan_hash_value from
(select sql_id, plan_hash_value,
row_number() over (partition by sql_id order by sql_id, timestamp desc) row_num
from DBA_HIST_SQL_PLAN
where 1 = 1) -- 전체 SQL
where row_num = 1) P
where t.sql_id = p.sql_id(+))
where plan_hash_value is null and type='SELECT';
select a.sql_id, b.sql_id, b.command_type from
(select distinct sql_id from v$sql) a, DBA_HIST_SQLTEXT b
where a.sql_id = b.sql_id(+)
;-- where sql_id='3hc96wfvxp4tk';
-- 56196, 9610
select distinct sql_id from DBA_HIST_SQLTEXT;
--> 5540
select sql_id, sql_text, sql_t, type, plan_hash_value, parsing_schema_name
from (
select t.sql_id,
t.sql_text,
replace(dbms_lob.substr(t.sql_text, 20, 1), chr(10), ' ') sql_t,
(select command_name from DBA_HIST_SQLCOMMAND_NAME where command_type=t.command_type) type,
p.plan_hash_value,
(select parsing_schema_name from DBA_HIST_SQLSTAT S where 1=1 and s.sql_id = t.sql_id
and s.plan_hash_value = p.plan_hash_value and rownum = 1) parsing_schema_name
from DBA_HIST_SQLTEXT T,
(select sql_id, plan_hash_value from
(select sql_id, plan_hash_value,
row_number() over (partition by sql_id order by sql_id, timestamp desc) row_num
from DBA_HIST_SQL_PLAN
where 1 = 1) -- 전체 SQL
where row_num = 1) P
where t.sql_id = p.sql_id
and exists ( select 'X'
from DBA_HIST_SQLSTAT S
where s.parsing_schema_name in ('KALMHS','KALPPO','NETBACKUP','KALPPO_SSO','KALSTD')
and module like '%%'
and s.sql_id = t.sql_id
and s.plan_hash_value = p.plan_hash_value)
)
order by 1;
select t.*,
sql_id, replace(dbms_lob.substr(t.sql_text, 20, 1), chr(10), ' ') sql_t,
(select command_name from DBA_HIST_SQLCOMMAND_NAME where command_type=t.command_type) type,
parsing_schema_name
From v$sql t
where t.parsing_schema_name in ('KALMHS','KALPPO','NETBACKUP','KALPPO_SSO','KALSTD');
where plan_hash_value is null and type='SELECT';
select sql_id, count(*) From v$sql group by sql_id having count(*) > 1;
select * From dba_tab_columns where column_name = 'MODULE' order by table_name;
select * from v$sql where sql_id='grvaq6wc3s189';
select * From dict where table_name like '%SHARED%';
select * from V$SQL_SHARED_CURSOR where sql_id='grvaq6wc3s189';
SELECT
A.SQL_ID,
A.SQL_TEXT,
A.COMMAND_TYPE, --> IF NEEDED
B.PLAN_HASH_VALUE,
B.ID,
B.OPERATION,
B.OPTIONS,
B.OBJECT_OWNER,
B.OBJECT_NAME,
B.OBJECT_TYPE,
B.OPTIMIZER,
B.PARTITION_START,
B.PARTITION_STOP,
B.PARTITION_ID
FROM DBA_HIST_SQLTEXT A, DBA_HIST_SQL_PLAN B
WHERE A.DBID = B.DBID
AND A.SQL_ID = B.SQL_ID
AND A.SQL_ID IN('03y5xw17vncxd')
AND EXISTS
(SELECT 'E'
FROM DBA_HIST_SQLSTAT C
WHERE A.DBID = C.DBID
AND A.SQL_ID = C.SQL_ID
AND B.SQL_ID = C.SQL_ID
AND B.PLAN_HASH_VALUE <> C.PLAN_HASH_VALUE
AND PARSING_SCHEMA_NAME IN('KALMHS'))
ORDER BY A.DBID, A.SQL_ID, B.PLAN_HASH_VALUE, B.ID;
'ORACLE' 카테고리의 다른 글
Oracle RMAN (0) | 2021.12.17 |
---|---|
ORACLE ATP DB 접속 (0) | 2020.01.27 |
Oracle ATP DB 생성 (0) | 2020.01.27 |
V$SQL (0) | 2019.12.22 |
Oracle tkprof (0) | 2019.12.21 |