2、查詢一段時(shí)間內(nèi) sql 總等待時(shí)間
select event,a.sql_id,sql_text,sum(time_waited)
from v$active_session_history a,v$sql s
where a.SQL_ID=s.SQL_ID
and a.SAMPLE_TIME>to_date('20190124 12:00:00','yyyymmdd hh24:mi:ss')
and a.SAMPLE_TIME<to_date('20190124 12:30:00','yyyymmdd hh24:mi:ss')
group by event,a.sql_id,sql_text
order by 4 desc;
2、查詢一段時(shí)間內(nèi) sql 單次執(zhí)行時(shí)間
select sql_id,s.SQL_TEXT,s.ELAPSED_TIME/s.EXECUTIONS
from v$sqlstats s
where s.LAST_ACTIVE_TIME>to_date('20190124 12:00:00','yyyymmdd
hh24:mi:ss')
and s.LAST_ACTIVE_TIME>to_date('20190124 12:00:00','yyyymmdd
hh24:mi:ss')
and s.EXECUTIONS>0
order by 3 desc;
3、查詢歷史會(huì)話阻塞等待情況
select
a.SAMPLE_TIME,a.SESSION_ID,a.SQL_ID,a.WAIT_TIME,a.BLOCKING_SESSION
from v$active_session_history a
where a.MACHINE='41cb3c835bb1'
and a.SAMPLE_TIME>to_date('20190125 15:50:00','yyyymmdd hh24:mi:ss')
and a.SAMPLE_TIME<to_date('20190125 16:10:00','yyyymmdd hh24:mi:ss')
group by event
order by 4 desc;
4、查詢 undo 表空間使用較多的表
select a.segment_name, count(*)
from dba_undo_extents a,
(SELECT n.name name
FROM V$session s, V$transaction t, V$rollstat r, v$rollname n
WHERE s.saddr = t.ses_addr
AND t.xidusn = r.usn
AND r.usn = n.usn) b
where a.segment_name = b.name
and a.status = 'ACTIVE'
group by a.segment_name
order by count(*);
5、查詢導(dǎo)致 undo 使用量和使用率高的會(huì)話
select b.sid,
文檔被以下合輯收錄
評(píng)論