Tuning the Buffer Cache
Oracle Tips by Burleson
The buffer cache is the area in memory where
data is stored from data tables, indexes, rollback segments, clusters,
and sequences. By ensuring that enough buffers are available for
storage of these data items, you can speed execution by reducing
required disk reads. In Oracle7 and early Oracle8 releases, you only
had the “normal” buffer area to worry about. To Oracle8i was added the
capability to subdivide this buffer area into KEEP and RECYCLE buffer
areas. Later in this section, we will examine how these areas interact
and how they should be tuned and sized. To add to the complexity you
can, in Oracle, also have multiple areas inside the buffers that do
not have the same blocksize as the rest of the database. We will cover
that in the Oracle tuning section.
If DB_BLOCK_BUFFERS is set too high, you may
exceed shared memory size on UNIX or NT for your instance. Another
possible result is that the entire Oracle process could be swapped out
due to memory contention with other processes. In either case, it is
not a desirable condition. To avoid exceeding shared memory area
size, be sure you set these operating system values (on UNIX) high
when the instance is created. To avoid swapping, know how much memory
you are able to access; talk with your system administrator to find
Tuning the Multipart Oracle8, Oracle8i, and
Oracle Buffer Cache
In Oracle8 and Oracle8i, the database block
buffer has been split into three possible areas: the default, keep,
and recycle buffer pool areas. It is not required that these three
pools be used, only one: the default pool, which must be configured
with the DB_BLOCK_BUFFERS or DB_CACHE_SIZE (in Oracle, this should
be used instead of DB_BLOCK_BUFFERS) initialization parameters; the
others are “sub” pool to this main pool.
How the various pools are used is covered in
the following subsections.
Use of the Default Pool
If a table, index, or cluster is created
specifying that the KEEP or RECYCLE pool be used for its data, then it
is placed in the default pool when it is accessed. This is standard
Oracle7 behavior; and if no special action is taken to use the other
pools, then this is also standard Oracle8, Oracle8i, and Oracle
behavior. The initialization parameters DB_BLOCK_BUFFERS and
DB_BLOCK_LRU_LATCHES must be set if multiple pools are to be used:
DB_BLOCK_BUFFERS = 2000
DB_BLOCK_LRU_LATCHES = 9
NOTE: In Oracle DB_BLOCK_BUFFERS should not be used, Instead
set DB_CACHE_SIZE. Also, DB_BLOCK_LRU_LATCHES will be determined
Use of the KEEP Pool
The KEEP database buffer pool is configured
using the BUFFER_POOL_KEEP initialization parameter, which looks like
BUFFER_POOL_KEEP = ‘100,2’
In Oracle, this becomes DB_KEEP_CACHE_SIZE
and is specified in megabytes.
The two specified parameters are,
respectively, the number of buffers from the default pool to assign to
the KEEP pool and the number of LRU (least recently used) latches to
assign to the KEEP pool. The minimum number of buffers assigned to the
pool is 50 times the number of assigned latches. The KEEP pool, as its
name implies, is used to store object data that shouldn’t be aged out
of the buffer pool, such as lookup information and specific
performance-enhancing indexes. The objects are assigned to the KEEP
pool either through their creation statement or by specifically
assigning them to the pool using the ALTER command. Blocks already in
the default pool are not affected by the ALTER command, only
subsequently accessed blocks are.
The KEEP pool should be sized such that it can
hold all the blocks from all of the tables created with the buffer
pool set to KEEP.
Use of the RECYCLE Pool
The RECYCLE database buffer pool is configured
using the BUFFER_POOL_RECYCLE initialization parameter, which looks
BUFFER_POOL_RECYCLE = ‘1000,5’
In Oracle, this becomes
DB_RECYCLE_CACHE_SIZE and is specified in megabytes.
The two specified parameters are,
respectively, the number of buffers from the default pool to assign
to the RECYCLE pool and the number of LRU (least recently used)
latches to assign to the KEEP pool. The minimum number of buffers
assigned to the pool is 50 times the number of assigned latches. The
RECYCLE pool, as its name implies, is used to store object data that
should be aged out of the buffer pool rapidly, such as searchable LOB
information. The objects are assigned to the RECYCLE pool either
through their creation statement or by specifically assigning them to
the pool using the ALTER command. Blocks already in the default pool
are not affected by the ALTER command, only subsequently accessed
As long as the RECYCLE pool shows low block
contention, it is sized correctly. With the above setpoints for the
default, KEEP and RECYCLE pools, the default pool would end up with
900 buffers and 3 LRU latches.
Tuning the Three Pools
In Oracle8i, the classic method of tuning the
shared pool is not available, so we must examine alternative methods
to achieve the same ends. This involves looking at what Oracle has
provided for tuning the pools. A script, catperf.sql, offers several
views for tuning the Oracle buffer pools. These views are:
V$BUFFER_POOL. Provides static
information on pool configuration.
summary information on DBWR write activities.
V$DBWR_WRITE_LOG. Provides write
information for each buffer area.
Of these four views, V$BUFFER_POOL_STATISTICS
seems the most useful for tuning the buffer pool. It contains
statistics such as buffer_busy_waits, free_buffer_inspected,
dirty_buffers_inspected, and physical write-related data.
If a buffer pool shows excessive numbers of
dirty_buffers_inspected, and high amounts of buffer_busy_waits, then
it probably needs to be increased in size.
In Oracle, the V$DB_CACHE_ADVISE view is
available for tuning the buffer areas, which is described in the next
When configuring LRU latches and DBWR
processes, remember that the latches are assigned to the pools
sequentially and to the DBRW processes in round-robin fashion. The
number of LRU processes should be equal to or a multiple of the value
of DBWR processes to ensure that the DBRW load is balanced across the
Code Depot for Full Scripts
||This is an excerpt
from Mike Ault, bestselling author of "Oracle
10g Grid and Real Application Clusters".
You can buy it direct from the publisher for 30%-off and get
instant access to the code depot of Oracle tuning scripts.