Wait Events
buffer busy waits
This wait indicates that there are some buffers in the buffer cache that multiple processes are attempting to access concurrently. Query V$WAITSTAT for the wait statistics for each class of buffer. Common buffer classes that have buffer busy waits include data block, segment header, undo header, and undo block. Check the following V$SESSION_WAIT parameter columns: P1 - File ID P2 - Block ID P3 - Class ID Causes To determine the possible causes, first query V$SESSION to identify the value of ROW_WAIT_OBJ# when the session waits for buffer busy waits. For example: SELECT row_wait_obj# FROM V$SESSION WHERE EVENT = 'buffer busy waits'; To identify the object and object type contended for, query DBA_OBJECTS using the value for ROW_WAIT_OBJ# that is returned from V$SESSION. For example: SELECT owner, object_name, subobject_name, object_type FROM DBA_OBJECTS WHERE data_object_id = &row_wait_obj; |
Identifying sessions to Trace
It is expected that the session/s to be traced have already been identified
using information elsewhere in this set of articles. Below is a reminder of
some of the forms of statement which may be used when isolating a session
to be traced:
Finding user/s of a particular SQL statement given the "ADDRESS" and "HASH_VALUE" from V$SQLAREA: SELECT s.sid , s.serial#, s.status, s.server, s.username FROM v$session s WHERE s.sql_address='&ADDRESS' AND s.sql_hash_value='&HASH_VALUE' ; Finding the SID/SERIAL# of a user showing a particular type of wait: SELECT s.sid , s.serial#, s.status, s.server, s.username, e.event, e.time_waited FROM v$session_event e, v$session s WHERE e.sid=s.sid AND e.event like '&WAITEVENT_TO_CHECK' AND e.time_waited > '&WAIT_TIME_THRESHOLD' ; ( or use e.total_waits > '&NUM_WAITS_THRESHOLD') Eg: Replace &WAITEVENT_TO_CHECK with "buffer busy waits" to show sessions exhibiting lots of buffer busy waits. Finding the SID/SERIAL# of a user showing a particular count for a given statistic: SELECT s.sid , s.serial#, s.status, s.server, s.username, n.name, t.value FROM v$statname n, v$sesstat t, v$session s WHERE t.sid=s.sid AND t.statistic#=n.statistic# AND n.name like '&STATISTIC_TO_CHECK' AND t.value > '&VALUE_THRESHOLD' ; Eg: Replace &STATISTIC_TO_CHECK with "sorts (disk)" to show sessions exhibiting lots of disk sorts.
Tracing your own SessionTo start tracing your own session simply execute the PL/SQL call:DBMS_SUPPORT.START_TRACE; Tracing another SessionOnce a session has been isolated then you need to know the SID of the target session (and possibly the SERIAL#). To start tracing the target session simply call:DBMS_SUPPORT.START_TRACE_IN_SESSION( SID , NULL ); If it is important to capture an exact session you should specify both the SID and SERIAL# . Eg: DBMS_SUPPORT.START_TRACE_IN_SESSION( SID , SERIAL# ); This PL/SQL procedure will ask the target session to start writing trace output. The trace may NOT start immediately as there are certain points in the Oracle code where a session checks to see if it has been asked to do something (like writing trace output) - the target session only starts tracing once it has seen the request. Stopping TraceTo stop tracing in your own session call:DBMS_SUPPORT.STOP_TRACE; To stop tracing another session call: DBMS_SUPPORT.STOP_TRACE_IN_SESSION( SID , NULL ); Trace Output File FormatOutput files contain RAW trace output and can be found in the USER_DUMP_DEST directory for user sessions and BACKGROUND_DUMP_DEST for background processes. A summary of the RAW format can be found in Note:39817.1 . In this section we mention some of the important points about the trace file along with some tools which can be used to interpret the output for you.
Raw Trace FileThe raw trace file is described in Note:39817.1. Important points to note are:
ExampleThere are many ways to process a raw trace file but most require text processing filters such as GREP, AWK, NAWK, SED or PERL to extract the required information. As an example consider that several sessions have been showing waits for 'buffer busy waits'. By tracing a session the actual waits are written to the trace file. These could then be processed to list the file# and block# being waited for.Eg: In Unix one could process the waits using a command like: grep 'buffer busy waits' trace_file | \ awk ' { print substr($0,9); } ' | \ sort > sorted_buffer_wait_listThe actual waits may then be mapped back to an object using SQL like: SELECT segment_owner, segment_name FROM dba_extents WHERE file_id=&FILE_ID AND &BLOCK_ID between block_id and block_id+blocks-1 |
I/O-related Wait Events
I/O-related Wait Events that occur most often in Oracle databases together with reference notes describing each wait. db file sequential read: A sequential read operation reads data into contiguous memory (usually a single-block read with p3=1, but can be multiple blocks). Single block I/Os are usually the result of using indexes. This event is also used for rebuilding the controlfile and reading datafile headers (P2=1). In general, this event is indicative of disk contention on index reads. db file scattered read: Similar to db file sequential reads, except that the session is reading multiple data blocks and scatters them into different discontinuous buffers in the SGA. This statistic is NORMALLY indicating disk contention on full table scans. Rarely, data from full table scans could be fitted into a contiguous buffer area, these waits would then show up as sequential reads instead of scattered reads. The following query shows average wait time for sequential versus scattered reads: prompt "AVERAGE WAIT TIME FOR READ REQUESTS"select a.average_wait "SEQ READ", b.average_wait "SCAT READ" from sys.v_$system_event a, sys.v_$system_event b where a.event = 'db file sequential read' and b.event = 'db file scattered read'; use v$session_wait View to find information about Waiting: |