采样某瞬时SAMPLE_TIME或者某时间段内SAMPLE_TIME
1.采样某瞬时SAMPLE_TIME的SQL_ID||SQL_PLAN_HASH_VALUE、EVENT的活动会话分组
某个sample_time时间点查看该sample_time时间点的等待事件和相关SQL_ID、p1、p2等参数
set linesize 260 pagesize 10000
select sql_id, nvl(event,'on cpu') event,count(*),p1||'',p2||''
from v$active_session_history a
where sample_id=&sample_id
group by sql_id, nvl(event,'on cpu'),p1||'',p2||''
order by count(*) desc;
某个sample_time时间点查看该sample_time时间点的等待事件和SQL_PLAN_HASH_VALUE、p1、p2等参数
set linesize 260 pagesize 10000
select SQL_PLAN_HASH_VALUE, nvl(event,'on cpu') event, count(*),p1||'',p2||''
from v$active_session_history a
where sample_id=&sample_id
group by SQL_PLAN_HASH_VALUE, nvl(event,'on cpu'),p1||'',p2||''
order by count(*) desc;
2.采样某时间段内SAMPLE_TIME的SQL_ID||SQL_PLAN_HASH_VALUE、EVENT的活动会话的分组
某时间段内等待事件和相关SQL_ID、p1、p2等参数
set linesize 260 pagesize 10000
col nvl(event,'ON CPU') for a40
select *
from (select sql_id, nvl(event,'ON CPU'), count(*)
from gv$active_session_history
where sample_time between
to_date('&date1', 'yyyy-mm-dd hh24:mi:ss') and
to_date('&date2', 'yyyy-mm-dd hh24:mi:ss')
and inst_id in (select instance_number from v$instance)
group by sql_id, event
order by count(*) desc)
where rownum