Oracle Database 26ai will be available on generic Linux platforms in January and soon on AIX and Windows
Purpose
Wait events are events measured by the database where the user/application must wait for an activity to complete
Related Dynamic Performance Views
View Name
View Description
GV$SESSION_EVENT
One row for each session-specific wait event since session startup (gv$session logon_time)
GV$SESSION_WAIT
One row for each session listed in v$session (gv$session.sid)
V$EVENT_NAME
One row for each named Oracle kernel wait event
V$SYSTEM_EVENT
One row for each instance-wide wait event since instance startup (v$instance.startup_time)
Buffer Cache Busy Waits
Description
Buffer busy waits happens when a session tries to access a block in the buffer cache but it cannot because the buffer is busy, i.e. another session is modifying the block and the contents of the block are in flux.
To guarantee that the reader has a coherent image of the block with either all of the changes or none of the changes,
the session modifying the block marks the block header with a flag letting other users know a change is taking place and to wait until the complete change is applied.
The two main cases where this wait occurs are:
Another session is reading the block into the buffer - this specific case has been split out into a "read by other session" wait event in 10g and higher
Another session holds the buffer in an incompatible mode to our request
While the block is being changed, the block is marked as unreadable by others. The changes that are being made should last under a few hundredths of a second,
e.g. a disk read should be under 20 milliseconds and a block modification should be under one millisecond. Therefore it will take a lot of buffer busy waits to cause a problem, but some examples of this are:
Hot block issue, such as the first block on the free list of a table, with high concurrent inserts. All users will insert into that block at the same time, until it fills up, then users start inserting into the next free block on the list, and so on
Multiple users running an inefficient SQL statement performing a full table scan on the same large table at the same time. One user will read the block off disk,
and the other users will wait on buffer busy waits (or read by other session in 10g and higher) for the physical I/O to complete
Gather information
SELECT s.sql_hash_value, sw.p1 file#, sw.p2 block#, sw.p3 reason
FROM gv$session_wait sw, gv$session s
WHERE sw.event = 'buffer busy waits'
AND sw.sid = s.sid;
Identify the object of a wait event
SELECT owner, segment_name, segment_type
FROM dba_extents
WHERE file_id = &FileNo
AND &BlockNo BETWEEN block_id AND (block_id + blocks-1);
Top 10 buffer busy wait events
col owner format a10
col object_name format a25
col subobject_name format a15
col tsname format a10
col value format 99999
SELECT *
FROM (
SELECT owner, object_name, subobject_name, object_type, tablespace_name TSNAME, value
FROM gv$segment_statistics
WHERE statistic_name='buffer busy waits'
ORDER BY value DESC)
WHERE ROWNUM < 11
ORDER BY 1,2,3;
OWNER OBJECT_NAME
SUBOBJECT_NAME OBJECT_TYPE TSNAME
VALUE
------- ------------------------- --------------- --------------- -------
-----
AUDSYS SYS_LOB0000019840C00030$$ SYS_LOB_P898 LOB
PARTITION SYSAUX 4
AUDSYS SYS_LOB0000019840C00030$$ SYS_LOB_P1025 LOB
PARTITION SYSAUX 1
SYS ACTIVITY_TABLE$ SYS_
P908
TABLE PARTITION SYSAUX 2
SYS ATSK$_SCHEDULE_CONTROL
TABLE SYSAUX
3
SYS COL_USAGE$
TABLE SYSTEM
2
SYS I_ACTIVITY_TABLE$_OBJ
INDEX SYSAUX
2
SYS I_SCHEDULER_JOB4
INDEX SYSTEM
2
SYS MON_MODS_ALL$
TABLE SYSTEM
1
SYS SCHEDULER$_JOB
TABLE SYSTEM
11
SYS SEG$
TABLE SYSTEM
2
Issue Resolution Considerations
Increase extent size (are extents added too frequently?)
Reduce rows per block (is there hot block contention?)
Increase undo retention (by altering size or retention time)
Tune queries
TKPROF Output Parameters
Parameter Number
Description
P1
File number of the data file containing the block
P2
Block number within the datafile
P3
Reason code
Control File Waits
Description
The three different wait events of 'control file sequential read', 'control file single write', and 'control file parallel write' all contribute to the amount of time Oracle takes to keep the control file current.
Oracle maintains a record of the consistency of the database's physical structures and operational state through a set of control files. The Oracle control file is essential to the database operation and ability to recover from an outage.
In fact, if you lose the control file(s) associated with an instance you may not be able to recover completely. It is the Oracle control file(s) that records information about the consistency of a database's physical structures and operational statuses.
The database state changes through activities such as adding data files, altering the size or location of datafiles, redo being generated, archive logs being created, backups being taken, SCN numbers changing, or checkpoints being taken.
Through normal operation the control file is continuously hammered with reads and writes as it is being updated.
Why Control File Waits Occur
The performance around reads and writes against control files is often an indication of misplaced control files that share the same I/O access path or are on devices that are heavily used.
It is interesting to note that Oracle has always defaulted the creation of control files in a single directory. You can check where your control files reside on disk with this simple query.
View wait events
col event format a30
col wait_class format a20
SELECT inst_id, event, total_waits, total_timeouts, time_waited, average_wait, wait_class
FROM gv$system_event
WHERE event LIKE '%control%';
View sessions impacted by control file wait events
SELECT event, wait_time, p1, p2, p3
FROM v$session_wait WHERE event LIKE '%control%';
Number of blocks that the session is trying to read (should be 1)
TKPROF Output Parameters (db file single write)
Parameter Number
Description
P1
Number of control files being written to
P2
Number of blocks written
P3
Number of I/O requests
Idle Events
The table to the right is not complete but is a listing of the events most commonly seen idle events
SELECT UNIQUE event
FROM gv$session_wait
WHERE wait_class = 'Idle'
ORDER BY LOWER(event);
EVENT
---------------------------------------------------------
AQPC idle
ASM background timer
ASM cluster membership changes
class slave wait
Data Guard: Gap Manager
Data Guard: Timer
DIAG idle wait
heartbeat redo informer
LGWR worker group idle
lreg timer
OFS idle
pman timer
pmon timer
rdbms ipc message
smon timer
Space Manager: slave idle wait
SQL*Net message from client
Streams AQ: qmn coordinator idle wait
Streams AQ: qmn slave idle wait
Streams AQ: waiting for time management or cleanup tasks
VKRM Idle
VKTM Logical Idle Wait
wait for unread message on broadcast channel
watchdog main loop
Log Buffer Space
Wait for space in the SGA redo buffer
Parameter Number
Description
P1
Not used
P2
Not used
P3
Not used
Log File Switch
Database switches redo logs. The previously current log file becomes active and is archived (or) waiting for checkpoint to complete because all redo logs are full (or) waiting for the switch to complete
Parameter Number
Description
P1
Not used
P2
Not used
P3
Not used
Log File Sync
Wait for redo flush upon commit or rollback
Parameter Number
Description
P1
buffer# in log buffer that needs to be flushed
P2
Not used
P3
Not used
Session Wait Events
DFS Lock Handle
SELECT CHR(TO_CHAR(BITAND(p1,-16777216))/16777215) ||
CHR(TO_CHAR(BITAND(p1, 16711680))/65535) "Lock",
TO_CHAR(BITAND(p1, 65535)) "Mode"
FROM v$session_wait
WHERE event = 'DFS lock handle'
Unspecified Wait Events
This query is one way to identify so-called unspecified wait events by object
SELECT current_obj#, SUM(time_waited)/1000000, COUNT(*)
FROM gv$active_session_history
WHERE event = 'unspecified wait event'
GROUP BY current_obj#
ORDER BY 3 DESC;
Wait Event Tracing
Active tracing in the current session
ALTER SESSION SET EVENTS '10046 trace name context forever, level 12';