Oracle® Database Performance Tuning Guide 10g Release 2 (10.2) Part Number B14211-01 |
|
|
View PDF |
This chapter is an overview of the Oracle methodology for configuring a database for performance. Although performance modifications can be made to the Oracle database instance at a later time, much can be gained by proper initial configuration of the database for the intended needs.
This chapter contains the following sections:
This section discusses some initial database instance configuration options that have important performance impacts.
If you use the Database Configuration Assistant (DBCA) to create a database, the supplied seed database includes the necessary basic initialization parameters and meets the performance recommendations that are discussed in this chapter.
See Also:
|
A running Oracle instance is configured using initialization parameters, which are set in the initialization parameter file. These parameters influence the behavior of the running instance, including influencing performance. In general, a very simple initialization file with few relevant settings covers most situations, and the initialization file should not be the first place you expect to do performance tuning, except for the few parameters shown in Table 4-2.
Table 4-1 describes the parameters necessary in a minimal initialization file. Although these parameters are necessary they have no performance impact.
Table 4-1 Necessary Initialization Parameters Without Performance Impact
See Also: Oracle Database Administrator's Guide for information about managing the initialization parameters |
Table 4-2 includes the most important parameters to set with performance implications:
Table 4-2 Important Initialization Parameters With Performance Impact
Parameter | Description |
---|---|
COMPATIBLE |
Specifies the release with which the Oracle server must maintain compatibility. It lets you take advantage of the maintenance improvements of a new release immediately in your production systems without testing the new functionality in your environment. If your application was designed for a specific release of Oracle, and you are actually installing a later release, then you might want to set this parameter to the version of the previous release. |
DB_BLOCK_SIZE |
Sets the size of the Oracle database blocks stored in the database files and cached in the SGA. The range of values depends on the operating system, but it is typically 8192 for transaction processing systems and higher values for database warehouse systems. |
SGA_TARGET |
Specifies the total size of all SGA components. If SGA_TARGET is specified, then the buffer cache (DB_CACHE_SIZE ), Java pool (JAVA_POOL_SIZE ), large pool (LARGE_POOL_SIZE ), and shared pool (SHARED_POOL_SIZE ) memory pools are automatically sized. See "Automatic Shared Memory Management". |
PGA_AGGREGATE_TARGET |
Specifies the target aggregate PGA memory available to all server processes attached to the instance. See "PGA Memory Management" for information on PGA memory management. |
PROCESSES |
Sets the maximum number of processes that can be started by that instance. This is the most important primary parameter to set, because many other parameter values are deduced from this. |
SESSIONS |
This is set by default from the value of processes. However, if you are using the shared server, then the deduced value is likely to be insufficient. |
UNDO_MANAGEMENT |
Specifies which undo space management mode the system should use. AUTO mode is recommended. |
UNDO_TABLESPACE |
Specifies the undo tablespace to be used when an instance starts up. |
See Also:
|
Oracle needs undo space to keep information for read consistency, for recovery, and for actual rollback statements. This information is kept in one or more undo tablespaces.
Oracle provides automatic undo management, which completely automates the management of undo data. A database running in automatic undo management mode transparently creates and manages undo segments. Oracle Corporation strongly recommends using automatic undo management, because it significantly simplifies database management and removes the need for any manual tuning of undo (rollback) segments. Manual undo management using rollback segments is supported for backward compatibility reasons.
Adding the UNDO
TABLESPACE
clause in the CREATE
DATABASE
statement sets up the undo tablespace. Set the UNDO_MANAGEMENT
initialization parameter to AUTO
to operate your database in automatic undo management mode.
The V$UNDOSTAT
view contains statistics for monitoring and tuning undo space. Using this view, you can better estimate the amount of undo space required for the current workload. Oracle also uses this information to help tune undo usage in the system. The V$ROLLSTAT
view contains information about the behavior of the undo segments in the undo tablespace.
See Also:
|
The size of the redo log files can influence performance, because the behavior of the database writer and archiver processes depend on the redo log sizes. Generally, larger redo log files provide better performance. Undersized log files increase checkpoint activity and reduce performance.
Although the size of the redo log files does not affect LGWR performance, it can affect DBWR and checkpoint behavior. Checkpoint frequency is affected by several factors, including log file size and the setting of the FAST_START_MTTR_TARGET
initialization parameter. If the FAST_START_MTTR_TARGET
parameter is set to limit the instance recovery time, Oracle automatically tries to checkpoint as frequently as necessary. Under this condition, the size of the log files should be large enough to avoid additional checkpointing due to under sized log files. The optimal size can be obtained by querying the OPTIMAL_LOGFILE_SIZE
column from the V$INSTANCE_RECOVERY
view. You can also obtain sizing advice on the Redo Log Groups page of Oracle Enterprise Manager Database Control.
It may not always be possible to provide a specific size recommendation for redo log files, but redo log files in the range of a hundred megabytes to a few gigabytes are considered reasonable. Size your online redo log files according to the amount of redo your system generates. A rough guide is to switch logs at most once every twenty minutes.
If you use the Database Configuration Assistant (DBCA) to create a database, the supplied seed database automatically includes all the necessary tablespaces. If you choose not to use DBCA, you need to create extra tablespaces after creating the initial database.
All databases should have several tablespaces in addition to the SYSTEM and SYSAUX tablespaces. These additional tablespaces include:
A temporary tablespace, which is used for things like sorting
An undo tablespace to contain information for read consistency, recovery, and rollback statements
At least one tablespace for actual application use
In most cases, applications require several tablespaces. For extremely large tablespaces with many datafiles, multiple ALTER
TABLESPACE
x
ADD
DATAFILE
Y
statements can also be run in parallel.
During tablespace creation, the datafiles that make up the tablespace are initialized with special empty block images. Temporary files are not initialized.
Oracle does this to ensure that all datafiles can be written in their entirety, but this can obviously be a lengthy process if done serially. Therefore, run multiple CREATE
TABLESPACE
statements concurrently to speed up the tablespace creation process. For permanent tables, the choice between local and global extent management on tablespace creation can have a large effect on performance. For any permanent tablespace that has moderate to large insert, modify, or delete operations compared to reads, local extent management should be chosen.
For permanent tablespaces, Oracle recommends using automatic segment-space management. Such tablespaces, often referred to as bitmap tablespaces, are locally managed tablespaces with bitmap segment space management.
See Also:
|
Properly configuring the temporary tablespace helps optimize disk sort performance. Temporary tablespaces can be dictionary-managed or locally managed. Oracle Corporation recommends the use of locally managed temporary tablespaces with a UNIFORM
extent size of 1 MB
.
You should monitor temporary tablespace activity to check how many extents are being allocated for the temporary segment. If an application extensively uses temporary tables, as in a situation when many users are concurrently using temporary tables, the extent size could be set smaller, such as 256K, because every usage requires at least one extent. The EXTENT
MANAGEMENT
LOCAL
clause is optional for temporary tablespaces because all temporary tablespaces are created with locally managed extents of a uniform size. The default for SIZE
is 1M
.
See Also:
|
When installing applications, an initial step is to create all necessary tables and indexes. When you create a segment, such as a table, Oracle allocates space in the database for the data. If subsequent database operations cause the data volume to increase and exceed the space allocated, then Oracle extends the segment.
When creating tables and indexes, note the following:
Specify automatic segment-space management for tablespaces
This allows Oracle to automatically manage segment space for best performance.
Applications should carefully set storage options for the intended use of the table or index. This includes setting the value for PCTFREE
. Note that using automatic segment-space management eliminates the need to specify PCTUSED
.
Note: Use of free lists is no longer encouraged. To use automatic segment-space management, create locally managed tablespaces, with the segment space management clause set toAUTO . |
Heap-organized tables can be stored in a compressed format that is transparent for any kind of application. Table compression was designed primarily for read-only environments and can cause processing overhead for DML operations in some cases. However, it increases performance for many read operations, especially when your system is I/O bound.
Compressed data in a database block is self-contained which means that all the information needed to re-create the uncompressed data in a block is available within that block. A block will also be kept compressed in the buffer cache. Table compression not only reduces the disk storage but also the memory usage, specifically the buffer cache requirements. Performance improvements are accomplished by reducing the amount of necessary I/O operations for accessing a table and by increasing the probability of buffer cache hits.
Table compression works by eliminating column value repetitions within individual blocks. Duplicate values in all the rows and columns in a block are stored once at the beginning of the block, in what is called a symbol table for that block. All occurrences of such values are replaced with a short reference to the symbol table. The compression is higher in blocks that have more repeated values.
Before compressing large tables you should estimate the expected compression factor. The compression factor is defined as the number of blocks necessary to store the information in an uncompressed form divided by the number of blocks necessary for a compressed storage. The compression factor can be estimated by sampling a small number of representative data blocks of the table to be compressed and comparing the average number of records for each block for the uncompressed and compressed case. Experience shows that approximately 1000 data blocks provides a very accurate estimation of the compression factor. Note that the more blocks you are sampling, the more accurate the result become.
Oracle achieves a good compression factor in many cases with no special tuning. As a database administrator or application developer, you can try to tune the compression factor by reorganizing the records when the compression actually takes place. Tuning can improve the compression factor slightly in some cases and very substantially in other cases.
To improve the compression factor you have to increase the likelihood of value repetitions within a database block. The compression factor that can be achieved depends on the cardinality of a specific column or column pairs (representing the likelihood of column value repetitions) and on the average row length of those columns. Oracle table compression not only compresses duplicate values of a single column but tries to use multi-column value pairs whenever possible. Without a very detailed understanding of the data distribution it is very difficult to predict the most optimal order.
Over time, it is common for segment space to become fragmented or for a segment to acquire a lot of free space as the result of update and delete operations. The resulting sparsely populated objects can suffer performance degradation during queries and DML operations.
Oracle Database provides a Segment Advisor that provides advice on whether an object has space available for reclamation based on the level of space fragmentation within an object.
See Also: Oracle Database Administrator's Guide and Oracle Database 2 Day DBA for information about the Segment Advisor |
If an object does have space available for reclamation, you can compact and shrink database segments or you can deallocate unused space at the end of a database segment.
See Also:
|
The most efficient way to create indexes is to create them after data has been loaded. By doing this, space management becomes much simpler, and no index maintenance takes place for each row inserted. SQL*Loader automatically does this, but if you are using other methods to do initial data load, you might need to do this manually. Additionally, index creation can be done in parallel using the PARALLEL
clause of the CREATE
INDEX
statement. However, SQL*Loader is not able to do this, so you must manually create indexes in parallel after loading data.
During index creation on tables that contain data, the data must be sorted. This sorting is done in the fastest possible way, if all available memory is used for sorting. Oracle recommends that you enable automatic sizing of SQL working areas by setting the PGA_AGGREGATE_TARGET
initialization parameter.
See Also:
|
Using shared servers reduces the number of processes and the amount of memory consumed on the server machine. Shared servers are beneficial for systems where there are many OLTP users performing intermittent transactions.
Using shared servers rather than dedicated servers is also generally better for systems that have a high connection rate to the database. With shared servers, when a connect request is received, a dispatcher is already available to handle concurrent connection requests. With dedicated servers, on the other hand, a connection-specific dedicated server is sequentially initialized for each connection request.
Performance of certain database features can improve when a shared server architecture is used, and performance of certain database features can degrade slightly when a shared server architecture is used. For example, a session can be prevented from migrating to another shared server while parallel execution is active.
A session can remain nonmigratable even after a request from the client has been processed, because not all the user information has been stored in the UGA. If a server were to process the request from the client, then the part of the user state that was not stored in the UGA would be inaccessible. To avoid this, individual shared servers often need to remain bound to a user session.
See Also:
|
When using some features, you may need to configure more shared servers, because some servers might be bound to sessions for an excessive amount of time.
This section discusses how to reduce contention for processes used by Oracle architecture:
The following views provide dispatcher performance statistics:
V$DISPATCHER
- general information about dispatcher processes
V$DISPATCHER_RATE
- dispatcher processing statistics
The V$DISPATCHER_RATE
view contains current, average, and maximum dispatcher statistics for several categories. Statistics with the prefix CUR_
are statistics for the current sample. Statistics with the prefix AVG_
are the average values for the statistics since the collection period began. Statistics with the prefix MAX_
are the maximum values for these categories since statistics collection began.
To assess dispatcher performance, query the V$DISPATCHER_RATE
view and compare the current values with the maximums. If your present system throughput provides adequate response time and current values from this view are near the average and less than the maximum, then you likely have an optimally tuned shared server environment.
If the current and average rates are significantly less than the maximums, then consider reducing the number of dispatchers. Conversely, if current and average rates are close to the maximums, then you might need to add more dispatchers. A general rule is to examine V$DISPATCHER_RATE
statistics during both light and heavy system use periods. After identifying your shared server load patterns, adjust your parameters accordingly.
If needed, you can also mimic processing loads by running system stress tests and periodically polling the V$DISPATCHER_RATE
statistics. Proper interpretation of these statistics varies from platform to platform. Different types of applications also can cause significant variations on the statistical values recorded in V$DISPATCHER_RATE
.
See Also:
|
To reduce contention, consider the following:
Adding dispatcher processes
The total number of dispatcher processes is limited by the value of the initialization parameter MAX_DISPATCHERS
. You might need to increase this value before adding dispatcher processes.
Enabling connection pooling
When system load increases and dispatcher throughput is maximized, it is not necessarily a good idea to immediately add more dispatchers. Instead, consider configuring the dispatcher to support more users with connection pooling.
Enabling Session Multiplexing
Multiplexing is used by a connection manager process to establish and maintain network sessions from multiple users to individual dispatchers. For example, several user processes can connect to one dispatcher by way of a single connection from a connection manager process. Session multiplexing is beneficial because it maximizes use of the dispatcher process connections. Multiplexing is also useful for multiplexing database link sessions between dispatchers.
See Also:
|
This section discusses how to identify contention for shared servers.
Steadily increasing wait times in the requests queue indicate contention for shared servers. To examine wait time data, use the dynamic performance view V$QUEUE
. This view contains statistics showing request queue activity for shared servers. By default, this view is available only to the user SYS
and to other users with SELECT
ANY
TABLE
system privilege, such as SYSTEM
. Table 4-3 lists the columns showing the wait times for requests and the number of requests in the queue.
Table 4-3 Wait Time and Request Columns in V$QUEUE
Column | Description |
---|---|
WAIT |
Displays the total waiting time, in hundredths of a second, for all requests that have ever been in the queue |
TOTALQ |
Displays the total number of requests that have ever been in the queue |
Monitor these statistics occasionally while your application is running by issuing the following SQL statement:
SELECT DECODE(TOTALQ, 0, 'No Requests', WAIT/TOTALQ || ' HUNDREDTHS OF SECONDS') "AVERAGE WAIT TIME PER REQUESTS" FROM V$QUEUE WHERE TYPE = 'COMMON';
This query returns the results of a calculation that show the following:
AVERAGE WAIT TIME PER REQUEST ----------------------------- .090909 HUNDREDTHS OF SECONDS
From the result, you can tell that a request waits an average of 0.09 hundredths of a second in the queue before processing.
You can also determine how many shared servers are currently running by issuing the following query:
SELECT COUNT(*) "Shared Server Processes" FROM V$SHARED_SERVER WHERE STATUS != 'QUIT';
The result of this query could look like the following:
Shared Server Processes ----------------------- 10
If you detect resource contention with shared servers, then first make sure that this is not a memory contention issue by examining the shared pool and the large pool. If performance remains poor, then you might want to create more resources to reduce shared server process contention. You can do this by modifying the optional server process initialization parameters:
MAX_DISPATCHERS
MAX_SHARED_SERVERS
DISPATCHERS
SHARED_SERVERS
See Also: Oracle Database Administrator's Guide for information on setting the shared server process initialization parameters |