You are on page 1of 18

Objectives & Scope

• What is Oracle Wait Interface


• What are wait events
• Wait Events to focus on
• Quick look at top 10 wait events
• Practical scenarios and some useful scripts
What is a wait event ?

Tasks such as reading and writing data blocks to and from


data files, waiting for latch acquisitions before accessing
or manipulating data in the memory, are known as
database events, and they have specific names.
Every session that is connected to an Oracle instance
needs resources to perform its tasks. A resource may be
a data buffer, a latch, an enqueue (lock), a pin, or a
database object. Whenever a session has to wait for
something, the wait time is tracked and charged to the
event that is associated with that wait.
Where to look for wait event information?
Determine the best source data…

V$SYSTEM_EVENT V$SESSION_EVENT
Content: system-level data Content: session-level granularity

V$SESSION_WAIT (X$KSUSECST)
Content: Fine-grain data
Common Wait Events
Events to ignore:
KXFX: Execution Message Dequeue – Slave
PX Deq: Execution Msg
Events to monitor: KXFQ: kxfqdeq - normal deqeue
PX Deq: Table Q Normal
db file sequential read
Wait for credit - send blocked
db file scattered read PX Deq Credit: send blkd
Wait for credit - need buffer to send
latch free
PX Deq Credit: need buffer
direct path read Wait for credit - free buffer
PX Deq Credit: free buffer
direct path write parallel query dequeue wait
Enqueue PX Deque wait
Parallel Query Idle Wait – Slaves
library cache pin PX Idle Wait slave wait
buffer busy waits dispatcher timer virtual circuit status
pipe get rdbms ipc message
free buffer waits rdbms ipc reply pmon timer
smon timer PL/SQL lock timer
WMON goes to sleep client message
SQL*Net message from client (* debatable)
Null event (* debatable)
Handling Wait Events
Db file sequential read & Db file scattered read

At what point do these wait events become a problem?

What are they a symptom of? Handling these wait events requires
a) Low cache hit ratio you to know:-
b) Slow I/O subsystem 1. The amount of time the events
are costing the process.
c) Physical I/O calls
2. The SQL statement that is
d) Small block size
associated with the events.
e) Small buffer cache

Solution: SQL tuning


Handling Wait Events
Latch Free
Latch Free contention is symptomatic of?
a) Low SPIN_COUNT.
b) Inefficient SQL statements.
c) Concurrency coupled with high demands for resources.
d) Insufficient number of latches.
e) Insufficient or slow CPU.

Handling the latch free contention requires you to know:-


1. The type of latch sessions are competing for (28 individual latch
wait events in Oracle10g Release 1).
2. The amount of time a session spent waiting on latches.
3. The SQL statement that is associated with the event.
Handling Wait Events
Latch Free: Shared Pool & Library Cache

Contention for the Shared Pool & Library Cache latches is symptomatic of?
a) Hard parses – literal SQL statements.
b) Soft parses.
c) Oversized shared pool.
d) Bad application.

Solution: If not symptom c), the real fix has to come from the application.

Workarounds:
• Set CURSOR_SHARING = FORCE
• Set SESSION_CACHED_CURSORS
Handling Wait Events
Latch Free: Cache Buffers Chains

Contention for the CBC latch is symptomatic of?


a) Inefficient SQL statement.
b) Hot blocks.
c) Long hash chains.
d) Insufficient number of latches.

Handling the CBC latch contention requires you to know:-


1. If the contention is widespread or localized to a particular latch.
2. The SQL statements that participate in the competition.
Handling Wait Events
Latch Free: Cache Buffers Chains

Solutions:
• Tune the application and SQL statements.
• Reduce the level of concurrency.

Workarounds:
• Spread the hot blocks across multiple CBC latches.
• Increase the _SPIN_COUNT (9i and above, use
_LATCH_CLASS and _LATCH_CLASSES).
• Increase _DB_BLOCK_HASH_BUCKETS.
• Increase _DB_BLOCK_HASH_LATCHES.
Handling Wait Events
Buffer Busy Waits
BBW contention is symptomatic of?
a) Read/read, read/write, or write/write contention.
b) Corrupted buffer pin.
c) Insufficient INITRANS.
d) Large block size.

Handling the BBW contention requires you to know:-


1. The amount of time a session spent waiting on the event.
2. The reason code that represents why a process fails to get a
buffer pin.
3. The class of block that the buffer busy waits event is for.
4. The SQL statements that are associated with the event.
5. The segment that the buffer belongs to.
Handling Wait Events
Buffer Busy Waits
Solutions depend on the class of block and reason code:
BBW contention for data block class (class #1), reason code 130
• Reduce the level of concurrency or change the way the work is
partitioned between the parallel threads.
• Optimize the SQL statement to reduce the number of physical
and logical reads.
• Increase the number of FREELISTS and FREELIST GROUPS.

BBW contention for data block class (class #1), reason code 220
• Reduce the level of concurrency or change the partitioning
method.
• Reduce the number of rows in the block.
• Rebuild the object in another tablespace with a smaller block
size (Oracle9i and above).
Handling Wait Events
Buffer Busy Waits
Solutions depend on the class of block and reason code:
BBW contention for data segment header (class #4)
• Increase the number of FREELISTS and FREELIST GROUPS of
the identified object.
• Ensure the gap between PCTFREE and PCTUSED is not too small.
• Ensure the next extent size is not too small.

BBW contention for undo segment header (class #17)


• **Applies to rollback segment, not the system-managed undo.
• Create additional rollback segments.
• Ensure the next extent size is not too small.

BBW contention for undo blocks (class #18)


• Application tuning.
Handling Wait Events
Free Buffer Waits

Free Buffer Waits wait is symptomatic of?


a) Small buffer cache.
b) Insufficient number of DBWR processes.
c) Inefficient SQL statement.
d) Slow I/O subsystem.
e) Delayed block cleanout.

Handling the Free Buffer Waits event requires you to know:-


1. The amount of time a session spent waiting on the event.
2. The SQL statements that are associated with the event.
3. The number of DBWR processes.
4. The I/O operation and database storage system.
Handling Wait Events
Free Buffer Waits

Solutions:
• Optimize the SQL statements.
• Increase the number of DBWR processes.
• Use appropriate I/O operation (async or sync).
• Lower the FAST_START_MTTR_TARGET value.
• Reduce the buffer cache size.
• Increase the buffer cache size.
• Pre-scan the table after each load.
Handling Wait Events
Log File Sync
Log File Sync wait is symptomatic of?
a) Oversized log buffer.
b) High commit frequency.
c) Bad application.
d) Slow LGWR process.
Handling the Log File Sync event requires you to know:-
1. The amount of time a session spent waiting on the event.
2. The type of job (batch or OLTP) that is associated with the event.

Solution:
• Reduce the commit frequency.

Workarounds:
• Reduce the log buffer size or lower the _LOG_IO_SIZE.
• Increase LGWR I/O throughput.
Handling Wait Events
Enqueue
Enqueue contention is symptomatic of?
a) Concurrent access to the DBMS_AQ package.
b) Concurrent transactions with incompatible lock requests for a
database resource.
c) Concurrent transactions with incompatible lock requests for a
latch.
d) Poor application design.

Handling the Enqueue contention requires you to know:-


1. The type and mode of enqueue the sessions are competing for (All
enqueues have independent wait event names in Oracle10g).
2. The amount of time a session spent waiting on enqueues.
3. The SQL statement that is associated with the event.
References

• Oracle Wait Interface: A Practical Guide to


Performance Diagnostics & Tuning
by Richmond Shee, Kirtikumar & K Gopalkrishnan

• Handling Common Oracle Wait Events


by Richmond Shee
Questions

You might also like