DBA SGA Wait Event Summary (active session history)

Description
Categories: Enginatics
Repository: Github
Wait event and CPU usage summary from the SGA active session history.
select
100*gash.seconds/xxen_util.zero_to_null(sum(gash.seconds) over (partition by &gash_inst_id 1)) percentage,
gash.seconds/gash.total_seconds active_sessions,
xxen_util.time(gash.seconds) time,
&gash_inst_id
gash.seconds,
gash.wait_class,
&gash_event
xxen_util.time(gash.total_seconds) time_window
from
(
select distinct
&gash_inst_id
count(*) over (partition by &gash_inst_id gash.wait_class,&gash_event 1) seconds,
nvl(gash.wait_class,'ON CPU') wait_class,
&gash_event
(max(cast(gash.sample_time as date)) over (partition by &gash_inst_id 1)-min(cast(gash.sample_time as date)) over (partition by &gash_inst_id 1))*86400 total_seconds
from
gv$active_session_history gash
where
1=1
) gash
order by
&gash_inst_id
seconds desc
Parameter NameSQL textValidation
From Time
gash.sample_time>=:from_time
DateTime
To Time
gash.sample_time<:to_time+1/86400
DateTime
By Instance
gash.inst_id,
LOV
By Event
gash.event,
LOV
Session Type
gash.session_type=upper(:session_type)
LOV