Oracle & read ahead cache
Oracle Tips by Burleson Consulting
I just wanted
to check with the experts on "Read ahead cache" on Windows 2003 Sp2
SAN configuration. Currently my SAN doesn't employ "Read ahead
cache" turned on because the nature of the application is high
volume very random selects and huge amount of inserts.
Here are my top-5 events from an AWR report:
Top 5 Timed Events
Waits Time (s) (ms) Time
db file sequential read 445,254 2,735
enq: TX - row lock contention 95 279
db file parallel write 421,399
125 0 3.2
db file scattered read 133,905
90 1 2.3
Under what conditions
will a enabling the read ahead cache help me?
Answer: The read
ahead cache is only useful in cases of "db file scattered reads" (i.e. full
table scans). In your example, you only have 2.3% of I/O as scattered
reads, and a read-ahead may not help much.
The read ahead caching
has many names on different operating systems, and it started on IBM mainframes
as "sequential prefetch".
The concept of
readahead caching is simple. Over 90% of I/O latency is consumed in the
read-write head movement, as the heads are placed under the target cylinder.
Once in-place, the disk continues to spin and the read-write head can
simultaneously transmit back the original block request at the same time as the
next sequential block passes below the read-write heads.
For complete details on
device-level caching, see
my book "Oracle
Tuning: The Definitive Reference".
For scan operations
(index range scans, index fast full scans, and full-table scans), a read-ahead
cache can be very useful for speeding up these "scattered read" operations.
In sum, if your
database is requesting adjacent data blocks, the read-ahead cache may improve
I/O throughput. However, using RAID10 (SAME, stripe and mirror
everywhere), like with ASM, the blocks are not adjacent, and a read-ahead cache
may not be as useful as a database where the data blocks are laid-out
sequentially. Of course, the stripe width influences this decision.
For complete details,
see the book "Oracle
disk I/O tuning" where we see specific examples.
Placing adjacent blocks
together on disk (when you know that they will be accessed sequentially) is
analogous to the process of placing high-impact files near the middle absolute
track of huge Oracle disks, to minimize read-write head latency:
Placing hit impact files in the middle cylinder reduces read-write head
How to tell of
read-ahead caching is right for your Oracle database
As we noted, enabling
your read-ahead cache will greatly improve the I/O throughput for scan
operations. In a normal database you should look for "db file scattered
reads", and see if the latency is less than "db file sequential reads", which
happen on single block fetch operations:
Using Ion to find disk I/O
Ion tool is the
easiest way to analyze STATSPACK and AWR disk I/O data in Oracle.
Ion allows you to spot hidden I/O trends and times when full-scan operations
In sum, a transaction that does not require
adjacent data block will not benefit from a read-ahead cache, while transactions
that perform index range scans or full-table scans will benefit the most from a
Also, remember that most Oracle database process a wide range of transactions
and an OLTP database which does few "db file scattered reads" may perform lots
of full-scans during batch reporting windows.
Hence, you need to compare the costs of enabling your read-ahead cache with
the benefits in speeding-up "db file scattered reads". This can easily be
confirmed in a STATSPACK or AWR report.
If you like Oracle tuning, see the book "Oracle
Tuning: The Definitive Reference", with 950 pages of tuning tips and
You can buy it direct from the publisher for 30%-off and get
instant access to the code depot of Oracle tuning scripts.