Sequential I/O Wait Analysis
Script: Sequential_io.sql
Section titled “Script: Sequential_io.sql”rem psysev.sqlremset lines 132remset pagesize 200;col SNAP_ID format 999999 heading 'SNAP ID'col instance_number format 99 head 'INST'col end_interval_time format a15 heading 'SNAP TIME'col EVENT_NAME format a35 heading 'EVENT'col total_waits format b999,999,990 heading 'TOTAL WAITS'col waits_per_sec format b99,990 heading 'WAITS|PER|SEC'col timeout_pct format b990.0 heading 'TIMEOUT|PCT'col time_waited_micro format b999,999,990 heading 'TIME WAITED(ms)'col avg_wait format 990.0 heading 'AVG|WAIT|TIME(ms)'remremremclear breakclear computeremselect /*+ ordered use_nl(e x b se sb) */ e.snap_id, to_char(e.end_interval_time, 'MM/DD HH24:MI') end_interval_time, e.instance_number, se.event_name, se.total_waits - sb.total_waits total_waits, ((se.total_waits - sb.total_waits) / ((to_date(to_char(e.end_interval_time,'MM/DD/YYYY HH24:MI:SS'),'MM/DD/YYYY HH24:MI:SS') - to_date(to_char(b.end_interval_time,'MM/DD/YYYY HH24:MI:SS'),'MM/DD/YYYY HH24:MI:SS')) *60*60*24)) waits_per_sec, -- (se.total_waits - sb.total_waits) -- / ((e.end_interval_time - b.end_interval_time) ) waits_per_sec, (se.total_timeouts - sb.total_timeouts) / decode( (se.total_waits - sb.total_waits), 0, 1, (se.total_waits - sb.total_waits) )*100 timeout_pct, (se.time_waited_micro - sb.time_waited_micro)/1000 time_waited_micro, (se.time_waited_micro - sb.time_waited_micro) / decode( (se.total_waits - sb.total_waits), 0, 1, (se.total_waits - sb.total_waits) )/1000 avg_wait, (casewhen(se.time_waited_micro - sb.time_waited_micro) / decode( (se.total_waits - sb.total_waits), 0, 1, (se.total_waits - sb.total_waits) )/1000< 11 then 'GREEN'when(se.time_waited_micro - sb.time_waited_micro) / decode( (se.total_waits - sb.total_waits), 0, 1, (se.total_waits - sb.total_waits) )/1000< 16 then 'YELLOW'else 'RED' END) STATUSfrom dba_hist_snapshot e, dba_hist_snapshot b, dba_hist_system_event se, dba_hist_system_event sbwhere b.snap_id = (select max(x.snap_id) from dba_hist_snapshot x where x.snap_id < e.snap_id and x.dbid = e.dbid and x.instance_number = e.instance_number) and b.dbid = e.dbid and b.instance_number = e.instance_number and se.snap_id = e.snap_id and se.dbid = e.dbid and se.instance_number = e.instance_number and sb.snap_id = b.snap_id and sb.dbid = b.dbid and sb.instance_number = b.instance_number and e.end_interval_time >= trunc(sysdate) and e.end_interval_time <= sysdate + 1 and sb.event_name = se.event_name and upper(se.event_name) like upper('db file scattered read')order by e.end_interval_time , e.instance_number , se.event_name/remundefine start_dtundefine end_dtundefine namundefine instno
Important Note
Section titled “Important Note”The provided script has an error: It monitors ‘db file scattered read’ instead of ‘db file sequential read’. To monitor sequential reads, change line 68 to:
and upper(se.event_name) like upper('db file sequential read')
Purpose
Section titled “Purpose”This script should monitor ‘db file sequential read’ wait events from AWR history, providing insight into single-block I/O operations typically associated with index lookups and table access by ROWID.
Key Features
Section titled “Key Features”- AWR-Based Analysis: Uses historical snapshots for trend analysis
- Performance Metrics: Calculates waits per second and average wait times
- Status Indicators: Color-coded status based on wait time thresholds
- Delta Calculations: Shows changes between consecutive snapshots
Metrics Displayed
Section titled “Metrics Displayed”- SNAP ID: AWR snapshot identifier
- SNAP TIME: Snapshot timestamp
- INST: Instance number (for RAC)
- TOTAL WAITS: Number of waits in the interval
- WAITS PER SEC: Wait frequency
- TIMEOUT PCT: Percentage of timed-out waits
- TIME WAITED(ms): Total wait time in milliseconds
- AVG WAIT TIME(ms): Average wait time per event
- STATUS: Performance indicator (GREEN/YELLOW/RED)
Status Thresholds
Section titled “Status Thresholds”- GREEN: Average wait time < 11ms (good performance)
- YELLOW: Average wait time 11-16ms (marginal performance)
- RED: Average wait time > 16ms (poor performance)
Note: Sequential read thresholds are lower than scattered reads because single-block reads should be faster.
Understanding Sequential Reads
Section titled “Understanding Sequential Reads”Sequential reads occur when Oracle reads a single block, typically during:
- Index unique scans
- Index range scans
- Table access by ROWID
- Undo segment reads
Performance Implications
Section titled “Performance Implications”High sequential read waits may indicate:
- Slow I/O subsystem
- Hot blocks causing contention
- Inefficient index access patterns
- Insufficient buffer cache
Optimization Strategies
Section titled “Optimization Strategies”- Improve I/O Performance: Faster storage, better RAID configuration
- Increase Buffer Cache: Keep frequently accessed blocks in memory
- Optimize Indexes: Ensure efficient index design
- Reduce Logical I/O: Tune SQL to minimize block accesses
- Consider SSD Storage: For frequently accessed data
Corrected Usage
Section titled “Corrected Usage”To properly monitor sequential reads:
-- Fix the event name in the scriptSQL> @Sequential_io.sql
Related Scripts
Section titled “Related Scripts”- Scattered_io.sql: Monitor multi-block reads
- random_io.sql: Analyze random I/O patterns
- gvio.sql: Real-time I/O statistics