ORACLE For UNIX - Performance Tuning Tips
ORACLE For UNIX - Performance Tuning Tips
Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
I. Preface
Purpose
The purpose of this guide is to help users improve the performance of Oracle
applications on UNIX systems. Oracle Corporation believes that following the
tuning tips in this guide will result in a reasonably well-tuned Oracle environ-
ment but does not intend this guide as the definitive authority on tuning Oracle on
UNIX.
If after reading this paper you wish to explore further, please see the Bibliogra-
phy for more specialized documents. This paper includes material from the refer-
ences as needed. Specialized help is also available from the Oracle Consulting
Group; for more information contact your regional Oracle Consulting manager.
This revision features many new tips. New material has been added to cover the
7.1 parallel query and Parallel Server options. The Bibliography has been
enhanced and annotated. Experience from Oracle’s internal tuning and bench-
marking groups as well as feedback from the UNIX Level 3 Performance Tuning
Course has been added.
Audience
This guide is written for new as well as experienced Oracle Database Adminis-
trators (DBA’s) and UNIX System Managers who are familiar with either Oracle
or UNIX, but not necessarily both. New and part-time DBAs can use this guide
to advance their tuning skills. Experienced, full-time UNIX System Managers
may find this guide useful for validating tuning procedures they already follow
and for discovering a few new ideas.
Using this Guide
This guide illustrates how to use features within Oracle products and UNIX to
tune your Oracle database. More detailed descriptions may be found in the
Oracle7 Server Administrator’s Guide, the platform-specific Oracle for UNIX
Installation & Configuration Guides, the Oracle7 Server Tuning Guide, Release
7.2 and other references described in the Bibliography. Included here you will
find basic instructions for using various performance monitoring tools and sam-
ple displays from them.
The guide clearly indicates whenever a procedure may optimize UNIX for
Oracle at the expense of other applications. Responsibility for balancing the per-
formance of Oracle and non-Oracle applications rests with the System Manager.
Before you begin the actual tuning, please read through this guide. If you are
focusing on a particular tip, prepare the reports that may be needed from your
system before tuning.
Feedback
The information in this guide has been taken from previously published technical
documentation and from the personal experiences of Oracle/UNIX performance
specialists. Oracle Corporation is very interested in your feedback, especially
suggestions for tuning UNIX that will improve this guide. We are also interested
in the problems, concerns, and ambitions of our customers.
Please complete and return the comment form in the back of this guide to provide
us your feedback on the effectiveness of this guide and information about your
system. If you have access to the Internet, you can send your comments electron-
ically to Tony Duarte at address aduarte@us.oracle.com.
not to scale, this suggests that tips associated with application design and data
access methods (Step 2 and Step 3) usually obtain the greatest performance gain.
The following steps list some of the major performance tuning tasks:
Step 1. Installing and Configuring Oracle
• Install and Configure Oracle using the Oracle Optimal Flexible Architecture
(OFA) Rules
Step 2. Application Design
Step 3. Tuning Data Access
• Tune SQL Statements: TKPROF and EXPLAIN PLAN
Step 4. Tuning Memory Management
• Tune Number of Database Buffers and Redo Buffers
• Tune Data Dictionary Cache
• Reduce Swap-out and Page-out activities
Step 5. Tuning Disk I/O
• Distribute I/O and Applications
• Tune Number of Database Writers
• Check for Large Disk Request Queues
• Check for Disk and Tablespace Fragmentation
CPU
Memory
Cache
System Bus
can cause performance degradation. To detect any memory contention, you can
monitor the memory activities of the Oracle Server using Sever Manager (see
Tips 19, 20 and 21). To monitor paging and swapping activities, you can use sar
on System V and vmstat on BSD UNIX (see Tips 12 and 13). To check swap
space, you can use pstat on BSD UNIX and swap on SYSTEM V (see Tip 14).
Disk I/O contention may be the result of poor memory management (with subse-
quent paging and swapping), or poor distribution of tablespaces and files across
disks. In a well tuned system, the I/O load is spread fairly evenly across all of the
disks, with none much more heavily loaded than the others. On System V, you
can use sar to get information about I/O activities such as request queues to disks
while iostat can provide you with similar information on BSD UNIX (see Tips
32 and 33). You can also monitor I/O activities through the sqldba Monitor Menu
function (see Tip 33) and utlbstat/utlestat (see Tip 36). Balancing Disk
I/O can be done by striping across several disks (see Tips 27-30) or moving files
to unloaded disk drives (see Tip 34). Network contention is not discussed in this
guide.
The CPU is also one of the components of the computer system for which pro-
cesses may contend. Although the UNIX kernel can allocate the CPU effectively
most of the time, many processes compete for CPU cycles. If your system has
more than one CPU (multiprocessor environment), there may be different levels
of contention on various CPUs. One way to measure CPU loads is to use sar on
System V and vmstat and iostat on BSD UNIX (see Tip 43).
Contention can also be caused for Oracle resources: Typically locks and latches.
To identify those bottlenecks most quickly, you can use the Oracle v$ tables as
described in Tip 53. You can also monitor the contention for Oracle latches
through utlbstat/utlestat (see Tip 60).
Over time, both the database size and number of users tends to grow. What was
once a lightly loaded system gradually (or not so gradually) slows down. Starting
use of parallel query can dramatically increase the load on every component of a
typical computer system. As a result, checking for bottlenecks must be done from
time to time to ensure that your system stays balanced.
drive to spread the I/O as widely as possible. One rule of thumb is to create one
rollback segment per four active transactions, but never create more segments
than your instance’s maximum number of concurrently active transactions and
never create more than 50. Chapters 7, 8 and 9 of the Oracle7 Server Administra-
tor’s Guide give additional information on configuring data objects.
When many users execute the same program, substantial reuse is almost certain
to occur, especially if the library cache is large enough (Tip 23). Application
development systems like Oracle Forms4 and Pro*C have “identical” SQL state-
ments from user to user. Good software engineering practices such as using com-
mon libraries and sharing code will maximize the reuse of SQL statements.
Our tuning specialists have found that application code developed and tuned for
versions 5 and 6 of the Oracle Server can frequently benefit significantly from
retuning for SQL statement reuse.
============================================================================
select nvl (cc.template_id, ''),
nvl (bal.currency_code, ''),
bal.set_of_books_id,
SEGMENT1, SEGMENT2, SEGMENT3, SEGMENT4,
nvl (begin_balance_cr,0), nvl(begin_balance_dr,0),
nvl (budget_version_id,''),
nvl (actual_flag,''),
nvl (period_name,''),
nvl (period_net_cr, 0), nvl(period_net_dr,0)
from GL_CODE_COMBINATIONS cc, GL_BALANCES bal
where bal.code_combination_id = cc.code _combination_id and
nvl (bal.translated_flag,'x') != 'R' and
bal.set_of_books_id in (1) and
(nvl (cc.SEGMENT1,'') between '2' and '2' ) and
(nvl (cc.SEGMENT2,'') between '60' and '60' ) and
(nvl (cc.SEGMENT3,'') between '3100' and 'ST31' ) and
(nvl (cc.SEGMENT4,'') between '0000' and 'S602' ) and
( (period_name='May-91' and actual_flag='A' )
or ( period_name='May-91' and budget_version_id=1003
and actual_flag='B')
or ( period_name='May-90' and actual_flag='A' ) )
User Memory
Memory
Shared Redo-Log
SGA Buffers
Pool
Kernel
Memory UNIX Buffer Cache
cache with shared SQL and PL/SQL areas, data dictionary cache, and session
information. The redo-log buffers hold redo-log information. Tuning is accom-
plished by properly setting the size of these three SGA components to use
enough, but not too much, memory. The size of the SGA is the sum of the size of
these components plus some overhead items, and is computed for you during
Oracle start-up.
The Oracle buffer manager ensures that more frequently accessed data is cached
longer (and is therefore available without the need for an I/O request). Monitor-
ing the buffer manager and tuning the buffer cache can have a significant influ-
ence on the performance of Oracle. Some of the following tips discuss ideas for
tuning data and shared pool buffers. The optimal Oracle buffer size for your sys-
tem will depend on the overall system load and on the relative priority of Oracle
over other applications; if you increase the size of an Oracle buffer to improve
Oracle performance, you may affect other applications by reducing the amount of
available memory.
As Figure 5 illustrates, the relative size of the UNIX and Oracle buffer caches is
also important since they both have to share the same limited system memory
resources. When the UNIX file system is used, UNIX will read data from disk
into the UNIX buffer cache (in system space) and then from the UNIX buffer
cache to the Oracle buffer cache (in user space). When raw devices are used, the
UNIX file system is bypassed. Consequently the UNIX buffer cache can be min-
imized (see Tip 40).
% vmstat -S 5 9
sar -p 10 10
Paging may not present as serious a problem as swapping since the entire pro-
gram doesn’t have to reside in memory to run. A small amount of page-outs may
not noticeably affect the performance of your system. However, the performance
may degrade rapidly as page-out activity increases. Thus, it is a good idea to try
to minimize page-outs as much as possible. It is also important to remember that
page-outs may not cause serious performance degradation if you have fast CPUs
and/or disks.
If you have a Sun, IBM AIX, or DG-UX system, significant paging activity is
normal. Sun aggressively frees up memory by pre-paging. IBM and DG can use
“free” memory for read-ahead file buffering. Detecting excessive paging on these
systems will require running measurements during periods of good response or
idle time to obtain a baseline for comparing against measurements during periods
of sluggish response
The tools we can use to monitor paging are sar -p on System V and vmstat -S on
BSD UNIX. Figure 7 shows a sample output from sar. The vflt/s column indi-
cates the number of address translation page faults; address translation faults
occur when a process references a valid page not in memory. If processes fre-
quently reference paged-out memory, your system is experiencing a memory
shortage. You need to learn from experience what typical address translation
fault rates are on your system, and try to keep them low enough to provide good
response time. Another important column in Figure 7 is rclm/s; the number of
valid pages that have been reclaimed and added to the free list by page-out activ-
ity. This value should be zero.
If you are constantly having excessive page-out activity, the only solutions may
be to get more memory, to off-load some of the work to another system, or to
configure your kernel to use less memory. Although there are some ways to con-
serve memory, they are beyond the scope of this guide. UNIX system perfor-
mance tuning books, such as those in the Bibliography, offer guidance on
memory management.
If you can’t add more memory or drop any applications to conserve memory, it is
important to consider the tradeoffs in changing the size of the SGA. Suppose you
would like to maintain the number of users you currently have. If you make the
SGA too large, less memory will be available for other Oracle or non-Oracle pro-
cesses and swapping and paging activities will increase. On the other hand, if you
make the SGA too small, more memory will be available for other Oracle or non-
Oracle processes but database I/O will increase.
If possible, you want the entire active portion of the database to be able to fit
inside the buffer cache. However, in practice, you are likely to have limited
memory and other activities on your system. Therefore you need to optimize the
SGA size.
Tip No. 16: Hold the SGA in a Single Shared Memory Segment
Another consideration for memory tuning involves shared memory. A single
shared memory segment should be big enough to hold the SGA. If there isn’t
enough shared memory available, you can’t start up the Oracle instance. You
may need to reconfigure the UNIX kernel to increase shared memory. The UNIX
kernel parameters for shared memory include SHMMAX, SHMMNI, and
SHMSEG. See the platform-specific Installation Guide for a recommended value
of each parameter. To check the components of the SGA and their corresponding
sizes, use the Server Manager Instance/Database selection or SQL*DBA:
>show sga
Total System Global Area 4408616 bytes
Fixed Size 52120 bytes
Variable Size 3938704 bytes
Tip No. 18: Make Oracle Block Size a Multiple of the O/S Block Size
The Oracle Server manages the database files in units usually called blocks
(sometimes called pages). Database blocks refer to blocks which correspond to
the Oracle block size; they may differ in size from the standard I/O block size of
the host operating system. Since a UNIX system always reads entire O/S blocks
from the disk, I/O bandwidth is used inefficiently if the database block size is
smaller than the UNIX file system buffer size.
Your database block size should be equal to, or a multiple of your operating sys-
tem block size. The database block size is set by the initdb<n>.ora parame-
ter DB_BLOCK_SIZE. The block size can only be changed by recreating the
database. The table below shows default Oracle block size, number of extents
possible with that block size, and platforms that use that block size as the default.
LogicalReads – PhysicalReads
HitRatio = --------------------------------------------------------------------------
LogicalReads
where
You can monitor through sqldba the statistic redo log space requests which
reflects the number of times a user process waits for space in the redo log buffer:
sqldba> monitor systemstatistic Redo
Figure 8 shows an equivalent example in Server Manager. The Total value of
redo log space requests should be near 0, or not increasing. A nonzero value (as
is the case in Figure 8) indicates that processes are waiting for space in the buffer.
In this case, consider increasing the size of the redo log buffer (in increments of
5%). The size of the redo log buffer is determined by the initdb<n>.ora
parameter LOG_BUFFER whose value is expressed in bytes.
Tip No. 24: Lock large PL/SQL blocks into the shared pool
Sometimes semi-frequently used shared objects should be locked into the shared
pool. Objects are loaded into a contiguous block of memory in the library cache.
If a large PL/SQL package is aged out of the shared pool and then reused, some-
times it is necessary to age out many more objects than their combined size might
suggest to generate enough contiguous space for the reloaded object. During the
time needed to free up the space and (re)load library cache, the library cache
latch is held exclusively, and all potential users of the library cache must wait. Of
course, all the SQL and PL/SQL that was aged out must be reparsed and reloaded
before it can be used. If the library cache latch is often seen as a bottleneck, then
this tip can often help. (Note: this tip is valid for 7.1 and 7.2 Oracle. Futures ver-
sions of Oracle may change this functionality.)
Use the dbms_shared_pool utility package to discover the size of objects in the
shared pool. (Documentation is in the comments of the pl/sql script dbmspool.sql
normally installed at $ORACLE_HOME/rdbms/admin.) The following proce-
dure installs the PL/SQL, enables the server output buffer, and runs the sizes()
procedure.
• Navigate to $ORACLE_HOME/rdbms/admin.
• Invoke sqlplus or sqldba and execute the following sequence of commands:
@dbmspool
@prvtpool
set serveroutput on size xxxxxx
begin
sys.dbms_shared_pool.sizes ( minsize number );
end;
/
A setting of 20000 should be big enough for xxxxxx, and 20 a starting number
for minsize. Once the large objects that are semi-frequently used are identified,
the procedure keeping varchar2, flag char DEFAULT ‘P’) can be run as many
times as needed to lock objects into the shared pool. (You may want to build a
splplus script to do this as part of start-up.) The procedure unkeep is used to
unlock objects.
VALUE NAME
---------- ----------------------------
12675 session cursor cache hits
12766 session cursor cache count
2 rows selected.
Tip No. 26: Place Redo Logs on their Own Disk Device
If your Oracle applications involve heavy INSERT and UPDATE activity, you
can maximize Oracle performance by locating your redo logs on disks that sup-
port no other disk activity. Also, if you have enabled the ARCHIVING option,
place each redo log on a separate disk to minimize disk contention between the
LGWR process (writing to the current redo log) and the ARCH process (reading
from the closed redo log).
Placing redo logs on raw (character special) files can enhance performance fur-
ther. Redo logs should be the among the first files to be put on raw devices for
the following reasons.
• Redo files are written and read sequentially, maximizing the benefits of raw
devices.
• Asynchronous read and write is likely to be available for raw devices.
• Redo files do not need to be backed-up if your site is using an off-line
backup strategy, minimizing raw device administrative costs, and
• The size of redo files is fixed, minimizing raw device administrative costs.
Depending on your initial configuration, your system resource limitations, and
your overall system load, the performance benefit that you might see is roughly 0
– 15%.
Tip No. 27: Balance Disk I/O across all disk drives
In general, ensuring that I/O is balanced across every disk drive is an essential
part of tuning your Oracle Server. For smaller databases and those not using the
parallel query option, ensuring that different datafiles and tablespaces are distrib-
uted across the available disks may be sufficient. Tips 32 - 35 show how to tune
by moving files around. Appendix 1, OFA, describes a mechanism and naming
conventions designed to facilitate balancing the I/O load.
The three tips below (28 - 30) describe how to balance the datafiles belonging to
a single tablespace across as many disks as necessary. While unneeded for
smaller systems, this tuning operation is essential for best results for very large
databases and effective use of the parallel query option. If available, use a logical
volume manager for first level striping. You can then stripe across multiple logi-
cal volumes if necessary.
Tip No. 28: Balance Disk I/O with a Logical Volume Manager
Many operating systems now include a Logical Volume Manager(LVM) as part
of their standard distribution. A LVM can be used to stripe data across multiple
disk drives in order to distribute I/O across multiple disk spindles. A typical
stripe size is 4 Mb, but trial and error is usually used to find the best size. In gen-
eral, smaller stripes are better for OLTP with random access, while bigger stripes
are better for sequentially accessed data often encountered in decision support
applications or when using the parallel query option. Redo logs should also use
large stripes or no stripes. The stripe size should be a few times larger than the
initdb<n>.ora parameter DB_FILE_MULTIBLOCK_READ_COUNT
times your DB_BLOCK_SIZE. Be sure to stripe data files containing indexes
and clusters as well. Performance gains vary widely depending on the size of the
tables and the efficiency of the LVM. When using the parallel query option to do
full table scans of large tables, LVM can produce performance gains of 50% to
over 500% compared to unstriped tables.
Some of the vendors who provide LVM’s include:
• Hewlett Packard -- HPUX provides drive stripes as small a 1MB, and is
reported to give “near RAID” performance.
• Data General - DGUX provides a LVM which allows system memory to be
dynamically configured as cache for the drives.
• IBM - AIX provides mirrored logical volumes, which improves read perfor-
mance.
• Pyramid Technology -- DYNIX/ptx allows blocks as small as 2k.
• Novell -- UNIXware provides a GUI based LVM.
Tip No. 29: Balance Disk I/O using the DATAFILE keyword.
Oracle also allows data files to be striped without a LVM. This is done with the
DATAFILE keyword of the CREATE TABLE command. Performance will usu-
ally be better with a LVM. A LVM encourages a smaller stripe size, which tends
to distribute I/O more randomly and more automatically. If a LVM is available,
use it rather than the DATAFILE keyword. However, careful use of the DATA-
FILE keyword can improve parallel queries by 50% to 500% over results from a
large, unstriped table.
Tip No. 31: Tune the Database Writer to increase write bandwidth
Updates and Inserts to a database must eventually be written to disk. For the
Oracle server, a single logical process called the Database Writer (DBWR)
writes all changed database blocks to disk. If this logical process is contained in a
single UNIX process using a normal synchronous disk write call, it can only do
one write at a time. If the system is doing many inserts or updates, this serializing
of database writes can become a bottleneck.
improves the system performance by minimizing the wasted idle time; DBWR
won’t be blocked on each I/O.
Use asynchronous I/O if it is available on your system. It can be enabled by set-
ting the parameter ASYNC_WRITE (or USE_ASYNC_IO on some platforms)
to true in initdb<n>.ora. Asynchronous I/O is available on many Oracle for
UNIX platforms but may require the use of raw disk devices or special kernel
configuration. Consult your Installation and Configuration Guide for more infor-
mation. If your database files are not on raw devices, multiple DBWRs may be a
better choice than converting to raw device use to gain the benefits of asynchro-
nous database writes.
• Sun Solaris -- Async I/O for both raw and filesystem files
• SCO -- Async I/O for raw files
• Pyramid -- Async I/O for raw files
• Sequent -- Async I/O for raw files
to multiple files on the same disk, you should reduce the queues by distributing
some of the hot files to other disks. (See the following tips.)
Although the report from iostat doesn’t include disk request queues, it shows
which disks are busy. This information is valuable when you need to balance I/O
workload in the following tips. In Figure 11, the field bps indicates the number of
kilobytes transferred per second and the field tps indicates the number of trans-
fers per second.
In order to correctly interpret the output of sar or iostat, you need to find out the
throughput of your disk drives as installed on your system. In theory, one way to
% sar -d 5 2
% iostat 5 10
do this is to look up in your system manuals the capacity of your disk subsystem.
As a practical matter, it is often more straightforward to run some simple tests on
an unloaded system and calculate the throughput. A typical command which will
allow simple timing is:
$ time dd if=/dev/rdisk1 of=/dev/rdisk2 bs=4096
This command will return the number of blocks transferred and the time to run
the command. It is important to remember that normal UNIX operation will slow
down the performance due to operations like context switching, interrupt servic-
ing, and other processes on the system. Still, this command can give realistic per-
formance numbers for an installed system, and can be expanded in a shell script
to parallelize the test for multiple drives and controllers.
with the statistics reflecting their I/O activity. To identify hot files, compare the
activity levels of your database files. For each database file, observe the statistics:
the flexibility you need. You can also separate data segments and their corre-
sponding index segments into separate tablespaces.
The steps for changing segment tablespaces are included in Appendix 3. The
steps for separating data and index segments are described in Appendix 4. If only
one segment is involved, consider table striping to place the segment data into
multiple files in a single tablespace (Tip 27).
After you have redistributed the hot files, check whether you reduced your
request queues. If not, you may have to examine the applications on your system
to see if the I/O is unavoidable. More information is available in the references
described in the Bibliography.
Depending on your initial configuration, your system resource limitations, and
your overall system load, the range of performance benefit that you might see is
from 0 to 50%.
The Oracle*APS tool dbmap can also be used to check database fragmentation. It
provides the information you get from the queries above in a well structured for-
mat. Figure 13 shows a portion of the dbmap output. It illustrates two types of
free space fragmentation:
• Bubbling (block 8244) where small bubbles of noncontiguous free space
form whenever an extent lying between active extents is dropped; and
• Honeycombing (blocks 9545, 9550, 9555, etc.) where free space is sectioned
into contiguous pieces whenever adjacent extents are dropped.
A high recursive calls value in utlbstat/utlestat reports may also sug-
gest table fragmentation, assuming the data dictionary cache has already been
properly tuned. Appendix 2 has instructions for using utlbstat/utlestat.
Oracle, disk, and/or memory parameters will not necessarily increase perfor-
mance.
In theory, maximum system throughput occurs when all the system CPUs operate
at 100% capacity; however, in practice, this isn’t achievable. Application loads
are very dynamic and load spikes make it impossible to maintain 100% utiliza-
tion in a production system.
% sar -u 5 10
Average 9 14 73 4
ers per processor in each Oracle instance. (The proper value is very applica-
tion and system dependent.)
• Tables: Use the CREATE (or ALTER) TABLE (or CLUSTER) PARALLEL
command to specify the DEGREE of parallelism for a single instance, and
INSTANCES to specify the number of instances available when the Parallel
Server option is used. The product of DEGREE times INSTANCES should be
equal or less than the number of disk drives the table is striped across
(Tip 27). DEGREE must be less than one half (or less than)
PARALLEL_MAX_SERVERS for a uni-processor or SMP system.
• Queries: Use the PARALLEL and NOPARALLEL hints to reduce the parallel-
ism that could be obtained for the tables in the query. This should be done as
part of a load balancing or for lower priority queries that use tables designed
for highly parallel, high priority queries.
While it is possible to specify a higher degree of parallelism in a query than is
specified for a table, this capability should be used with caution. If a new
query requests more Query Servers than the system can provide, that query
will be executed sequentially. As a result, a hint requesting a highly parallel
query may actually execute more slowly than one using the parallel degree
assigned to the table.
requires more memory, since the Oracle executable’s text is no longer shared
between the front-end and the background processes. However, its advantage is a
much faster process (for a system that is not memory-bound). Thus, if you need
to transfer large amounts of data between the user and Oracle (such as
export/import), it is very efficient to use single-task. To make the single-task
import (impst) and export (expst) executables, use the oracle.mk program which
can be found in the $ORACLE_HOME/rdbms/lib directory.
Depending on your initial configuration, your system resource limitations, and
your overall system load, the performance benefit that you might see is roughly 0
to 15%.
nature of the SQL which is being executed. For example, repeated execution may
result in an event appearing for a length of time, and that event may be a result of
contention caused by SQL executed during that period. See Figure 16 for sample
output of v$session_wait.
Some possible interpretations of the events of Figure 15 and Figure 16 are
shown in Figure 17.
Output from this command displays the SQL which caused the contention:
SQL_TEXT
----------------------
select f1,f2,f3,f4 from c0t1
1 row selected.
Of course, this same information can be obtained using a single select and a join
with the sid to ensure that the cached sql_text is not out of date.
blocks that make up rollback segments are accessed frequently, rollback seg-
ments may be subject to contention.
Use the following SQL statement to determine how often requests for space in a
rollback segment cause delays. The hit rate (HITS) should be more than 95%.
Figure 19, below shows output results from this SQL statement.
SELECT name, gets, waits, ((gets-waits)*100)/gets hits
FROM v$rollstat s, v$rollname n
WHERE s.usn = n.usn;
If too few rollback segments exist, or if they are too small, or if users are not
assigned to rollback segments properly, then a rollback segment may become a
bottleneck. The simple solution to rollback contention is to add more rollback
segments (Tip 6).
It is also a good idea to assign users who run large transaction to large rollback
segments so that they don’t run out of rollback space. A common symptom of too
little rollback space is the error message “snapshot too old.”
Figure 20 shows a sample output for the equivalent display from Server Man-
ager. Examine the statistics for the redo allocation latch and the redo copy
latches of type Wait:
STATISTIC VALUE
--------------------- -----------
Servers Busy 70
If this number reaches the value set for PARALLEL_MAX_SERVERS, it means
that at least some parallel queries are probably being processed sequentially. At
the same time, run sar -u to observe CPU loading. Observe these measurements
over a significant period of time. The table below summarizes tuning actions
based on the ratio of Servers Busy to PARALLEL_MAX_SERVERS compared to
CPU utilization.
You can check the contention level of the latch by monitoring the miss rate and
the sleep rate from utlbstat/utlestat. The goal is to reduce the sleep rate
by tuning the spin count. If the contention level is high, you can increase the spin
count to make processes spin more before acquiring the latches. However, since
increasing the spin count makes CPU usage go up, the system throughput may go
down at some point. Thus, it is important to find the optimal point by tuning spin
count.
XII. Step 7: Tuning Resource Contention for the Parallel Server Option
The Oracle Parallel Server option(OPS) allows many independent UNIX proces-
sors with separate Oracle Instances to operate on a single database stored on col-
lection of shared disks. Database concurrency is maintained across the processors
using a Distributed Lock Manager (DLM). Normally the actions of the DLM are
transparent to the users of the database. However, managing resources using the
DLM is less efficient than using the shared memory model within a single data-
base instance. The tips below describe tuning techniques designed to minimize
the chances that the DLM will become a bottleneck.
Consistentgets – Asynclockconverts
Lockconversionratio = ----------------------------------------------------------------------------------------
Consistentgets
This ratio should be 95% or higher in order for the application to scale well. If
there is too much lock contention then the application must be re-evaluated and
perhaps re-designed to work with the Parallel Server option.
Although the application being executed by the Oracle RDBMS is the most com-
mon source of lock contention, sometimes insufficient locks have been allocated,
New installations If you are doing a new installation or building a new database, you can use the
and small to mid-sized installer to build an OFA compliant database. Figure 1 shows such a newly
databases installed OFA compliant installation. You will have to supply a database name
(db_name). Use a descriptive 8 character or shorter name.
Installing an OFA compliant database and Oracle software products with the ver-
sion of the Installer shipped with the Oracle7 Server Release 7.2 requires enter-
ing the path names for the data files rather than accepting the suggested defaults.
After the install is completed, you will need to build the admin directory struc-
ture and change the dump file destinations in $ORACLE_HOME/dbs/con-
fig<db_name>.ora to point to the appropriate directories. You may also want to
m o v e t h e d a t a b a s e c r e a t i o n s c r i p t s a n d p a r a m e t e r fi l e s t o t h e
../admin/<db_name>/(pfile or create) directories. If you do move the parameter
Logical Volume Managers On systems with a Logical Volume Manager (LVM), such as HP, Sun, DG, IBM,
Pyramid, and UNIXware, a Logical Volume can be built up from slices on several
physical disks. These logical volumes can be used instead of slices to build up the
file system and datafiles. With an LVM, a logical volume can be much larger than
a single physical disk. In addition, Logical Volumes can stripe the data from a sin-
gle(large) file across many disks, potentially increasing performance (Tip 27).
Oracle recommends using an LVM, if available.
$ORACLE_BASE $ORACLE_HOME
(/u01/app/oracle) (/u01/app/oracle/product/7.1.3)
Mount Points A mount point is a directory name identifying where the file subsystem for a sin-
gle disk slice (or logical volume) will be linked into an existing UNIX file sys-
tem. You will have to choose mount points for slices containing all the software
and data files. Careful selection of mount point names can make UNIX easier to
administer. In selecting names, the configuration planner must find an appropriate
balance among these requirements:
Requirement 1. The file system must be organized to allow easy adminis-
tration of growth: Adding data into existing databases, adding users, creat-
ing databases, and adding hardware
Requirement 2. .It must be possible to distribute I/O load across suffi-
ciently many disk drives to prevent a performance bottleneck.
Requirement 3. It may be necessary to minimize hardware cost.
Requirement 4. It may be necessary to isolate the impact of drive failure
across as few applications as possible.
Using an LVM to build a single logical volume across every disk satisfies
requirement 2 with minimal effort. Unfortunately it does not allow adding a new
disk easily, and a single disk failure would prevent every application from run-
ning until repair and recovery was completed, violating requirements 1 and 4. In
general, meeting requirement 3 will usually result in some compromise to
requirements 2 and 4. For an LVM, the logical volumes can be striped across
only some of the disks, or be built as mirrored logical volumes, meeting all four
requirements.
One way to balance these requirements is to name every one of your UNIX
mount points so it is easy to find where each disk slice in the file system. The fol-
lowing rule accomplishes this goal.
OFA 1 Name all mount points that will hold site specific data to match the pattern /pm
where p is a string constant and m is a unique fixed-length key used to distinguish
each mount point. Examples: /u01 and /u02 or /disk01, /disk02, etc.
VLDB Mount Points Some sites have a single Oracle database large enough to require many disk
drives of storage. These sites are able to satisfy Requirement 2 and still dedicate
entire disk drives (or logical volumes made up of entire disk drives) to a single
Oracle database application. In this case a different mount point naming strategy
can be considered.
OFA 11 1. If you can guarantee that each disk drive will contain database files from
exactly one application, and...
2. You have enough drives for each database to ensure that there will be no I/O
bottleneck.
If 1 and 2 are correct, then name mount points matching the pattern /qdm where q
is a string denoting that Oracle data is to be stored there, d is the value of the
db_name init<db_name>.ora or config<db_name>.ora parameter for the data-
base, and m is a unique fixed-length key that distinguishes one mount point for a
given database from another. Example: /ora/intl01 implies that data from the
Oracle database intl is stored on this drive.
Login Home Directories Requirement 5. It must be possible to distribute across two or more disk
drives both (a) the collection of home directories and (b) the contents of an
individual home directory.
OFA 2 Name home directories matching the pattern /pm/h/u, where pm is a mount point
name, h is selected from a small set of standard directory names, and u is the
name of the owner of the directory.
Example: the Oracle Server software owner home directory might be
/u01/app/oracle, and the Oracle Applications software owner home directory
might be /u01/app/applmgr. Placing all home directories at the same level in the
UNIX file system means that we can put home directories on different mount
points, yet still be able to refer to the collection of login homes with a single pat-
tern. The pattern /*/app/* can be used to refer to all applications owner directo-
ries on the system, meeting Requirement 5(a).
Using Symbolic Links In the example above, if both Oracle Financials and Manufacturing share the
same software owner directory: /u02/app/applmgr, more than a gigabyte of disk
space would be needed. Requirement 5(b) can be met using symbolic links to
make directories appear in a single subtree, even though they physically reside on
different mount points.
Figure 2 shows the symbolic link required to enable the Oracle General Ledger
software to live on a separate mount point from the other applications software,
yet appear to live in /u02/app/appmgr. All applmgr files are still identifiable as
residents of subtrees whose names match the pattern /*/app/applmgr
$ ln -s /u03/app/applmgr/gl /u02/app/applmrg/gl
$ ls -l /u02/app/applmgr
-rw-r--r-- 1 applmgr 1119 Jul 5 01:16 AOL.env
drwxrwxr-x 1 applmgr 2048 Jul 5 01:16 alr
drwxrwxr-x 1 applmgr 2048 Jul 5 01:16 fnd
lrwxrwxrwx 1 applmgr 5 Jul 5 01:16 gl -> /u03/app/applmgr/gl
...
$ ls -l /uo3/app/appmgr
drwxrwxr-x 1 applmgr 2048 Jul 5 01:16 gl
Moving directories Requirement 6. It must be possible to add or move login home directories
without having to revise programs that refer to them.
OFA 3 Refer to explicit path names only in files designed specifically to store them, such
as /etc/passwd and /etc/oratab; refer to group memberships only in /etc/group.
Product files Mature production sites normally support two or more versions of a product: the
version in production and the version being prepared for production.
Requirement 8. It must be possible to execute multiple versions of appli-
cations software simultaneously. Cutover after upgrade must be as simple
for the administrator and as transparent for the user as possible.
OFA 4 Store each version of the Oracle Server distribution software in a directory
matching the pattern h/product/v, where h is the login home directory of the
Oracle software owner, and v represents the version of the software.
Example: /u01/app/oracle/product/7.1.3 names the start of the directory struc-
ture where the Oracle7.1.3 Server files are located. The environment variable
$ORACLE_HOME is set to this point in the directory structure for the active
version of the Oracle Server. (Keep these directories clean. (Requirement 7) Add-
ing site-specific data may imperil the next update if the old version directory is
deleted.)
Administrative Files In the normal course of operation, installers store programs that create databases;
the Oracle Server itself produces trace files; and administrators save structural
records, instance parameters, performance statistics, backups, archives, and gen-
eral logbook entries on each database. Each database needs a large set of adminis-
trative files. The more databases, the more files must be managed.
Requirement 9. Administrative information about one database must be
separated from that of others; there must be a reasonable structure for
organization and storage of administrative data.
OFA 5 For each database with whose db_name is d, and where h is the Oracle software
owner’s home directory, store database administration files in the following sub-
directories of h/admin/d:
adhoc ad hoc SQL scripts for a given database
arch archived redo log files
adump audit files (Oracle7 audit feature - must clean out periodically)
(set audit_file_dest in config<db_name>.ora to point here)
bdump background process trace files
cdump core dump files
create programs used to create the database
exp database export files
logbook files recording the status and history of the database
pfile instance parameter files
udump user SQL trace files
Some administrative directories, such as arch and exp, are typically too large to
store on the disk slice housing the Oracle owner’s login home directory. These
directories can be connected easily into the administrative subtree with symbolic
links similar to the one shown in Figure 2. Using symbolic links is a simple
mechanism for storing a file anywhere it needs to be without sacrificing the orga-
nization of the file system to physical size constraints.
Local Software The OFA standard encourages the administrator to add site-specific Oracle soft-
ware into the system in the local subtree of the directory structure described
above. In addition, Oracle Consulting will populate this subtree with administra-
tive utilities during an on-site engagement.
File Sharing Some Oracle customers run substantially the same software on several systems
connected together with a high-performance Local Area Network (LAN). Often a
portion of the file system is made available over the network using products like
NFS (Network File System), DFS (Distributed File System), or AFS (Andrew
File System). In these cases, networked partitions can be included in an OFA con-
forming system as separate mount points. You should use a different /pm (like
/n01) to distinguish these partitions. The product, administrative, and local files
described in this section and illustrated in Figure 2 can all be part of a network file
system and shared. However, see the warnings below about extending this use of
networked file systems to database files.
NFS WARNING Do not place any Oracle Database File in any kind of network file system. The
data files concurrency controls on network file systems are not safe when used with data
items smaller than a file. The Oracle Server manages data at the block level, much
smaller than a file. Even if you think that only one system is using the database
files, individual blocks can still be lost or arrive out of order, corrupting your
database.
NFS warning Other files may be placed in NFS safely. However, NFS files will typically be
other files slower than local files. NFS is often used to store the binaries, message files, etc.
especially on parallel server implementations. However, if the NFS sever fails,
every Oracle instance associated with it will typically soon hang or fail. If the
parallel server is used for availability, having a single NFS server defeats the pur-
pose. Oracle software is often on NFS during development and prototyping, then
moved to regular partitions for mission-critical production use.
Figure 3 opposite shows how the OFA requirements and rules for Mount Points
and Oracle software, administrative, and local files come together in a UNIX
directory structure. In this case, there are three mount points: /u01, /u02, and
/u03. In addition, there are three databases: intl, sab and sabt. Symbolic links are
used to present a single, consistent view of the Oracle files independent from the
underlying disk drives.
$ORACLE_BASE $ORACLE_HOME
(/u01/app/oracle) (/u01/app/oracle/product/7.1.3) /7.1.3
/bin
/u01 /app /oracle /dbs
/forms40
/install
/lib
/network
/product
/rdbms
/sqlplus
/u02 /app /applmgr /local /tcppa
/alr /tk2
/fnd /admin
/7.0.16
/gl -> /u03/app/applmgr/gl
/bin
/dbs
/app /applmgr /TAR ...
/u03
/gl
/intl
/adhoc
/arch
/unn /adump
/bdump
/cdump
/create
/etc
oratab /exp
sqlnet /logbook
tnsnames.ora /pfile
listener.ora ---initintl.ora
/udump
/usr /local /bin
oraenv /sab
...
coraenv
dbaenv /sabt
...
cdbaenv
dbhome
Oracle database files should be separated from the other files on the system for
several reasons. Database files have lifetimes that differ from all other files on the
system. Database files also require a different backup strategy than the other files.
Experience yields the following requirement:
Requirement 10. Database files should be named so that (a) database files
are easily distinguishable from all other files; (b) files of one database are
easily distinguishable from files of another; (c) control files, redo log files,
and data files are identifiable as such; and (d) the association of data file to
tablespace is easily identifiable.
Control files Oracle control files contain structural information about the database, including
relatively static data like the current redo log sequence number. For safety’s sake,
it is essential that the administrator create at least two control files on two differ-
ent disks. Having three control file copies ensures that even if one file is lost,
there remains a safe duplication. Because control file copies are always stored on
different disks, they can have identical basenames.
/u01 /oradata
/u02 /oradata
/u03 /oradata
Redo log files Oracle redo log files record information necessary to roll forward a database in
case of CPU or disk failure. Redo log files are written sequentially during transac-
tion processing, and they are read only during archiving and recovery. Since redo
log files for a database may all exist on a single drive, the file basename must be
distinguished. The distinguishing key is normally a three- or four-character string
showing the group and sequence for that redo log.
Data files Oracle datafiles store the data from tablespaces (see below). Using the tablespace
name as the root of the data file unambiguously shows the connection between
tablespace and data file. There are often many datafiles associated with a single
dataspace so a distinguishing key (usually 2 characters) is added to the tablespace
name to complete the basename.
Personal Preferences The examples here are intended to inform, not dictate, naming. Many variations
on the themes expressed here will work. Meeting the requirements described in
this appendix is more important than following the rules. The examples below
show variations that meet the requirements described earlier and also meet the
two important tests below:
• The directory’s actual name does not mater, as long as it is both consistent
with the names of other similar directories, and chosen carefully to not mis-
represent the contents of the directory.
• I/O balanced files can be stored at any level below the mount point, as long
as it’s the same level on every mount point.
Examples:
/u01/ORACLE/sab/system01.dbf
/disk4/oradata/pdnt/system01.dbf
/db016/ora/mail/system01.dbf
/neptune/data/disk31/oracle/bnr1/system01.dbf
/u08/app/oracle/data/pfin/system01.dbf
Tablespace Names The OFA standard of embedding the name of a tablespace in the basename of its
associated data files (OFA 6) means that UNIX file name length restrictions (14
characters for portable UNIX) also restrict tablespace name lengths. The datafiles
include a six character suffix, so 8 characters are left for the tablespace name.
Raw redo logs Because raw devices are most beneficial for files that do sequential writes, redo
logs are ideal candidates for raw devices. In addition, on-line redo log files are not
usually included in normal operating system backup procedures, so one of the pri-
mary administrative challenges for raw devices is removed
There are two additional administrative issues associated with the use of raw par-
titions:
• Backup: the only standard UNIX utility to backup a raw device is “dd”.
• Fragmentation: By definition, the file size of a raw partition equals the parti-
tion size. Once created, disk partitions are very hard to change and the size
choices available may be very limited. Putting two facts together, there are
seldom enough raw partitions available when needed, and those that are
available are usually of the wrong size.
Both of these issues must be addressed at any site that plans to use raw devices.
Fortunately, substantial help is (or soon will be) available for many UNIX plat-
forms. Backup issues can be avoided by only putting redo logs on raw partitions,
or addressed directly using the Oracle backup offering as it becomes available.
If you have decided to use raw devices, then you will need to meet the following
requirement:
Requirement 12. It must be possible to tune disk I/O load across all drives,
including drives storing Oracle data in raw devices.
OFA teaches that whatever initial configuration is chosen, over time, that config-
uration will change significantly. OFA suggests rules and requirements that
ensure adaptability for data files in the file system. The advice in the section
below makes using raw devices as flexible as possible. This is also the way that
the Oracle customer benchmarking team sets up a benchmark database on raw
devices.
OFA 9 Chose a small set of standard sizes for all raw devices that may be used to store
Oracle database files.
In general, standardizing on a single size is the way to go. If a single size is used,
raw files can be moved from one partition to another safely. The size should be
small enough so that a fairly large number can be created. but large enough to be
convenient. For example, a two gigabyte drive could be divided into 10 partitions
of 200 megabytes each -- a good balance between size and number. Any
tablespace that uses raw devices should stripe them across several drives. This
should be done with a logical volume manager.
Logical Volume Manager A logical volume manager should be used, if available, to build up pre-striped
raw database files. Tip 28 describes use of an LVM to meet Requirement 12.
For example, you could use the LVM to build 8 logical volumes striped across
five disks (ten if mirroring is required for availability). This gives 8 pre-striped
logical volumes of one gigabyte each ready to be assigned to datafiles. In addi-
tion, you could create 10 unstriped logical volumes for the SYSTEM, TOOLS,
and other small tablespaces for an OPS based application.
Some logical volume managers, such as HP’s, allow mirrored logical volumes to
be established in increments of 4 megabytes after the striped volume groups are
built. This allows far more precision in matching file sizes to database needs.
However, sticking to a few sizes each an integral multiple of the others is still
required to allow files to be moved conveniently.
Integrate raw devices Figure 5 shows how symbolic links with a meaningful name can be used in an
with the file system OFA compliant data file structure to point to each raw partition. Because the size
using symbolic links of each data file is fixed, the size is embedded in the name, in this case using a
two digit number just before the “.” where the LSB represents 100 megabytes.
Additional raw partitions or LVM partitions will be needed from time to time,
often unpredictably. Figure 4 shows that every partition available for use is
included in the path /pm/q/spare_pool using symbolic links to connect the parti-
tion to the raw device name.
In order to perform backups or other administration that requires the knowledge
of what data is on what disk or partition, create a text file with symbolic links for
every datafile in every tablespace. There should be mappings to both the logical
volumes and also to the physical partitions for recovery and reconfiguration. This
file can be processed using the usual UNIX tools to build the scripts needed for
many administrative activities.
Meeting Requirement 13 can take advantage of the following features of the OFA
standard: the directories arch, create, and exp are database administrative direc-
tories; bdump, cdump, pfile, and udump are instance administrative directories,
and adhoc and logbook are mixtures of both.
One way to structure the administrative directory for the sab database is shown in
Figure 6. In this example each administrative subtree that holds instance specific
information adds a directory layer to put the information for each instance into its
own directory path. NFS mounting some of the files to give a common link from
all instances, appropriate use of symbolic links for admin/d, or use of a common
working directory by setting it to ~oracle/admin/sab are all options for fulfilling
Requirement 13.
OFA 10 If you are using Oracle Parallel Server, select exactly one node to act as Oracle
administrative home for the cluster to house the administrative subtree defined in
OFA 5. Create a directory named for each instance accessing the database within
the bdump, cdump, logbook, pfile, and udump directories of ~/admin/d Ensure
that the admin directory for the administrative home is mounted as the admin
directory for every instance.
After you run the application that you wish to monitor, to end the collection of
statistics, run the utlestat script. Like utlbstat, utlestat creates a set
of tables and views in the SYS account. These tables contain a snapshot of the
state of the system at the end of the performance test. The tables that reflect the
‘end’ state of the system are listed in Table 2.
In addition to the ‘end’ state tables, ESTAT creates a set of tables in the SYS
account which outline the differences between the ‘beginning’ state and ‘end’
state statistics. The database tables created are listed in Table 3.
shared pool
Enqueue freelist
row cache library cache
recursive calls/ (pins-reloads)/
user calls < .1 pins > 95% enqueue misses = 100% hit rate
adjust by increasing
adjust adjust enqueue_resources in init.ora
shared_pool shared_pool
in init.ora in init.ora
buffer cache
Redo Log buffer
LRU
chain
dirty
chain
Bibliography
No one can know everything about the Oracle database, UNIX and how to tune them. This bibliography iden-
tifies a number of sources for tuning information. It is recommended that the Oracle manuals be available, at
least as a reference (you might consider using the CD-ROM version). In addition, everyone responsible for
tuning the Oracle Server should own several of the books from outside Oracle.
1. Oracle7 Server Administrator’s Guide; Oracle Part A20322-2, Release 7.2.
The DBA’s most important document. Describes how to build and maintain an Oracle database. Most of the
tuning advice has been moved to Oracle 7 Server Tuning, described below.
2. Oracle7 Server Application Developer’s Guide; Oracle Part A20323-2, Release 7.2.
This manual describes how to design an application. It provides an introduction to components of the server
that most impact performance. Specific tuning advice is in the Oracle 7 Server Tuning manual, below.
3. Oracle7 Server Tuning, Release 7.2; Oracle Part #A25421-1.
This manual describes SQL Processing, including Discrete Transactions, the query Optimizer, and parallel
query. Each of these subjects is described in detail, along with how to use these features for best results.
4. Oracle7 Server Reference, Release 7.2; Oracle Part #A20327-2.
Describes initialization parameters, data dictionary - including the V$tables, and SQL scripts needed to
administer and monitor the database.
5. Oracle7 Server Concepts Manual, Release 7.2; Oracle Part A20321-2.
Tuners should be generally familiar with the database concepts explained in this book.
6. Oracle Server Manager User’s Guide; Oracle Part A30887-1.
This manual describes use of the Server Manager. Several of the screens shown in this document are taken
from server manager displays.
7. Oracle7 Server Utilities User’s Guide; Oracle Part #3602-70-1292.
Chapters 10 through 13 describe SQL*DBA.
8. Oracle7 Parallel Server, Release 7.2; Oracle Part A19487-2.
Introduction to the parallel server option. Chapter 3, Database Design, discusses a number of parallel server
tuning issues to consider when designing an OPS database.
9. Oracle 7 Parallel Server Administrator’s Guide; Oracle Part A12852-1.
The “fish book”, this document describes the tools available on most UNIX systems. The second non-Oracle
document to own.
The next six books are popular books covering UNIX system administration, UNIX internals, and computer
architecture. New additions appear on a regular basis.
22. Evi Nemeth, Garth Snyder, and Scott Seebass; UNIX System Administration Handbook; Prentice-Hall; Engle-
wood Cliffs, NJ; 1989.
23. Aeleen Frisch; Essential System Administration; O’Reilly & Associates; Sebastopol, CA; 1991.
24. Maurice J. Bach; The Design of the UNIX Operating System; Prentice-Hall; Englewood Cliffs, NJ; 1986.
25. Bernard M. Goodheart, James Cox; The Magic Garden Explained; Prentice Hall.
26. Jerry Peek, Mike Loukides, Tim O’Reilly et al.; Unix Power Tools; O’Reilly & Associates.
27. David A. Patterson and John L. Hennessy; Computer Architecture A Quantitative Approach; Morgan Kauf-
mann Publishers; San Mateo, CA; 1990.
An excellent book on computer architecture. The examples, methods and historical insights are unrivalled.
The writing is clear, clean, well organized and persuasive. Patterson and Hennessy have also published a new
text focusing on the interaction of architecture and operating systems.
28. VAX VMS Tuning for Oracle; Oracle Part #52569.0992.
Oracle Corporation welcomes your comments and suggestions on the quality and usefulness of this publica-
tion.Your input is an important part of the information used for revision. You can also send your comments elec-
tronically to mhjohnso@oracle.com.
Oracle Corporation
World Headquarters
500 Oracle Parkway
Redwood Shores, CA 94065
415.506.7000
800.442.8649
Fax 415.506.7200
International inquiries:
44.932.872.020
Telex 851.927444 (ORACLE G)
Fax 44.932.874.625