Académique Documents
Professionnel Documents
Culture Documents
James F. Koopmann
Chapter 1: INTRODUCTION
As a database administrator, you already know that tuning an Oracle database is a complex
task. With hundreds of features and numerous application interfaces, you must weigh
tuning decisions carefully, and not lose sight of the intricacy of the full system. In fact
tuning Oracle is not a one-person job. Oracle tuning requires not only the database
administration staff but others who understand the full intent of the database and the
applications:
• Developers
• System administrators
• Storage administrators
• Architects
• Business personnel
You can address the complex task of tuning an Oracle database using a systematic
approach. This paper looks at tuning an Oracle database with consideration for Oracle
database files. Other papers address the aspects of memory and applications.
The physical operating system files map to Oracle logical structures at the segment level.
You can improve the performance of the storage subsystem by monitoring the segments
associated with database objects, identify problems and ultimately tune those aspects of
Oracle that relate to the physical data files on the storage subsystem. Database files are the
physical link between logical structures in Oracle and your storage subsystem. They
contain a variety of information, are of different sizes, and often have unique and different
input/output (I/O) patterns.
Categorizing an Oracle database file for unique placement on physical storage is very
challenging. After you have the task completed, you must remember that databases
continue to grow exponentially and that continuous monitoring is nearly impossible.
Tuning the database aspect of Oracle is often neglected until the database performance
deteriorates.
Specifically, this paper focuses on these factors:
• Determining the appropriate RAID level
• Understanding Redo Logs
• Investigating system level performance problems
• Distributing Tablespace
• Applying Tuning Strategies for Oracle Database Files
By examining RAID level, Redo Logs and tablespace you gain a clearer and deeper
understanding of how database files impact system performance. You can then use this
information to tune Oracle and the underlying storage subsystem.
After you have analyzed your storage system, you can make the following decisions for
improved performance:
• Reducing redo log contention
• Sizing redo logs
• Managing archived redo logs
• Using segment level statistics to improve performance
By carefully tuning the Oracle database, you can better meet the information needs of your
environment. By understanding these tuning strategies, you will be better equipped to tune
the Oracle database to meet today’s needs and to prepare for tomorrow’s needs.
Before RAID, you had to manually balance the inputs/outputs load for an Oracle database
across many discrete disk drives. Today, with larger storage requirements and the use of
RAID, you can easily allow the storage subsystem to distribute the I/O load evenly across
a group of disk drives. You must determine only what RAID level to use. When deciding
the RAID level for Oracle datafiles, there are a few critical factors:
• Space requirements
• Input/outputs per second (IOPS) and megabytes per second (MBps)
• Disk utilization (the amount of usable disk drive space)
Data Files
Oracle databases place information on physical files on the storage subsystem.
• The database requests data on disk drive.
• The storage subsystems serves the data to the database processes.
Depending on the application and the configuration of the database, I/O requests might
arrive at varying intervals and for varying amounts of data. This is known as application
mix. For a complete discussion of application mixes in tuning Oracle, refer to: Tuning
Oracle with Consideration for Storage Subsystem and Your Application Mix.
As a database administrator, you are responsible for configuring the storage subsystem so
it serves the desired I/O rates. You must carefully monitor the datafile level to avert
potential hot spots within the storage subsystem. If a datafile, or a set of datafiles, begins
to reach the performance level of your configured storage subsystem, you must
reconfigure or move the datafiles.
To find those tablespaces and the physical datafile names that are performing large
amounts of reads and writes, use this SQL command:
select vtablespace.name tablespace_name,
vdatafile.name datafile_name,
vfilestat.phyrds physical_reads,
vfilestat.phywrts physical_writes,
vfilestat.avgiotim average_time_for_io
from v$datafile vdatafile,
v$filestat vfilestat,
v$tablespace vtablespace
where vdatafile.file# = vfilestat.file#
and vdatafile.ts# = vtablespace.ts#;
For a clear picture of the I/O activity on a set of datafiles, use the previous SQL command
periodically.
If there is no direct relationship between the Oracle objects stored in the underlying data
files, you can initially place these data files in the same RAID group and then monitor for
contention or for reaching physical storage subsystem limits such as IOPS and MBps.
Redo log files contain the changes that are made to a database and are used when needed
for recovery. Redo logs are constantly in use for writing and can at times become a
contentious point in the database and on the storage array.
Redo logs must be protected by RAID as these files are at the core of recovery procedures.
Consider a RAID 1 or RAID 1+0 for redo logs. These RAID provide the fast I/O that redo
logs require so as to not bottleneck the system as they record all changes.
to_char(sum(decode(substr(to_char(first_time,'HH24'),1,2),'16',
1,0)),'99') “16”,
to_char(sum(decode(substr(to_char(first_time,'HH24'),1,2),'17',
1,0)),'99') “17”,
to_char(sum(decode(substr(to_char(first_time,'HH24'),1,2),'18',
1,0)),'99') “18”,
to_char(sum(decode(substr(to_char(first_time,'HH24'),1,2),'19',
1,0)),'99') “19”,
to_char(sum(decode(substr(to_char(first_time,'HH24'),1,2),'20',
1,0)),'99') “20”,
to_char(sum(decode(substr(to_char(first_time,'HH24'),1,2),'21',
1,0)),'99') “21”,
to_char(sum(decode(substr(to_char(first_time,'HH24'),1,2),'22',
1,0)),'99') “22”,
to_char(sum(decode(substr(to_char(first_time,'HH24'),1,2),'23',
1,0)),'99') “23”
from v$log_history
group by to_char(first_time,'YYYY-MM-DD');
Check for hours that have a high number of switches, and then check the size of your redo
logs. Examine the disk drive area where the redo logs and archive logs are being written to
make sure that the disk drives can handle the amount of I/O hours when there are high
numbers of switches.
Use the recommended optimal logfile size value to rebuild the redo log groups.
Oracle control files contain vital information on the configuration of an Oracle instance.
Control files are continually being updated to record specific recovery information.
Typically the disk drive placement of these control files is not an issue, but you should
monitor resource waits and make corrections as required.
Initialization Files
Oracle also maintains an initialization file that contains configurable parameters. This file
takes two forms, either an SPFILE or an INIT file. The use of this file does not cause any
disk drive contention within Oracle.
Database Objects
Oracle sessions have only two major functions when attached to an Oracle database:
• To read (SELECT) information from objects
• To write (INSERT, UPDATE, or DELETE) from objects
The two most common objects that Oracle sessions read and write from are tables and
associated indexes. The storage allocation associated with tables and indexes is
represented in Oracle through logical structures called segments.
If you monitor the activity of reads and writes through segments, you gain a better
understanding of how Oracle is performing on the storage array.
With segment-level statistics, you can determine where problem areas for particular
objects reside and take appropriate action. To collect segment level statistics, you must set
the STATISTICS_LEVEL parameter to TYPICAL or all. Oracle keeps segment-level
statistics associated with segments in three views.
View Description
V$SEGSTAT_NAME Reference view describing each of the segment level statistics collected.
Two of the statistics in the V$SEGSTAT_NAME view are only sampled
while the others are accumulated. The STATISTICS# view is not the
same as in the V$STATNAME view.
V$SEGSTAT Highly efficient view for real time monitoring of segment level statistics.
V$SEGMENT_STATISTICS User-friendly view for segment level statistics. It is the same as the
V$SEGSTAT view but with easily recognizable object properties such as
owner and segment_name.
If you see a large amount of time awaited for reads, writes, or buffer activity, you might
want to further investigate the database objects related to this I/O by querying the
V$SEGMENT_STATISTICS view.
The following example SQL helps you determine which objects are producing read- or
write-performance problems. To find different wait events, replace the
statistic_name comparison in the WHERE clause.
select owner,object_type,object_name,value
from V$SEGMENT_STATISTICS
where (statistic_name like '%read%'
or statistic_name like '%write%')
order by value desc
Tablespaces are the links between database objects and data files out on disk drive.
Tablespaces have the following attributes:
• Hold and group various database objects for ease of management.
• Contain one or many database objects, which have storage requirements through
segments.
• Store one or many physical database files on a disk drive.
• Link between the logical database objects and to the physical blocks on a disk drive.
Consider these attributes when designing tablespaces, the objects they hold, and the
location where they will be placed on disk drive.
For example, placing the two most accessed tables, with their indexes, in one tablespace
will cause problems:
• They would occupy the same relative areas on disk drive.
• They would likely produce contention on the storage array.
Follow these basic guidelines for tablespace design:
• Spread potential hot objects through different tablespaces.
• Do not put similar objects in the same tablespace. To improve performance, place two
objects that are used in the same SQL query in different tablespaces and at different
locations on disk drive.
• Do not put an object’s indexes in the same tablespace as the object.
• Put similarly accessed objects together to allow for easy placement on a disk drive that
will have the same configuration (RAID level, caching, segment size, and similar
attributes).
• Put similarly maintained objects together to allow for maintenance at the tablespace
level.
• Watch for volatile objects and do not place them in the same tablespaces as stable
objects. For instance if an application creates and drops objects regularly, dedicate a
tablespace for its operations.
The previous SQL shows you the average time it takes for an I/O transaction. If the I/O
time is unacceptable, investigate for contention on the underlying disk drives and consider
reconfiguring disk drives.
SYSTEM Tablespace
The SYSTEM tablespace is a special tablespace that contains information about the current
instance and database. The SYSTEM tablespace contains the data dictionary, which
consists of tables that define every object created. Do not place user-defined objects in this
tablespace. User-defined objects in the SYSTEM tablespace is almost always the cause of
issues with the SYSTEM tablespace or its underlying physical data file.
TEMPORARY Tablespace
The TEMPORARY tablespace sorts and holds temporary segments when a user runs an
SQL statement requiring sorting or does database maintenance that creates temporary
segments. A user’s TEMPORARY tablespace for sorting is assigned in one of three ways.
• Default tablespace is assigned to the user.
• A default TEMPORARY tablespace is assigned for the entire database.
• A TEMPORARY tablespace is group assigned.
Undo Tablespace
The Oracle UNDO tablespace is used to store critical information for the possibility that a
ROLLBACK command will be issued, and changes made after the last COMMIT point will
be backed out. UNDO is also used to recover a database from failure by applying undo
records to roll back any uncommitted changes. The UNDO records also provide read-
consistency to satisfy a result set that is guaranteed at the time you issue data manipulation
language (DML) commands in relation to other user’s changing data mid-stream of your
result set. You might face a problem with the UNDO tablespace if the undo that you have
created can not provide sufficient consistency and recovery for the transaction mix on
your database system.
Use the Undo Advisor to answer questions on how the undo configuration is performing
for current work loads. Here is a sample of function calls to the Undo Advisor package,
DBMS_UNDO_ADV.
Function Description
undo_info Basic UNDO information:
Tablespace Name
Current retention value
If undo is auto extensible
If undo is guaranteed undo retention
longest_query Longest running query. Use the LONGEST_QUERY function to
tune in relation to time.
required_retention Retention value is based on the longest running query. Use the
REQUIRED_RETENTION function to determine how to set the
UNDO_RETENTION function to help prevent snap-shot-too-old
errors.
best_possible_retention Undo_retention that best fits your parameters. Use the
BEST_POSSIBLE_RETENTION function to determine the
best undo fit for your current undo tablespace size and usage.
required_undo_size Size of the undo tablespace needed for INIT.ORA parameter
UNDO_RETENTION.
undo_health Any problems encountered with your current undo tablespace
size or setting of the init.ora parameter undo_retention and
recommendations for fixing.
undo_advisor Descriptive output on any problems encountered and possible
resolutions.
undo_autotune Undo_auto tuning for undo retention can be either enabled or
disabled.
rbu_migration Size required for undo tablespace size. Use rbu_migration
information for switching to automatic undo management.
You might want to migrate databases to automatic undo management. See Oracle
documentation for procedure to migrate databases to automatic undo management: http://
www.oracle.com/technology/software/tech/orion/index.html.
If you migrate databases to automatic undo management, you should still occasionally
review the undo area and verify the I/O requirements of this tablespace.
Conclusion
A clear understanding of how Oracle objects map to the physical files on a storage array is
essential for tuning an Oracle database and the underlying storage array. By pinpointing
activity on Oracle objects through monitoring of Oracle segments, you can detect and
reduce contention, and improve database performance. Because the physical operating
system files map to Oracle logical structures at the segment level, you can monitor the
segments associated with database objects. To improve the performance of the storage
subsystem, use the mapping to identify problems and ultimately tune those aspects of
Oracle that relate to the physical data files on the storage subsystem.
Examining RAID levels, redo logs and tablespace provide you with a better understanding
of how database files impact system performance. You can then use this information to
tune Oracle and the underlying storage subsystem.
Whenever you increase database performance through structures that interface with the
storage, you experience performance gains on the storage array.
Contact Information
For more information and sales office locations, visit the IBM web sites at:
http://www.ibm.com
Product data has been reviewed for accuracy as of the date of initial publication. Product data is subject to
change without notice. This document could include technical inaccuracies or typographical errors. IBM
may make improvements and/or changes in the product(s) and/or program(s) described herein at any time
without notice. Any statements regarding IBM's future direction and intent are subject to change or
withdrawal without notice, and represent goals and objectives only. References in this document to IBM
products, programs, or services does not imply that IBM intends to make such products, programs or
services available in all countries in which IBM operates or does business. Any reference to an IBM
Program Product in this document is not intended to state or imply that only that program product may be
used. Any functionally equivalent program, that does not infringe IBM's intellectually property rights, may
be used instead.
THE INFORMATION PROVIDED IN THIS DOCUMENT IS DISTRIBUTED "AS IS" WITHOUT ANY
WARRANTY, EITHER EXPRESS OR IMPLIED. IBM EXPRESSLY DISCLAIMS ANY WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. IBM
shall have no responsibility to update this information. IBM products are warranted, if at all, according to
the terms and conditions of the agreements (e.g., IBM Customer Agreement, Statement of Limited Warranty,
International Program License Agreement, etc.) under which they are provided. Information concerning
non-IBM products was obtained from the suppliers of those products, their published announcements or
other publicly available sources. IBM has not tested those products in connection with this publication and
cannot confirm the accuracy of performance, compatibility or any other claims related to non-IBM products.
IBM makes no representations or warranties, expressed or implied, regarding non-IBM products and
services.
The provision of the information contained herein is not intended to, and does not, grant any right or license
under any IBM patents or copyrights. Inquiries regarding patent or copyright licenses should be made, in
writing, to:
AIX*, IBM logo*, DB2 Universal Database*, IBM eServer*, Magstar*, OS/390*, OS/400*, e-business
logo*, ESCON*, FICON*, IBM*, S/390*, Tivoli*, TotalStorage*, WebSphere*, iSeries*, pSeries*,
xSeries*, xSeries*, System Storage*
Intel is a trademark of the Intel Corporation in the United States and other countries.
Java and all Java-related trademarks and logos are trademarks or registered trademarks of Sun
Microsystems, Inc., in the United States and other countries.
Lotus, Notes, and Domino are trademarks or registered trademarks of Lotus Development Corporation.
Linux is a registered trademark of Linus Torvalds.
Microsoft, Windows and Windows NT are registered trademarks of Microsoft Corporation.
SET and Secure Electronic Transaction are trademarks owned by SET Secure Electronic Transaction LLC.
UNIX is a registered trademark of The Open Group in the United States and other countries.
Notes:
Performance is in Internal Throughput Rate (ITR) ratio based on measurements and projections using
standard IBM benchmarks in a controlled environment. The actual throughput that any user will experience
will vary depending upon considerations such as the amount of multiprogramming in the user's job stream,
the I/O configuration, the storage configuration, and the workload processed. Therefore, no assurance can
be given that an individual user will achieve throughput improvements equivalent to the performance ratios
stated here.
IBM hardware products are manufactured from new parts, or new and serviceable used parts. Regardless,
our warranty terms apply.
All customer examples cited or described in this presentation are presented as illustrations of the manner in
which some customers have used IBM products and the results they may have achieved. Actual
environmental costs and performance characteristics will vary depending on individual customer
configurations and conditions.
This publication was produced in the United States. IBM may not offer the products, services or features
discussed in this document in other countries, and the information may be subject to change without notice.
Consult your local IBM business contact for information on the product or services available in your area.
All statements regarding IBM's future direction and intent are subject to change or withdrawal without
notice, and represent goals and objectives only.
Information about non-IBM products is obtained from the manufacturers of those products or their
published announcements. IBM has not tested those products and cannot confirm the performance,
compatibility, or any other claims related to non-IBM products. Questions on the capabilities of non-IBM
products should be addressed to the suppliers of those products.
Prices subject to change without notice. Contact your IBM representative or Business Partner for the most
current pricing in your geography.
TSW03008-USEN-00