Professional Documents
Culture Documents
Objectives
This lesson introduces you to tuning methodologies. By applying a tuning methodology, you can
optimize performance and improve response time and scalability. Tuning is an ongoing process
in the life cycle of a project that must start in the development phase and continue through the
maintenance phase.
This lesson shows you the different steps in tuning SQL and the various methods available for
each step. It also introduces different tools that can be used in each step. Subsequent lessons
discuss each of the steps and tools in greater detail.
Performance Problems
Performance problems occur when a task takes longer to perform than the time allowed and uses
excessive resources. Usually problems occurs when the the supply of a resource is insufficient to
meet the demand. The resource may be a physical resource (such as available memory buffers
that store data blocks) or a nontangible resource (such as a lock). Possible causes of performance
problems are the following.
Inadequate Consumable Resources
Sometimes a resource may simply be inadequate to meet the need under any circumstances. For
example, if you want a function to complete in less than one second, a network with a message
turnaround time of two seconds will never meet the target.
If the limiting factor is a consumable resource (such as CPU power), all the users of that resource
are affected.
High-Load SQL
In some cases, a single SQL statement may take up a large amount of resources, thereby
affecting the performance of other statements.
Contention
If many users are trying to update the same set of tables, contention due to locking might be a
problem.
• Schema
– Data design
– Indexes
• Application
– SQL statements
– Procedural code
• Instance
• Database
• User expectations
• Hardware and network tuning
Factors to Be Managed
Performance management can be divided into the following four areas. Although the areas are
separate, they are also interdependent and require different skill sets.
Schema tuning deals with the physical structure of the data. If an application has inadequate or
inappropriate data design, then tuning the physical allocation, providing indexes, or rewriting
programs will not overcome the problem.
Application tuning deals with such business requirements as 24/7 availability, OLAP, OLTP,
and so on as well as the program modules or applications that implement the functions. Tuning
the procedural code for the type of application and tuning the embedded SQL statements are also
included in this factor. If an application is well designed, it may still perform badly. A common
reason for this is badly written SQL.
Instance tuning deals with the configuration of the Oracle server for memory utilization.
Database tuning deals with managing the physical arrangement of data on the disk.
Tuning Goals
The goal of tuning a system is either to reduce the response time for end users or to reduce the
resources used to process the same work. You can accomplish both of these objectives in several
ways:
• Reduce the workload: SQL tuning commonly involves finding more efficient ways to
process the same workload. It is possible to change the execution plan of the statement
without altering the functionality to reduce the resource consumption. Two examples of
how resource usage can be reduced are:
- If a query needs to access a small percentage of data in the table, this can be executed
more efficiently by using an index. By creating such an index, you reduce the amount
of resources used.
- If a user is looking at the first 20 rows of the 10,000 rows returned in a specific sort
order, and if the query (and sort order) can be satisfied by an index, then the user does
not need to access and sort the 10,000 rows to see the first 20 rows.
Identify high-load or
problematic SQL
Manual Tuning
The steps involved in tuning SQL manually are listed in the slide. The following slides cover
these steps in detail.
• Stored outlines
• Stored statistics
• Locking statistics
Summary
Applying a tuning methodology to your design and efforts optimizes performance. Tuning SQL
is a major component of a tuning methodology.
After completing this lesson, you should be able to:
• State the procedural steps in managing performance
• Describe the causes of performance problems
• Identify the main system areas that you can address by using the tuning process
• Describe the tuning methodology
• Explain the advantage of following the steps of the tuning methodology in their proper
sequence
• List the tuning steps that are the responsibility of the application developer
Anyone involved in tuning should follow a tuning methodology to achieve maximum
performance. Tuning SQL statements is an important step that is least expensive when
performed at the proper point in the overall tuning methodology.
Summary (continued)
Tuning SQL statements involves the effective use of analysis tools, SQL tuning techniques, and
the optimizer. In addition, tuning the schema can create additional access paths for the optimizer,
such as the use of an index.