Professional Documents
Culture Documents
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
10g
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
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
CACHE# PARAMETER
---------- --------------------------------
1 dc_free_extents
4 dc_used_extents
2 dc_segments
0 dc_tablespaces
5 dc_tablespace_quotas
6 dc_files
7 dc_users
3 dc_rollback_segments
8 dc_objects
17 dc_global_oids
12 dc_constraints
Copyright 2006 Kyle Hailey
#.35
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
-- ------ --------------------- ----- ----- ------ ------------- -------
1 112796 66053 BBW_INDEX_VAL_I INDEX 1 112796 6avm49ys4k7t6 data block 1
1 112401 66053 BBW_INDEX_VAL_I INDEX 1 112401 5wqps1quuxqr4 data block 1
1 112796 66053 BBW_INDEX_VAL_I INDEX 1 112796 5wqps1quuxqr4 data block 1
1 113523 66053 BBW_INDEX_VAL_I INDEX 1 113523 5wqps1quuxqr4 data block 1
Copyright 2006 Kyle Hailey
#.39
Object Translation
Object ID
File # and Block #
#.42