------------------------------------------------------------
-- file ashsp.sql
-- desc ASH sess level w/params, last x min (min SID SER partial event)
-- author Craig A. Shallahamer, craig@orapub.com
-- orig 02-April-07
-- lst upt 09-April-07
-- copyright (c)2007 OraPub, Inc.
-- It is possible to get percentages greater/lesser than 100% because there
-- is a time lag between the total calculations and the report query
------------------------------------------------------------
def sleep_time_min=&1
def sid=&2
def ser=&3
def partial_event=&4
set echo off
set feedback off
set heading on
set verify off
set termout on
def osm_prog = 'ashsp.sql'
def osm_title = 'Session Level ASH By Event w/parameters (last &sleep_time_min min)'
start osmtitle
col event format a38 heading "Wait Event" trunc
col time_pct format 990.00 heading "% Time|Waited"
col p1 format 999999
select ash.event,
p1,p2,p3,
count(distinct(p1||p2||p3)) occurs
from v$active_session_history ash
where ash.sample_time between (sysdate-&sleep_time_min/(60*24)) and sysdate
and ash.session_id=&sid
and ash.session_serial#=&ser
and ash.event like '%&partial_event%'
group by ash.event,p1,p2,p3
having count(distinct(p1||p2||p3)) 1
order by 1,2,3
/
--order by ash.event,ash.p1,ash.p2,ash.p3
start osmclear
--This may be helpful
--select to_char(sysdate,'DD-Mon-YY HH24:MI:SS') now,
-- to_char(sysdate-24/24,'DD-Mon-YY HH24:MI:SS') one_day_prior,
-- to_char(sysdate-1/24,'DD-Mon-YY HH24:MI:SS') one_hour_prior,
-- to_char(sysdate-1/(60*24),'DD-Mon-YY HH24:MI:SS') one_min_prior,
-- to_char(sysdate-30/(60*24),'DD-Mon-YY HH24:MI:SS') thirty_min_prior
--from dual;