Professional Documents
Culture Documents
SQL> SELECT *
2 FROM v$buffer_pool;
Dictionary Views
These dictionary views have a BUFFER_POOL column that indicates the default buffer pool
for the given object:
• USER_SEGMENTS, DBA_SEGMENTS
• USER_CLUSTERS, ALL_CLUSTERS, DBA_CLUSTERS
• USER_INDEXES, ALL_INDEXES, DBA_INDEXES
• USER_TABLES, ALL_TABLES, DBA_TABLES
• USER_OBJECT_TABLES, ALL_OBJECT_TABLES, DBA_OBJECT_TABLES
• USER_ALL_TABLES, ALL_ALL_TABLES, DBA_ALL_TABLES
The V$BUFFER_POOL view describes the buffer pools allocated. The columns from
V$BUFFER_POOL show:
• The number and range of LRU latches allocated to the buffer (sets)
• The number and range of blocks allocated to the buffer
Caching Tables
When the server retrieves blocks using a full table scan, the blocks go to the least recently
used end of the LRU list. The blocks are used the next time a free block is needed, so they are
not available for other processes. You can choose to cache whole tables at the most recently
used (MRU) end of the list.
You alter this behavior if you do the following:
• Create a table using the CACHE clause
• Alter a table using the CACHE clause
• Code the CACHE hint clause into a query
If you use one of these methods, the Oracle server places the table blocks at the most recently
used end of the LRU list. Use the CACHE clause when you create small lookup tables used by
many users. You may overcrowd the buffer cache if you have too many cached tables.
NAME VALUE
--------------------------- --------
free buffer inspected 183
From V$SYSTEM_EVENT:
SQL> SELECT event, total_waits
2 FROM v$system_event
3 WHERE event in
4 (’free buffer waits’, ’buffer busy waits’);
EVENT TOTAL_WAITS
---------------------- -----------
free buffer waits 337
buffer busy waits 3466
• Query V$SESSION_WAIT.
• Identify the object and get free lists for the
segment from DBA_SEGMENTS.
• Either:
– Change the object in question, or
– Move into an auto-managed tablespace.
LGWR
ARCn
Control
files
Server
process
Server
process
LGRW
SQL> DELETE FROM employees
2 WHERE employee_id=7400; ARCH
Diagnosing Problems
On machines with fast processors and relatively slow disks, the processors may be filling
the rest of the redo log buffer in the time it takes the LGWR process to move a portion of the
buffer out to disk.
For this reason, a larger buffer makes it less likely that new entries will collide with the part
of the buffer still being written.
Server processes may request space from the redo log buffer to write new entries and not
find any. They will have to wait for LGWR to flush the buffer to disk.
Tuning Goal
Tuning the redo log buffer means ensuring that the space required by server processes in
the redo log buffer is sufficient. However, too much space will reduce the amount of
memory that can be allocated to other areas. It is also important to note that the DBA can
adopt practices that will reduce the amount of redo that must be performed.
V$SYSSTAT
Redo Buffer Allocation Retries statistic
LOG_BUFFER
LOG_CHECKPOINT_INTERVAL
LOG_CHECKPOINT_TIMEOUT
Dynamic Views
The V$SESSION_WAIT view indicates through the Log Buffer Space event if there are any
waits for space in the log buffer because the session is writing data into the log buffer faster
than LGWR can write it out.
SQL> select sid, event, seconds_in_wait, state
2 from v$session_wait
3 where event = ’log buffer space%’;
• SHARED_POOL_SIZE:
– 8 KB per loaded class
– 50 MB for loading large JAR files
• Configure Oracle Shared Server
• JAVA_POOL_SIZE
– 20 MB default
– 50 MB for medium-sized Java application
How Oracle9i Enterprise Java Engine (EJE) Uses the Shared and Large Pool
The Java Engine uses about 8 KB per loaded class. The shared pool is also temporarily used
by the class loader while loading and resolving classes into the database. While loading and
resolving particularly large JAR files, you can use 50 MB of shared pool memory.
The UGA is allocated in the large pool when the LARGE_POOL_SIZE is included in the
init.ora file.
How Oracle9i Enterprise Java Engine (EJE) Uses the Java Pool
The Java pool is a structure in the SGA that is used for all session-specific Java code and
data within the EJE. During instance startup, the Java pool is allocated a fixed amount of
memory equal to the init.ora parameter JAVA_POOL_SIZE.
Generally, the JAVA_POOL_SIZE should be set to 50 MB or higher for large applications.
The default value of 20 MB should be adequate for typical Java Stored Procedure usage.
I/O Slaves
Asynchronous I/O behavior, if not natively available, can be simulated with the deployment
of I/O slave processes. I/O slaves are specialized processes whose only function is to perform
I/O. Many platforms that support asynchronous I/O for disk devices do not do so for tape
devices. In this case, I/O slaves can be used to do nonblocking I/O to tape devices.
The DBWR_IO_SLAVES and BACKUP_TAPE_IO_SLAVES initialization parameters
control I/O slave deployment. You can turn asynchronous I/O on and off with the
DISK_ASYNCH_IO and TAPE_ASYNCH_IO parameters. It may be necessary to turn off
the asynchronous I/O facility provided by the operating system. For example, if the
asynchronous I/O code of the platform has bugs or is not efficient, asynchronous I/O can be
disabled by device type. Usually the parameter should be left at the default value of TRUE.
The I/O Slave Mechanism
I/O slaves can be deployed by the DBW0 process. I/O slaves for DBW0 are allocated
immediately following database open when the first I/O request is made.
The DBW0 process looks for an idle I/O slave. If one is available it gets the post. If there are
no idle slaves, the I/O issuer spawns one. If the allowed number of slaves have been
spawned, the issuer waits and tries again to find an idle slave. The DBW0 continues to do all
the DBW0-related work; for example, gathering dirty buffers into a batch. The DBW0 I/O
slave simply does the I/O on behalf of DBW0. That is, the writing of the batch is parallelized
between the I/O slaves. This is beneficial in write-intensive environments, because the CPU
time associated with issuing I/Os can be divided between the I/O slaves.
Guidelines
Consider increasing the DBWn processes, if you see a high number of
free_buffer_waits after querying the V$SYSTEM_EVENT view as in the following
syntax:
SELECT TOTAL_WAITS FROM V$SYSTEM_EVENT WHERE EVENT =
’FREE BUFFER WAITS’;
DBWn Write
LGWR Write
SERVER Read/write
Oracle Processes
While most server processes only read from disk, sort direct write server processes
will write to disk.
Performance Guidelines
For very heavy OLTP applications, there are concurrency problems when using dictionary
managed tablespaces because the dictionary needs to be accessed for space management
operations during extent allocation. With locally managed tablespaces, there is no dictionary
intervention, and therefore fewer concurrency problems.
Tables created in locally managed tablespaces can have thousands of extents with no
performance implications, therefore reorganizing tables is unnecessary. In locally managed
tablespace, free space does not have to be coalesced to remove “beehive” fragmentation
because bitmaps track free space and allocate it effectively.
When users are created, a temporary tablespace is designated for any disk sorts that they will
need. These sort areas should be separate from other database objects. If users do not have a
temporary tablespace, any sort areas needed will use the SYSTEM tablespace.
Tables and indexes should be split into separate tablespaces, because indexes and tables are
often inserted into and read from simultaneously.
All tables that contain LONG or LOB data types, for example, BLOB and CLOB, should be
placed into a separate tablespace.
Guidelines
• In general, to reduce the activity on an overloaded disk, move one or more of its heavily
accessed files to a less active disk.
– Redo log files are written sequentially by the LGWR process. Put the redo log files
on a disk with no other activity or a low incidence of reads and writes: LGWR can
write much faster if there is no concurrent activity.
– If users concurrently access a large table, striping across separate data files and
disks can help to reduce contention.
• Try to eliminate I/O unrelated to the Oracle server on disks that contain database files.
This is also helpful in optimizing access to redo log files and enables you to monitor all
data file activities on such disks with the V$FILESTAT dynamic performance view.
• Knowing the types of operation that predominate in your application and the speed with
which your system can process the corresponding I/Os, you can choose the disk layout
that maximizes performance.
Guidelines
Each database should have separate tablespaces specified for:
• Data dictionary objects
• Rollback segments and undo segments
• Temporary segments
• Tables
• Indexes
• Very large objects
Most production databases have many more tablespaces than this, but the important principle
is to separate data of different types and with different uses for housekeeping and backup
purposes.
The SYSTEM tablespace contains only data dictionary objects owned by sys. No other
users should have the ability to create objects in it.
Remember that stored objects such as packages and database triggers form part of the data
dictionary.
Rollback segments should use rollback segment tablespaces exclusively.
Undo segments can only exist in UNDO tablespaces thus making them exclusive.
V$FILESTAT
V$DATAFILE
Data files
Context Reference
file# File number (join to file# in V$DATAFILE for the name)
Phyrds Number of physical reads done
phywrts Number of physical writes done
phyblkrd Number of physical blocks read
phyblkwrt Number of physical blocks written
readtim Time spent doing reads
writetim Time spent doing writes
Note: The last two columns contain 0 unless the TIMED_STATISTICS parameter is set to
TRUE.
Use the following query to monitor these values:
SQL> SELECT phyrds,phywrts,d.name
2 FROM v$datafile d, v$filestat f
3 WHERE d.file#=f.file# order by d.name;
PHYRDS PHYWRTS NAME
---------- -------- --------------------------------
806 116 /…/u01/system01.dbf
168 675 /…/u04/temp01.dbf
8 8 /…/u02/sample01.dbf
26 257 /…/u02/undots01.dbf
65012 564 /…/u03/users01.dbf
8 8 /…/u01/query_data01.dbf
6 rows selected
I/O Statistics
Check the output in STATSPACK to observe how well the I/O load is distributed across the
disk devices. The output shows which files are most active. In the example shown on the
slide, the USERS tablespace is being hit heavily. About 98% of the reads are being
performed on the data file that contains tables. The index data file is having 0.01% of the disk
reads performed against it.
• Checkpoints cause:
– DBWn to perform I/O
– CKPT to update the data file header and control file
• Frequent checkpoints:
– Reduce instance recovery time
– Decrease run-time performance
Checkpoints
The LGWR background process writes to redo log groups in a circular fashion.
When a group is filled, the Oracle server must perform a checkpoint. This means that:
• DBWn writes all or part of the dirty blocks covered by the log being checkpointed to the
data files.
• CKPT updates the data file headers and the control files.
Checkpoints normally allow other work to continue at the same time, although the checkpoint
generates many disk writes. If the DBWn process has not finished checkpointing a file and
LGWR needs the file again, LGWR has to wait.
Frequent checkpoints mean shorter instance recovery times but more writes by DBWn (to the
data files) and CKPT (to the data file headers). Your choice depends on your priorities
regarding recovery time and run-time performance.
STATSPACK
LOG_CHECKPOINT_INTERVAL
LOG_CHECKPOINT_TIMEOUT
FAST_START_IO_TARGET
LOG_CHECKPOINTS_TO_ALERT Alert log
file
To specify a value for FAST_START_IO_TARGET, decide on the required service level after
discussion with users. Translate this time to equivalent number of datafile I/O by using the
average I/O time statistic from the view V$FILESTAT.
Monitoring Impact of Parameters on Recovery Time
Use the V$INSTANCE_RECOVERY view to obtain the following information:
• RECOVERY_ESTIMATED_IOS: The estimated number of data blocks to be processed
during recovery based on the in-memory value of the fast-start checkpoint parameter
• ACTUAL_REDO_BLKS: The current number of redo blocks required for recovery
• TARGET_REDO_BLKS: The goal for the maximum number of redo blocks to be
processed during recovery. This value is the minimum of the following 4 columns.
• LOG_FILE_SIZE_REDO_BLKS: The number of redo blocks to be processed during
recovery to guarantee that a log switch never has to wait for a checkpoint
• LOG_CHKPT_TIMEOUT_REDO_BLKS: The number of redo blocks that need to be
processed during recovery to satisfy LOG_CHECKPOINT_TIMEOUT
• LOG_CHKPT_INTERVAL_REDO_BLKS The number of redo blocks that need to be
processed during recovery to satisfy LOG_CHECKPOINT_INTERVAL
• FAST_START_IO_TARGET_REDO_BLKS: The number of redo blocks that need to be
processed during recovery to satisfy FAST_START_IO_TARGET