2007 Update: Since the days of Oracle7 when Oracle Corporation recommended keeping the
buffer cache hit ratio above a fixed threshold, research has show some important
facts.
Please read: Is the
Oracle buffer hit ratio a useless metric for monitoring and tuning?
Keeping your Oracle database tuned for peak
performance requires an understanding of a number of issues. In my previous
article, I explained how to tune the server and network. Once you've addressed
those tasks, the next place to look is within the Oracle instance itself. An
Oracle instance consists of the memory region of the database, called the System
Global Area or SGA, and the Oracle background processes. Once the instance has
been tuned, we look at tuning individual objects (tables and indexes) within the
database, and finally we tune the SQL statements that are run against the
database.
If you haven't read the first two articles in this
series, you can still catch up. The first installment, "Oracle
tuning: Start by looking at the big picture," provides an
overview of Oracle tuning. The second, "Oracle
tuning: Monitoring hardware with UNIX tools," looks at tuning
the database server.
Oracle initialization parameters
This instance-tuning phase of Oracle tuning examines the overall database and
the instance-wide parameters that affect performance.
With many hundreds of Oracle initialization parameters, it's important for the
database administrator (DBA) to focus on those parameters that have the most
impact on the performance of the Oracle database. Oracle has a huge number of
parameters in the Oracle initialization files (init.ora) that control the
overall configuration of the Oracle instance. While there are dozens of init.ora
parameters that affect performance, these are some of the most important:
- shared_pool_sizeThe memory region allocated for the library
cache and internal control structures
- db_block_sizeThe size of each data block
- db_block_buffersThe number of data buffers to allocate for the
instance
- sort_area_sizeThe amount of RAM reserved for each user to
perform sorting operations
- optimizer_modeThe default mode in which all SQL statements will
be optimized for an execution plan
- db_file_multiblock_read_countThe parameter that controls the
number of blocks that are read asynchronously in full-table scan operations
We have to remember that all Oracle instances are
generally constrained by I/O operations. I/O is the single most
dramatic component of Oracle performance, and any initialization
parameters that can be used in order to reduce I/O will improve the
performance of the database. For example, the db_block_size and
db_block_buffers (later renamed db_cache_size, db_nnk_cache_size,
&c) initialization parameters are very important in terms
of reducing I/O. As a general rule, the larger the Oracle block size,
the more the database can read in a single disk I/O and the less I/O
contention the system will have.
The values for these parameters affect several performance metrics. These are
the first things the Oracle DBA examines when performing instance tuning:
- Shared pool delaysDelays in the shared pool are most commonly
caused by large amounts of nonreusable SQL in the library cache. When a new
SQL statement is parsed, Oracle will check in the library cache to see if
the SQL statement has already been processed by an earlier task. This
checking can slow down SQL possessing, especially for a database whose SQL
is not reusable.
- Buffer busy waitsBuffer busy waits occur when a data block is in
the buffer but can't be accessed because another task has a lock on the data
block. This is most frequently caused by concurrent insert or update
activity against a table that does not have multiple freelists defined.
- Buffer hit ratioThis metric is a measure of the effectiveness of
the Oracle data block buffer. The higher the buffer hit ratio, the more
frequently Oracle found a data block in memory and avoided an I/O.
When tuning an Oracle instance, most DBAs begin by taking overall views of the
performance of the database. In Oracle8 through Oracle9i, most DBAs use
the Oracle STATSPACK utility to collect, store, and report on performance
information.
For details about capturing and plotting database STATSPACK information, see my
article "Oracle
Database Trend Analysis Using STATSPACK" in Oracle magazine.
Now that we have a high-level understanding of the main areas of instance
tuning, let's examine the tuning of the Oracle data buffers.
Data buffer tuning
The tuning of the Oracle data buffers is an important aspect of Oracle tuning
because the data buffer has a direct impact on disk I/O. Oracle provides an
in-memory cache for data blocks that have been retrieved by earlier SQL
requests. When a request is made to Oracle to retrieve data, Oracle will first
check the internal memory structures to see if the data is already in the
buffer. If the block is in memory, Oracle reads the data from the RAM buffer and
avoids doing unnecessary disk I/O.
It would be ideal if you could create one buffer for each database page,
ensuring that Oracle would read each block only once. With Oracle8i and
the very large memory (VLM) features, it's now possible to specify a data buffer
that's large enough to hold an entire multigigabyte database, but most large
databases do not have enough RAM to allow for the full caching of data pages.