暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

ASH分析等待事件分析

原创 Temi 2021-03-28
1392

1.在必要的时候备份下gv$active_session_history
create table ash_xxxx as select * from gv$active_session_history
where SAMPLE_TIME between TO_TIMESTAMP (’<time_begin>’, ‘YYYY-MM-DD HH24:MI:SS’) and TO_TIMESTAMP (’<time_end>’, ‘YYYY-MM-DD HH24:MI:SS’);

2.通过ash速查找阻塞源头
–分钟级
col sample_time for a30
col event for a60
col count(1) for 999999
select to_char(trunc(sample_time,‘mi’),‘yyyy-mm-dd hh24:mi:ss’) sample_time,event,count(1)
from gv$active_session_history
where sample_time >=to_date(’&begin_time’,‘yyyy-mm-dd hh24:mi:ss’)
and sample_time <=to_date(’&end_time’,‘yyyy-mm-dd hh24:mi:ss’)
group by trunc(sample_time,‘mi’),event order by 1;

–秒级
select to_char(sample_time,‘yyyy-mm-dd hh24:mi:ss’) sample_time,event,count(1)
from gv$active_session_history
where sample_time >=to_date(’&begin_time’,‘yyyy-mm-dd hh24:mi:ss’)
and sample_time <=to_date(’&end_time’,‘yyyy-mm-dd hh24:mi:ss’)
group by to_char(sample_time,‘yyyy-mm-dd hh24:mi:ss’),event order by 1;

3.查看某段时间阻塞链
with ash as (select inst_id,SESSION_ID,event,BLOCKING_SESSION,program ,
to_char(SAMPLE_TIME,‘YYYYMMDD HH24MISS’) SAMPLE_TIME,sample_id,blocking_inst_id
from gv$active_session_history where
sample_time >to_date(‘2021-03-01 00:00:00’,‘yyyy-mm-dd hh24:mi:ss’)
and
to_char(sample_time,‘hh24:mi:ss’) between ‘06:00:00’ and ‘06:10:00’)
select SAMPLE_TIME,FINAL_BLK,FINAL_PROGRAM,
nvl(FINAL_EVT,‘ON CPU’) as FINAL_EVT
,(LVL2_EVENT) as LVL2_EVENT,LVL3_EVENT,LVL4_EVENT,
count() from(
select SESSION_ID,SAMPLE_TIME,sys_connect_by_path(SESSION_ID,’,’) CHAIN,
connect_by_root(PROGRAM)as FINAL_PROGRAM,
connect_by_root(SESSION_ID)FINAL_BLK,
connect_by_root(event) FINAL_EVT,event ,
case when level=2 then event end as LVL2_EVENT ,
case when level=3 then event end as LVL3_EVENT ,
case when level=4 then event end as LVL4_EVENT
from ash start with BLOCKING_SESSION is null
connect by prior SESSION_ID = BLOCKING_SESSION and prior inst_id= BLOCKING_INST_ID and sample_id = prior sample_id
) group by FINAL_BLK,FINAL_EVT,SAMPLE_TIME,FINAL_PROGRAM ,LVL3_EVENT,LVL4_EVENT,LVL2_EVENT
having count(
) > 1
order by SAMPLE_TIME,count(*) desc

–https://blogs.oracle.com/database4cn/

最后修改时间:2021-03-28 23:34:47
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论