Part II: Waits Events and The Geeks Who Love Them: Kyle Hailey
Part II: Waits Events and The Geeks Who Love Them: Kyle Hailey
and the
Geeks who love them
Kyle Hailey
http://perfvision.com
#.2
WaitEvents
Wait Events
In this Presentation:
Introduction to Waits
Tuning Methodology
Plan of Action
Statspacks, AWR or OEM for Collection Data
Based on Waits
Database is Hung!
Everybody blames the database
Yet 9 out of 10 dba’s agree it’s not the
database
How do you prove it to management?
*$%@!!
Oracle’s Defense
After years of false accusations
Oracle took action and created a defense
system:
WAIT EVENTS
To the rescue
Oracle is the best instrumented database on
the market which can save time and money
on development and tuning
Network
IO
Tuning Methodology
1. Machine
Run queue (CPU)
Check other applications
reduce CPU usage or add CPUs
Paging
Reduce memory usage or add memory
2. Oracle
Waits + CPU > Available CPU
Tune waits We are going to
CPU 100% concentrate here
Tune SQL on WAITS
Else low waits, available CPU then
It’s the application
Copyright 2006 Kyle Hailey
#.11
Locks
Waits Library Cache
Redo
SQL*Net
v$active_session_history
Session (user, service, client, package, procedure, etc)
SQL statement
For IO related waits
CURRENT_OBJ# ,CURRENT_FILE# ,CURRENT_BLOCK#
Blocking_Session
P1
P2
P3
Difficult Waits
These 4 waits have multiple causes
Latches
p2 = latch # (p1= address, p3= tries)
Locks
p1 = lock type and mode ( p2 = id1, p3= id2)
Buffer Busy
p3 = block class#, p1= file, p2=block
(in 9i p3 was the bbw type)
Wait Analysis
Find SQL waiting
Most often the tuning answer lies in looking at what
the application is doing, and changing it
Find extended wait information
Parameter1, Parameter2, Parameter3
Background
Idle
Resource Manager
User2
User3
Background Waits
ASH
Avoid Background waits in ASH with
Select
Select …from
…from v$active_session_history
v$active_session_history
where
where SESSION_TYPE='FOREGROUND'
SESSION_TYPE='FOREGROUND'
V$session_wait joined to v$session
select
select ……
from
from v$session
v$session s,
s,
v$session_wait
v$session_wait w
w
where
where w.sid=s.sid
w.sid=s.sid
and
and s.type='USER'
s.type='USER'
Copyright 2006 Kyle Hailey
Idle Waits #.26
Select
Select name
name from
from v$event_name
v$event_name where
where
wait_class=‘Idle’;
wait_class=‘Idle’;
9i
Create a list with
Documentation
List created from 10g
Stats$idle_events from statspack
10g
select
select name
name from
from v$event_name
v$event_name where
where
wait_class='Scheduler';
wait_class='Scheduler';
RAC Waits
RAC waits are certainly interesting but will be covered
outside of this presentation.
Latches
Protect areas of memory from concurrent use
Light weight locks
Bitin memory
Atomic processor call
Fast and cheap
Gone if memory is lost
Finding Latches
“latch free”
Covers many latches, find the problem latch by
1. select name from v$latchname where latch# = p1;
OR
2. Find highest sleeps in Statspack latch section
In 10g, important latches have a wait event
latch: cache buffers chains
latch: shared pool
latch: library cache
Locks 10g
10g breaks all Enqueues out
enq: HW - contention Configuration
enq: TM - contention Application
enq: TX - allocate ITL entry Configuration
enq: TX - index contention Concurrency
enq: TX - row lock contention Application
enq: UL - contention Application
^LDictionary
^LDictionary Cache
Cache Stats
Stats for
for DB:
DB: ORA9
ORA9 Instance:
Instance: ora9
ora9 Snaps:
Snaps: 11 -2
-2
->"Pct Misses" should be very low (< 2% in most
->"Pct Misses" should be very low (< 2% in most cases) cases)
->"Cache
->"Cache Usage"
Usage" is
is the
the number
number of
of cache
cache entries
entries being
being used
used
->"Pct
->"Pct SGA"
SGA" is
is the
the ratio
ratio of
of usage
usage to
to allocated
allocated size
size for
for that
that cache
cache
Get
Get Pct
Pct Scan
Scan Pct
Pct Mod
Mod Final
Final
Cache
Cache Requests
Requests Miss
Miss Reqs Miss
Reqs Miss Reqs
Reqs Usage
Usage
----------------- --------- ------ ------- ----- -------- ----------
----------------- --------- ------ ------- ----- -------- ----------
dc_object_ids
dc_object_ids 45
45 0.0
0.0 00 00 958
958
dc_objects
dc_objects 89
89 0.0
0.0 00 00 1,129
1,129
dc_segments
dc_segments 69
69 0.0
0.0 00 00 807
807
dc_tablespaces
dc_tablespaces 12
12 0.0
0.0 00 00 13
13
dc_usernames
dc_usernames 22
22 0.0
0.0 00 00 19
19
dc_sequences
dc_sequences 120,003
120,003 0.0
0.0 00 120,003
120,003 55
Additional Support
AWR Tables – on disk for 7 days by default
DBA_HIST_ACTIVE_SESS_HISTORY
1 in 10 ASH samples
DBA_HIST_SEG_STAT
Good for ITL and buffer busy wait
DBA_HIST_SYSTEM_EVENT
Important for getting avg wait times
DBA_HIST_SQLSTAT
sql execution deltas
DBA_HIST_SYSMETRIC_SUMMARY
Statistics avg, max, min
Metric Tables – in memory deltas
V$EVENTMETRIC
Select ash.p1,
ash.p2,
CURRENT_OBJ#||' '||o.object_name objn,
o.object_type otype,
CURRENT_FILE# filen,
CURRENT_BLOCK# blockn,
ash.SQL_ID,
w.class ||' '||to_char(ash.p3) block_type
from v$active_session_history ash,
( select rownum class#, class from v$waitstat ) w,
all_objects o
where event='buffer busy waits'
and w.class#(+)=ash.p3
and o.object_id (+)= ash.CURRENT_OBJ#
and ash.session_state='WAITING'
and ash.sample_time > sysdate - &1/(60*24)
Order by sample_time
P1 P2 OBJN OTYPE FILEN BLOCKN SQL_ID BLOCK_TYPE
Object Translation
Object ID
File # and Block #
#.42