You are on page 1of 2

Oracle Active Session History (ASH)

Version 11.1
Note: Active session history is snapped once each second in gv_$active_session_history, held for
approximately 30 minutes and then stored in dba_hist_active_sess_history. It is designed for an hour of
online storage, based on 2MB per CPU, but may fill and flush sooner. when written to disk it is further
sampled (1 out of 10)

Dependent
Objects

dba_hist_active_sess_history wrh$_active_session_history
gv_$active_session_history
wrm$_snapshot

ASH
Buffers

SELECT*
FROMgv$sgastat
WHEREname='ASHbuffers';
descgv$active_session_history

SELECTsql_id,COUNT(*),ROUND(COUNT(*)/SUM(COUNT(*))
OVER(),2)PCTLOAD
FROMgv$active_session_history
WHEREsample_time>SYSDATE1/24
ANDsession_type='BACKGROUND'
Most Active GROUPBYsql_id
SQL in the
ORDERBYCOUNT(*)DESC;
previous
hour

Most Active
I/O

SELECTsql_id,COUNT(*),ROUND(COUNT(*)/SUM(COUNT(*))
OVER(),2)PCTLOAD
FROMgv$active_session_history
WHEREsample_time>SYSDATE1/24
ANDsession_type='FOREGROUND'
GROUPBYsql_id
ORDERBYCOUNT(*)DESC;
SELECTDISTINCTwait_class
FROMgv$event_name
ORDERBY1;
SELECTsql_id,COUNT(*)
FROMgv$active_session_historyash,gv$event_nameevt
WHEREash.sample_time>SYSDATE1/24
ANDash.session_state='WAITING'
ANDash.event_id=evt.event_id
ANDevt.wait_class='UserI/O'
GROUPBYsql_id
ORDERBYCOUNT(*)DESC;
setlinesize121
SELECT*FROM

TABLE(dbms_xplan.display_cursor('gpv3kb4n2f2q1'));
ASH Demo
connuwclass/uwclass
Demo
preparation
as the
active user

SELECTt.tablespace_name
FROMall_tablest,all_indexesi
WHEREt.tablespace_name=i.tablespace_name;
Note:donotclosesessionduringthebalanceof
thisdemo
conn/assysdba

Demo
preparation
as the DBA

SELECTsid,serial#
FROMgv$session
WHEREusername='UWCLASS';

To find out
the wait
events for
which this
session

SELECTsample_time,event,wait_time
FROMgv$active_session_history
WHEREsession_id=147
ANDsession_serial#=1715;

To find
recent
sample
times

SELECTsample_time
fromgv$active_session_history
WHEREsession_id=147
ANDsample_time>SYSDATE10/1440
ORDERBY1;

Find SQL
statement
identified
above

SELECTsql_text,application_wait_time
FROMgv$sql
WHEREsql_idIN(
SELECTsql_id
FROMgv$active_session_history
WHERETO_CHAR(sample_time)='04DEC0708.36.09.094
AM'
ANDsession_id=147
ANDsession_serial#=1715);

You might also like