获取某时间段内的top session_id+session_serial#
set linesize 260 pagesize 10000
col nvl(event,'ON CPU') for a40
select *
from (select session_id,session_serial#,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 session_id,session_serial#,sql_id,nvl(event,'ON CPU')
order by count(*) desc)
where rownum <=10;
获取某时间段内的BLOCKING_INST_ID、BLOCKING_SESSION、BLOCKING_SESSION_SERIAL#分组
select BLOCKING_SESSION_STATUS,
BLOCKING_SESSION,
BLOCKING_SESSION_SERIAL#,
BLOCKING_INST_ID,
count(*)
from v$active_session_history a
where event like 'cursor%'
and sample_time between
to_date('&date1', 'yyyy-mm-dd hh24:mi:ss') and
to_date('&date2', 'yyyy-mm-dd hh24:mi:ss')
group by BLOCKING_SESSION_STATUS, BLOCKING_SESSION ,BLOCKING_SESSION_SERIAL# ,BLOCKING_INST_ID
order by count(*) desc;




