Active Session History 129612
Active Session History 129612
Graham Wood
[email protected]
Oracle Corporation
Agenda
Introduction What is ASH Querying ASH data Comparison of ASH and Statspack/AWR Comparison of ASH and SQL trace/tkprof EM use of ASH data Conclusions
Oracle Statistics
Instance level statistics ( AWR, Statspack)
Too little detail Stop short of complete diagnosis Can be collected automatically Too much detail Intrusive. Hard to see big-picture Must be enabled manually Need prior knowledge that problem exists
Oracle Statistics
Solution: Active Session History
Sample session activity in the system including: Session id Wait event SQL id Object Always on for first fault analysis Just right!
Like doing select * from v$session_wait w/o SQL 2MB per CPU, 5% shared_pool, 2% sga_target Waiting on non-idle event or on CPU 10,000 sessions => 200 active sessions Design goal: one hour activity held in memory
DB Time
DB Time
Time
7:38:26 7:42:35 7:50:59 7:52:33
SID
213 213 213 213
Module
Book by author Get review id Add to cart One click
SQL ID
qa324jffritcf aferv5desfzs5 hk32pekfcbdfr abngldf95f4de
State
WAITING CPU WAITING WAITING
Event
db file sequential read
ASH: On disk
Captured as part of AWR snapshots
DBA_HIST_ACTIVE_SESS_HISTORY 10 second samples Whenever circular buffer is 66% full No missed data Table is partitioned for easy purging
AWR
WRH$_ACTIVE_SESSION_HISTORY
Module, Action, Client_id (~50%) Variable length rows Write 1 out of every 10 samples Direct-path INSERTS
Disk Usage
Log generation
AWR
No Consistent-Read requirement 1 Writer Multiple Readers Readers go unlatched Both V$ view and DBA_HIST view
Indexed on time
AWR
What events were taking most time? What was a session doing? What does a SQL statement wait for?
ASH: Dimensions
Session Waits
Event, P1, P2, P3 Sql_id, Opcode,Plan_hash Object#, File#, Block# Program, Module, Action, Client_id, Service
SQL
Objects
Application
10 ==> minutes of history you want to dump Generated file can be loaded into database using supplied control file rdbms/demo/ashldr.ctl
V$ACTIVE_SESSION_HISTORY
Gives most recent data first Control C or set pause on is your friend Simpleash.sql
Wait
Can analyze any time slice More samples More accurate results
Returns SQL spending most time doing I/Os Similarly, can do Top Sessions, Top Files, Top Objects
DBA_HIST_ACTIVE_SESS_HISTORY
Similar to in-memory ASH but adds
Total time spent waiting on IO? Totals sampled IO times Assumes that 5 hours history in memory
TIME_WAITED Actual time waited for that event Updated later upon event completion
ASH: TIME_WAITED
Remember actual time waited User Session (SID = 3) After Sample 1 Sample 1 Sample 2 Time
Sample
1
Session
State
Event
Wait_time Time_waited
0 0
Sample
1
Session
State
Event
Wait_time Time_waited
0 5ms
ASH vs AWR/Statpack
Instance wide data Time based data Counts/occurrence data Analyze any time period Detailed session level data Individual Wait event data Sampled data Time based analysis ASH Yes Yes No Yes Yes Yes Yes Yes AWR Yes Yes Yes No No No No Yes
ASH vs AWR
Top 5 Timed Events ~~~~~~~~~~~~~~~~~~ % Total Event Waits Time (s) DB Time Wait Class ------------------------------ ------------ ----------- --------- -------------log file sync 990,495 233,649 43.79 Commit latch: library cache 642,247 157,188 29.46 Concurrency latch: cache buffers chains 133,136 39,747 7.45 Concurrency latch: library cache pin 84,638 22,998 4.31 Concurrency latch free 61,709 20,079 3.76 Other Top Foreground Events ~~~~~~~~~~~~~~~~~~~~~ log file sync latch: library cache latch: cache buffers chains latch free latch: library cache pin
D E M O N S T R A T I O N
ASH Report
ASH vs SQLtrace/tkprof
ASH Parse/Exec/Fetch breakdown Time based data Counts/occurrence data Detailed session level data Individual Wait event data Complete trace of operations Always on Bind variables available No Yes No Yes Yes No Yes No SQLtrace Yes Yes Yes Yes Yes Yes No Yes
D E M O N S T R A T I O N
D E M O N S T R A T I O N
EM Diagnostic Pack
jmillistake3.png
Conclusion
ASH data always available Allows instance wide performance analysis Allows detailed session level performance analysis But it is sampled data, so use statistical analysis techniques
QUESTIONS ANSWERS