QuestSQLOptimizerForOracle UserGuide PDF
QuestSQLOptimizerForOracle UserGuide PDF
1
User's Guide
-1-
© 2008 Quest Software, Inc.
This guide contains proprietary information protected by copyright. The software described in this guide is
furnished under a software license or nondisclosure agreement. This software may be used or copied only in
accordance with the terms of the applicable agreement. No part of this guide may be reproduced or transmitted in
any form or by any means, electronic or mechanical, including photocopying and recording for any purpose other
than the purchaser’s personal use without the written permission of Quest Software, Inc.
If you have any questions regarding your potential use of this material, please contact:
Disclaimer
Disclaimer: The information in this document is provided in connection with Quest products. No license, express or
implied, by estoppel or otherwise, to any intellectual property right is granted by this document or in connection
with the sale of Quest products. EXCEPT AS SET FORTH IN QUEST'S TERMS AND CONDITIONS AS SPECIFIED IN
THE LICENSE AGREEMENT FOR THIS PRODUCT, QUEST ASSUMES NO LIABILITY WHATSOEVER AND DISCLAIMS
ANY EXPRESS, IMPLIED OR STATUTORY WARRANTY RELATING TO ITS PRODUCTS INCLUDING, BUT NOT LIMITED
TO, THE IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-
INFRINGEMENT. IN NO EVENT SHALL QUEST BE LIABLE FOR ANY DIRECT, INDIRECT, CONSEQUENTIAL, PUNITIVE,
SPECIAL OR INCIDENTAL DAMAGES (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF PROFITS,
BUSINESS INTERRUPTION OR LOSS OF INFORMATION) ARISING OUT OF THE USE OR INABILITY TO USE THIS
DOCUMENT, EVEN IF QUEST HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. Quest makes no
representations or warranties with respect to the accuracy or completeness of the contents of this document and
reserves the right to make changes to specifications and product descriptions at any time without notice. Quest
does not make any commitment to update the information contained in this document.
Trademarks
Quest, Quest Software, the Quest Software logo, Tuning Lab, Benchmark Factory, Quest Central, Spotlight, SQL
Navigator, Toad, T.O.A.D. are trademarks and registered trademarks of Quest Software, Inc. Other trademarks
and registered trademarks used in this guide are property of their respective owners.
Quest Software, Inc., Microsoft’s Global Independent Software Vendor Partner of the Year, delivers innovative
products that help organizations get more performance and productivity from their applications, databases and
infrastructure. Through a deep expertise in IT operations and a continued focus on what works best, Quest helps
more than 18,000 customers worldwide meet higher expectations for enterprise IT. Quest Software lets
organizations deliver, manage and control complex database environments through award-winning products for
Oracle, SQL Server, IBM DB2, Sybase, and MySQL. Quest Software can be found in offices around the globe and at
http://www.quest.com.
Quest Support is available to customers who have purchased a commercial version and have a valid maintenance
contract or who have a trial version of Quest software. Quest Support provides around the clock coverage with
SupportLink, our web self-service. Visit SupportLink at: http://support.quest.com
Table Of Contents
Quest SQL Optimizer Overview .................................................................................................................... 1
Performance Assurance Process ................................................................................................................... 2
Database Privileges .................................................................................................................................... 4
Batch Optimizer Overview ........................................................................................................................... 6
Batch Optimizer Tutorial.............................................................................................................................. 8
SQL Scanner Overview.............................................................................................................................. 10
SQL Scanner Tutorial ................................................................................................................................ 11
SGA Inspector Overview ........................................................................................................................... 13
SGA Inspector Tutorial .............................................................................................................................. 14
Tuning Lab Overview ................................................................................................................................ 16
SQL Optimizer Overview ........................................................................................................................... 17
SQL Optimizer Tutorial .............................................................................................................................. 19
Deploy Outline Tutorial ............................................................................................................................. 20
Index Expert Overview.............................................................................................................................. 21
Index Expert Tutorial ................................................................................................................................ 22
Index Impact Analysis Tutorial ................................................................................................................... 23
Best Practices Tutorial .............................................................................................................................. 24
Global Indexing Overview .......................................................................................................................... 25
Global Indexing Tutorial ............................................................................................................................ 26
Impact Analyzer Overview ......................................................................................................................... 27
Save SQL Statements to Impact Analyzer Tutorial ........................................................................................ 29
Impact Analyzer Tutorial ........................................................................................................................... 29
Outline Manager Overview ......................................................................................................................... 32
Outline Manager Tutorial ........................................................................................................................... 33
Options Settings ...................................................................................................................................... 34
Quest SQL Optimizer for Oracle – Users Guide
Quest SQL Optimizer for Oracle maximizes SQL performance by automating the manual, time-intensive, and
uncertain process of ensuring that SQL statements are performing as fast as possible. Quest SQL Optimizer
automatically analyzes, rewrites, and evaluates SQL statements within multiple database objects, files, or
collections of SQL statements from the SGA. The process of optimizing problematic SQL from multiple source code
locations is completely automated. Whether you are a developer, DBA, or performance tuner, you can just let
Quest SQL Optimizer for Oracle analyze and optimize in batch all problem SQL from multiple sources and then
Quest SQL Optimizer will provide you with the replacement code which includes the optimized SQL statements.
Quest SQL Optimizer also provides you a complete index optimization and plan change analysis solution, from
index recommendations for multiple SQL statements to simulated index impact analysis, through comparison of
multiple SQL execution plans.
Quest SQL Optimizer consists of the following:
Batch Optimizer
The Batch Optimizer enables you to submit files, database objects, text, or a Performance Analysis SQL repository
for batch processing. It first scans the code to extract the SQL statements, then optimizes the SQL statements and
tests the SQL alternatives to find the best performing SQL for your database environment. It provides the
replacement code with the optimized SQL statements.
SQL Scanner
The SQL Scanner identifies SQL statements from source code and database objects without requiring the execution
of the SQL statements. Once the SQL statements are identified, the SQL Scanner analyzes and categorizes them
according to suspected levels of performance problems.
SGA Inspector
The SGA Inspector offers an easy way to view and analyze previously executed and currently running SQL
statements from Oracle’s system global area (SGA). You can specify your own criteria to retrieve the SQL
statements and their corresponding statistics to review SQL performance.
Tuning Lab
The Tuning Lab contains the SQL Optimizer, the Index Expert, Deploy Outline, Test for Scalability and Best
Practices along with the testing of the alternative SQL statements and the index candidates.
The SQL Optimizer automates the optimization of SQL statements. It first analyzes the original SQL statement
and then exhaustively rewrites the syntax of the SQL statement and apply the Oracle optimization hints. It
produces a list of semantically equivalent and syntactically correct SQL statements. By test running these SQL
statements, it is then possible to identify which SQL statement best suits the needs of your database
environment.
The execution of the SQL statements enables you to test run the original and optimized SQL statements to
select which SQL statement gives the best performance. The execution times and run time statistics help you
identify which SQL statement is most suitable for the needs your database application environment.
Deploy Outline stores an Oracle stored outline for a specific SQL statement. Oracle will use the stored outline
when executing the SQL statement in place of using the execution plan.
-1-
Quest SQL Optimizer for Oracle – Users Guide
The Index Expert enables you to determine the best possible indexes for your SQL statements. It analyzes the
syntax of a SQL statement and the relation between tables to generate index alternatives. It provides all the
alternative index sets that generate a unique execution plan for a SQL statement. It creates these index sets
without physical creating the indexes in your database.
The performance of a SQL statement with the index candidates can be tested to help you determine which
indexes should be permanently created in your database.
The user workload that SQL statements may encounter can be simulated with Quest Benchmark Factory to see
how the best SQL alternatives will perform under different workload conditions.
Global Indexing
Global Indexing analyzes a group of SQL statements and determines the best common index set for all of those
SQL statements.
Impact Analyzer
The Impact Analyzer helps you to ensure reliable database performance by tracking execution plan and Oracle cost
changes for SQL statements. It keeps track of execution plan changes to allow you to estimate the impact on the
SQL statements' performance due to database changes. You can simulate different database scenarios with a
selected group of SQL statements that will give you a good representation of what will happen if a proposed
database change actually occurred. Or, you can track the actual changes in the execution plan over time or as the
result of actual changes in the database environment.
Outline Manager
The Outline Manager organizes the stored outlines used to improve the performance of SQL statements when you
cannot or do not want to change the SQL syntax in the source code.
Quest SQL Optimizer for Oracle enables you to assure that your SQL statements will run as fast as possible in your
database environment. Use the following process to identify the SQL that needs to be optimized, to find the
alternative SQL statements, and select the best SQL for your application.
1. Identify problematic SQL, optimize SQL statements, and test SQL alternatives
The first step in optimizing a database application is to find which statements are causing the performance
problems. Use the Batch Optimizer to extract embedded SQL statements from your database objects (such as
stored procedures, views, etc), application source code files, or executable files. The scanning process extracts the
SQL statements directly from the source code without requiring you to execute your application.
-2-
Quest SQL Optimizer for Oracle – Users Guide
Note: Dynamic SQL statements, which are not created until the application is executed, can be captured by the
SGA Inspector. For dynamic SQL statements, capture them first with the SGA Inspector and then use the Batch
Optimizer to extract and identify the problematic SQL statements from the Inspector file.
The scanning process, by analyzing the operations in the execution plan, identifies potential performance
bottlenecks such as performing full table scans on large tables or multiple table scans. These thresholds are user-
defined under the SQL Classification definitions. The analysis identifies the problematic SQL that should be
optimization.
The Batch Optimizer automatically optimizes the problematic and complex SQL to find alternative SQL statements
that have unique execution plans. The optimization process explores all possible ways to rewrite the original SQL
statement. First, the syntax of the SQL statement is analyzed along with the tables and indexes and it is rewritten
to provide all the SQL alternatives that produce the exact same result. It applies the optimization hints that are
specific to Oracle, such as ALL_ROWS, HASH, and ORDERED. The use of these Oracle hints is optional.
Once the optimization process has generated all the semantically equivalent SQL alternatives, the Batch Optimizer
determines which one is the most efficient for your database environment by executing the original SQL statement
and the SQL alternatives. It generates a script that you can use to replace the original SQL statement with the
better performing alternatives.
Note: You can also use the SQL Scanner module to extract and identify problematic SQL. Then you can use the
SQL Optimizer and Execute function in the Tuning Lab to generate the SQL alternatives and to test them.
In the Tuning Lab, use the Compare Scenario layout after the original SQL statement is optimized to view side-by-
side the alternative SQL statements in order to learn what alternate SQL syntax accomplishes the same result.
Also, view the execution plans side-by-side to improve your knowledge of how Oracle executes a SQL statement
based on the SQL syntax. Use the context sensitive help for each keyword in the execution plan to further your
understanding of execution plan steps.
Once you have found the best SQL for your application, copy the SQL alternative to the source code. You can also
create a report in the Tuning Lab or the Batch Optimizer with the alternative SQL statements and execution plans.
Note: The Batch Optimizer will create a replacement script for you.
If optimizing a SQL statement does not improve the performance enough to meet your performance requirements,
index alternatives can be generated for a single SQL statement with the Index Expert in the Tuning Lab or for a
group of SQL statements with Global Indexing to further enhance the database performance.
You can predict the performance changes to your database before you migrate to another database, make
configuration changes, or add new indexes. You can also track the changes that take place in the performances of
SQL statements as the result of changes like updating database statistics, changes in data volume, or program
upgrades.
You can use Oracle stored outlines to improve the performance of SQL statements when you cannot replace the
original SQL statement in your source. In the Tuning Lab, you can deploy an outline after you have optimized a
SQL statement and then use the Outline Manager to organize your stored outlines.
-3-
Quest SQL Optimizer for Oracle – Users Guide
Database Privileges
Oracle database privileges limit the access of individual users. The following lists the functionality that requires
specific Oracle database privileges. If you do not have one of these privileges, you can still use the functionality in
the other features of the program.
-4-
Quest SQL Optimizer for Oracle – Users Guide
-5-
Quest SQL Optimizer for Oracle – Users Guide
The Batch Optimizer combines the scanning of source code, the optimization of SQL statement, and testing of the
SQL alternatives with the original SQL into one simple process. So, it automates the whole process of identifying
problematic SQL in your database application, rewriting the SQL statements, and executing the original SQL
statement along with the alternative SQL statements to find the fastest alternative. Then it creates a script from
your original source code in which the slower SQL statements are replaced with better performing SQL alternatives.
To start the process, you must a add a job to a batch. A job consists of text which is expected to contain one or
more SQL statements. A job may be a block of text, a database object, an ASCII file, a binary file, a SQL Scanner
job, a SGA Inspector job, or a Performance Analysis SQL repository.
You can use the Add Batch Optimizer Jobs wizard to put the jobs into a batch. You can also submit a job to the
Batch Optimizer from other Quest products, such as Toad, SQL Navigator, Performance Analysis, or Spotlight. You
can submit a SQL statement from the SQL Text window of the SGA Inspector or the SQL Scanner.
Scanning
The first step of the Batch Optimizer process is to scan through the text in each job to find the INSERT, UPDATE,
DELETE, and SELECT SQL statements. This scanning process works exactly the same as the scanning process in
the SQL Scanner.
Optimization
The second step of the Batch Optimizer process is to optimize the SQL statements that were found during the
scanning process. This optimization is the same process that is used in the SQL Optimizer.
-6-
Quest SQL Optimizer for Oracle – Users Guide
Execution
The third step of the Batch Optimizer process is to execute the original SQL statement and the alternative
statements to see if any of the SQL alternatives outperform the original SQL statement.
If a SQL statement has a bind variable, it is not executed until you enter the value for the variable.
You may select to execute the SQL statements in a different schema or using a different database connection from
the one used for the scanning and optimizing processes.
After the SQL alternatives are executed, if one of the alternatives is faster than the original SQL statement then a
replacement script can be generated. This script is a copy of the original text that was scanned with the poor
performing SQL statements replaced with the best SQL alternatives. You can then take this script and replace the
code in the database object or application source code file.
Options Settings
The Batch Optimizer process can be fully automated by using the settings in the Batch Optimizer options. Or, can
manually control the process.
Scanning Options
Jobs will be automatically scanned as soon as they are placed in a batch if you select the Automatically start
extracting SQL when job is added setting.
The jobs are scanned using the settings in the SQL Scanner settings.
Optimizing Options
When the scanning process is finished, the optimization process can automatically be started based on the SQL
classification that you select in the SQL to automatically optimize setting. For example, if you select Problematic,
only those SQL statements that are classified as Problematic will automatically be optimized. If you do not select
any of the SQL classifications, then you must manually select each SQL statement you would like optimized.
The SQL statements are optimized using the Optimizer settings.
Executing Options
When the optimization process is finished, the execution of the original SQL statement and the selected
alternatives are automatically started if you select one type of SQL statement under the Types of SQL statement
to execution automatically after optimization option.
The SQL alternative that are executed are determined by these settings.
SQL type to execute—The Types of SQL statement to execution automatically after optimization enables
you to select whether the INSERT, UPDATE, DELETE, or SELECT statements are automatically executed.
SQL alternatives to execute—The Number of SQL alternatives to select as the representatives and Execute
these additional SQL alternatives settings determine which SQL alternatives are to executed.
When executing the SQL statements in the Batch Optimizer, the default execution method is Run on server. By
that, it is meant that all SQL statements are executed on the server and do not return the data from the SELECT
statements to the client. Executing the SQL statements with this method provides you with the run time on the
CPU for the SQL statement. Using this method, your logon account must have the SYS.DBMS_SQL package
privilege to retrieve the run time from the server.
-7-
Quest SQL Optimizer for Oracle – Users Guide
The best alternative is selected based on the Total elapsed time or the First row elapsed time in the Best SQL
Alternative Selection Criteria setting. The Total elapsed time is how long it takes to retrieve all the records
returned by a SELECT statement. The First row elapsed time is how long it takes to retrieve only the first record.
The Batch Optimizer combines the scanning, the SQL optimization, and testing of the SQL alternatives with the
original SQL into one simple process. So, it automates the whole process of identifying problematic SQL in your
database application, rewriting the SQL statements, and executing the original SQL statement along with the
alternative SQL statements to find the fastest alternative. Then it creates a script from your original source code in
which the problematic SQL is replaced with a better SQL alternative.
1. Click the Batch Optimizer tab.
2. In the Batch Job List window, click Add Code to Optimize and select All Types to
open the Add Batch Optimizer Jobs wizard so you can select which files, database objects, SQL Scanner
files, SGA Inspector files, text, or Performance Analysis SQL repository you want to scan for and optimize
the SQL statements that are found.
Connection page
a. In the Connection box, click Down Arrow to select a previously created database connection or
click Ellipsis to create a new connection.
Database Objects page
b. Expand the database user branch in the Database Objects box.
c. Highlight the schema, a database object type, or an individual database object, and click Add
Database Objects to move the item to the Select Objects box. (Whether or not you can scan
all of the selected database objects depends on your database privileges.)
Source Code page
d. Click the Text or binary files, Oracle SQL*Plus scripts, or COBOL programming source code option.
l. Click Add selected Scanner jobs to move the Scanner jobs to the Selected Scanners box.
m. Set the schema in the Scan using Schema list to correspond with the SQL that you are scanning.
The scanning process will use this schema and not the database connection that is associated with the
Scanner group you select in step a.
SGA Inspector page
n. In the Group box, select the Inspector group which contains the SQL statement you want to scan to
identify the problematic SQL.
-8-
Quest SQL Optimizer for Oracle – Users Guide
p. Click Add selected Inspector jobs to move the Inspector to the Selected Inspectors box.
q. Set the schema in the Scan using Schema list to correspond with the SQL that you are scanning.
The scanning process will use this schema and not the database connection that is associated with the
Inspector group you select in step a.
Performance Analysis page
r. Click Check for PA Repository.
s. Check Add the PA Repository as a job checkbox.
t. Enter the selection criteria for the SQL statement you would like to extract.
Batch Info page
u. Select Create a new batch.
v. In the Batch Name box, enter a name.
3. After you have made all your selections in the Add Batch Optimizer Jobs wizard, click Finish.
4. The Batch Optimizer will automatically start scanning the jobs that you created.
Note: The scanning automatically starts when the Automatically start extracting SQL when job is
added option is checked on the Batch Optimizer | Options page. The option is checked by default.
5. The SQL statements that are classified as Problematic or Complex will automatically start optimizing after
the scanning process is finished.
Note: Which SQL statements are optimized is determined by the SQL classifications selected in the SQL to
automatically optimize option on the Batch Optimizer | Options page. By default, the Problematic and
Complex SQL are optimized.
6. After the SQL statements are optimized, the original SQL statement and some of the alternatives SQL
statements are executed.
Note: The specific SQL statements that are executed is determined by the option selected under the
Number of SQL alternatives to select as the representatives and the Execute these additional SQL
alternatives settings on the Batch Optimizer | Execution | Auto Execution Options page.
7. You can review the details of the an optimized SQL statement in the Tuning Lab module by clicking the
row for the SQL statement in the SQL List window and clicking Open in Tuning Lab .
8. If a faster SQL alternative is found for a SQL statement, you can generate a replacement script for the
source code by click the job in the Job List window and clicking Generate Optimized Script . Review
the script before using it to replace your original source code.
-9-
Quest SQL Optimizer for Oracle – Users Guide
Database applications typically contain thousands of SQL statements that may need to be optimized for better
performance. Without the SQL Scanner, you have to find and extract each SQL statement manually — a very
tedious and time-consuming task. Once you have found the SQL statements, you need to analyze the execution
plan of each SQL statement to see if the execution plan represents a potential performance problem. The SQL
Scanner relieves you of this tedious task.
The SQL Scanner extracts SQL statements embedded in database objects, captured from the SGA, stored in
application source code and binary files, or saved in a Performance Analysis SQL repository. It retrieves and
analyzes the execution plans for the extracted SQL statements. It then categorizes the SQL statements according
to the complexity of the execution plan and determines whether it has the characteristics that typically cause
performance problems. The SQL Scanner allows you to quickly review SQL statements in existing code and detect
potential problems. With this approach, you can be proactive in the detection of performance problems and identify
the SQL statements that need to be optimized without executing the applications.
Once the problematic SQL statements have been identified, you can determine the best solution by
- 10 -
Quest SQL Optimizer for Oracle – Users Guide
Each item that is scanned is referred to as a "job" which can be a database object, text file, binary file, SGA
Inspector file, or Performance Analysis SQL repository.
The Scanning options allow you to include SQL statements that are found in a comment or that use only the
SYS.DUAL table. If your code has tags at the beginning of each line, you can have the scanning process skip them.
You can specify a continuation character if your code uses one at the end of each line of a SQL statement that is
displayed on several lines. And you can specify that it searches for the whole word when it looks for the INSERT,
UPDATE, DELETE, and SELECT statements, so that it does not try to build a SQL statement when it finds text like
UPDATERECORD.
Use the SQL Scanner to analyze SQL statements embedded within database objects, text/binary files, SGA
Inspector files, and application source codes. The SQL Scanner extracts each SQL statement embedded within the
scanned database objects and files, retrieves their respective execution plans from Oracle, and then performs an
analysis that determines which of these SQL statements are likely to contain performance bottlenecks. You can
send the SQL statements analyzed as problematic (top priority) or complex (second priority) to the Tuning Lab or
Batch Optimizer to provide alternative SQL statements that may improve the performance and/or examine the
extracted SQL statements with their execution plans.
Best Practices: An effective use of the SQL Scanner is to review existing code to proactively identify the SQL
statements that can potentially cause performance problems without the need of executing the applications. In this
way, you can prevent performance degradation.
Another effective use of the SQL Scanner is to locate the SQL that is causing performance problems in your
applications. For example, if you know that you have a slow running report, you can scan the program text or
binary file to extract the SQL statements that it contains without having to execute it. The SQL Scanner identifies
SQL statements that are likely to create performance problems. You can then use the Tuning Lab or Batch
Optimizer to provide alternative SQL statements that may improve the performance.
1. Click the Scanner tab.
3. Click Add Scanner Jobs to open the Add Scanner Jobs wizard so you can select which files, database
objects, or SGA Inspector files you want to scan.
4. In the Add Scanner Jobs wizard, click Next until you are at the page for the item that you want to scan.
Database Objects page
a. Expand the database user branch in the Database Objects box.
b. Highlight the schema, a database object type, or an individual database object, and click Add
Database Objects to move the item to the Select Objects box. (Whether or not you can scan
all of the selected database objects depends on your database privileges.)
Source Code page
c. Click the Text or binary files, Oracle SQL*Plus scripts, or COBOL programming source code option.
i. Click Add SGA Inspector to move the Inspector to the Selected Inspectors box.
- 11 -
Quest SQL Optimizer for Oracle – Users Guide
j. Set the Scan using Schema in the Schema list to correspond with the SQL that you are scanning.
The scanning process will use this schema and not the database connection that is associated with the
Inspector group you select in step a.
5. After you have made all your selections in the Add Scanner Jobs wizard, click Finish.
- 12 -
Quest SQL Optimizer for Oracle – Users Guide
The SGA Inspector offers an easy way to capture, view, and analyze executed and currently running SQL
statements from Oracle’s system global area (SGA). You can specify your own criteria to determine which SQL
statements and statistics to retrieve from the SGA. Since the information in the SGA is not static, all the SQL
statements and information retrieved are stored on your client computer for you to review now or a later time.
You can schedule the date and time of when the SQL statements and statistics are collected. Then you can identify
the impact of the SQL activities on database performance.
The SQL Scanner can also be used to review the SQL statements after they are collected from the SGA to classify
the SQL statements based on the characteristics of the execution. Once you have identified poor performing SQL
statements, you can use the Batch Optimizer or the SQL Optimizer to rewrite the syntax of the SQL statement to
find a better execution plan.
- 13 -
Quest SQL Optimizer for Oracle – Users Guide
You can retrieve executed SQL statements from the Oracle SQL Area or currently running SQL statements from
Oracle’s open cursor. After you have captured the SQL statements and statistics according to the retrieval criteria
you selected, the SQL statements and their run time statistics are displayed to help you identify the resource
intensive SQL statements. After you have identified these SQL statements, you can then move a specific SQL
statement to the Tuning Lab so you can generate SQL alternatives or index candidates. Or, you can use the SQL
Scanner to enable you to identify potentially problematic SQL statements. You can also use the Add Jobs function
in the Batch Optimizer to automatically optimize all the collected SQL statements.
Note: To retrieve previously executed SQL statements, you must have the privilege to view SYS.V_$SQLAREA, and
either SYS.V_$SQLTEXT_WITH_NEWLINES or SYS.V_$SQLTEXT.
1. Click the SGA Inspector tab.
3. Click Add Inspector Job to open the Add Inspector Job wizard.
4. On the General Information page, select Executed SQL from SQL Area for the Job Type.
5. Enter a Job name.
6. On the Collecting Criteria page, select Top n records and set the Number of records to be displayed
to your desired number.
7. In the First by box, select the statistic to use to extract the SQL statements when you are not displaying
all records. So if you are displaying only 100 records, it will extract the top 100 records based on the
statistic you select in this box.
Note: If you have a large SGA, it will take some time to sort the SQL statements before the extraction is
done.
8. On the SQL Filter page, select the type of SQL statements you want to collect.
9. On the Collection Time page, select Start collecting when you click the Inspect button.
10. On the Statistics page, review the selected statistics and remove any that you do not want collected.
11. Click Finish.
12. Click Inspect to start retrieving the SQL statements and statistics from the Oracle SQL Area.
13. In the SQL Statistics window, review the statistics.
14. The SQL statement in the SQL Text window corresponds to the selected statistics row in the SQL Statistics
Note: To retrieve previously executed SQL statements, you must have the privilege to view SYS.V_$SESSION,
SYS.V_$OPEN_CURSOR, and either SYS.V_$SQLTEXT_WITH_NEWLINES or SYS.V_$SQLTEXT.
1. Click the Inspector tab.
- 14 -
Quest SQL Optimizer for Oracle – Users Guide
3. Click Add Inspector Job to open the Add Inspector Job wizard.
4. On the General Information page, select Currently running SQL for the Job Type.
5. Enter a Job name.
6. On the Session page, select to collect the SQL from the Whole server, a specific Session ID, or a
particular Connection identity.
7. On the SQL Filter page, select the type of SQL statements you want to collect.
8. On the Collection Time page, set the amount of time you want to collect the executing SQL statements.
9. On the Statistics page, review the selected statistics and remove any that you do not want collected.
wizard. If you want to stop the monitor before the specified time, click Abort .
12. Select one SQL statement that you feel should be optimized. In the SQL Text window, click Optimize and
select Optimize in Tuning Lab and then continue from the SQL Optimizer Tutorial, Step 3.
13. If you would like to optimize all the SQL statements in the collection, use the Batch Optimizer Tutorial and
add an Inspector Job to the batch queue.
14. Another way of identifying a problematic SQL statement is to scan the Inspector file using the SQL
Scanner Tutorial.
- 15 -
Quest SQL Optimizer for Oracle – Users Guide
The Tuning Lab contains the SQL Optimizer and the Index Expert along with the testing of the alternative SQL
statements created by the SQL Optimizer and the index candidates generated by the Index Expert.
SQL Optimizer
The SQL Optimizer automates the optimizing of SQL statements. It first analyzes the original SQL statement and
then exhaustively rewrites the syntax of the SQL statement and applies the Oracle optimization hints. It produces a
list of semantically equivalent and syntactically correct SQL statements that produce the same result set as the
original SQL statement.
The execution of the SQL statements enables you to test run the original and optimized SQL statements to select
which SQL statement gives the best performance. The execution times and run time statistics help you identify
which SQL statement is most suitable for the needs of your database application environment.
Index Expert
The Index Expert enables you to determine the best possible indexes for your SQL statements. It analyzes the
syntax of a SQL statement and the relation between tables to generate index alternatives. It provides all the
alternative index sets that generate a unique execution plan for the SQL statement. It creates these index sets
without physical creation of indexes in your database.
The performance of a SQL statement with and without the index candidates can be tested to help you determine
which indexes should be permanently created in your database. This process does create the indexes in your
database.
- 16 -
Quest SQL Optimizer for Oracle – Users Guide
• Toolbar
The Toolbar has the most frequently used commands available for easy selection.
• Header Bar
The Header Bar contains the text links which displays the current selection and selection lists that enable
you to select a layout, to select a Scenario for review, to open a window not currently in the Layout, to
change the Intelligence Levels, and to change the current schema.
• Layout Buttons
Layouts have specific windows grouped together to enable you to quickly enter a SQL statement, compare
the alternative SQL statements and index candidates, and review the results of the testing.
• Tuning Lab Windows
Several windows are provided to help you quickly enter SQL statements and analyze the results of the
optimization and index generation processes.
• Status Bar
The Status Bar displays the progress of the current function and contains the Abort button.
The SQL Optimizer in the Tuning Lab automates the optimization of SQL statements. It employs a unique engine
that uses Artificial Intelligence to generate all the possible SQL alternatives that can be mathematically proven to
be "semantically equivalent" to the original SQL statement which guarantees that the SQL alternatives will produce
the exact same results as the original SQL statement. After the alternatives are generated, you can compare each
SQL statement to any other SQL statements to see the different SQL coding techniques for achieving the same
results. You can then test these alternative SQL statements in your environment to find the best one for your
database environment.
During the optimization of a SQL statement, the SQL Optimizer employs a unique engine that uses Artificial
Intelligence to execute several SQL syntax rules to produce the alternative SQL statements. The first step of this
engine transforms the original SQL statement and produces a group of alternative SQL statements where the
- 17 -
Quest SQL Optimizer for Oracle – Users Guide
syntax was rewritten. Then, the SQL Optimizer rewrites each newly created SQL statement to produce another
group of alternatives. The engine continues rewriting each alternative until all the SQL statements cannot be
rewritten any further or until the user-defined quota for the number of SQL statements generated by syntax
transformation is reached.
One of the syntax transformation rules is illustrated in the following example:
SELECT *
FROM table_a
WHERE table_a.key IN (SELECT table_b.key
FROM table_b)
If table_b.key is an indexed column, the following transformation rule is applied:
SELECT *
FROM table_a
WHERE EXISTS (SELECT 'x'
FROM table_b
In the Optimization settings, you can also control whether the optimization process will merge the SELECT
statement from a VIEW used in the original SQL so that it is rewriting the original SQL and the SELECT statements
from all the views accessed by the SQL statement. You can also specify to include a transformation rule that will
transform the query to an inline view, that is take a subquery and use it as a table in a FROM clause. You can also
select to use the JOIN clause (INNER JOIN, CROSS JOIN) from the Ansi-92 SQL standard or to use the original SQL
syntax for joining tables.
After the SQL Optimizer has exhausted rewriting the syntax of the SQL statement, the Oracle optimization hints
which are selected in the Optimizer options are applied to the original SQL statement and each of the SQL
alternatives until all selected hints have been applied to all the SQL alternatives or until the user-defined quota is
reached.
For each rewritten SQL statement, the execution plan is compared to all the other execution plans. One SQL
alternative is selected for each unique execution plan. Although the optimization process may generate hundreds of
SQL alternatives, you will see only some of the alternatives since the alternatives with a duplicate execution plan
are eliminated.
Although all the SQL alternative statements produce the same result, Oracle will likely use a different path to
retrieve the data for each one. It is difficult to decide which SQL statement will run faster without taking into
account the database structure, indexes, and data volume, so it is important to test the SQL alternatives in your
database environment using the Execute function to determine the best SQL alternative from the run time
statistics.
The settings in the Optimizer options affect the amount of time it takes and the number of alternatives that are
generated by the optimization process. You can quickly select to increase or decrease the intensity of the
optimization process using the Intelligence Level settings to automatically select more or less options.
- 18 -
Quest SQL Optimizer for Oracle – Users Guide
You also have the ability to test and compare your own SQL alternatives using the Create User-Defined SQL
function.
In the SQL Optimizer within the Tuning Lab, the SQL optimization is a two-step process. In the first step, the SQL
optimization process automatically transforms the original SQL statement and generates semantically equivalent
alternative SQL statements with unique execution plans. For every alternative execution plan, the Oracle Cost
estimation is displayed. Once the SQL alternatives have been generated, the second step consists of locating the
most-efficient SQL alternatives for your database environment by testing the SQL alternatives against your
database. The results obtained from the second step indicate the time required to execute each SQL statement, as
well as, run time statistics.
Tip: The Oracle Cost is only an estimate of the resources it takes to execute a SQL statement. It is essential to
execute the alternative SQL statements in order to determine which statement performs the best in your
environment.
Optimize SQL
2. If the Create a New Tuning Lab window does not appear, click Create a new session .
3. In the Connection box, click Down Arrow and select a previously created database connection or click
Ellipsis to create a new Connection Profile. Click OK.
4. Enter a SQL statement in the SQL text window.
5. In the Header Bar upper right corner of the Tuning Lab, click the Set Schema option and select the
schema which matches your SQL statement.
6. Click Optimize .
This step launches the SQL Optimizer that automatically transforms the SQL statement. The use of hints
and other optimization options such as transforming a view to an inline view and the ANSI JOIN syntax
are optional. In the Options, the intensity of the SQL transformation process is controlled by the
Intelligence Level. The Intelligence Levels control how many Oracle hints are applied to transform SQL and
how many SQL alternatives are created.
7. Look at the progress bar in the bottom right corner of the Tuning Lab to see the progress optimization
process.
Compare Scenarios
When the optimization is finished, the Compare Scenarios Layout is displayed. At this point since you have not yet
run the SQL statements, the top window in the layout displays only the Oracle Cost values. These are only
estimations of how each statement will perform. You need to test each statement to obtain its actual run time
statistics.
8. To compare the original SQL statement and the execution plan to the alternative SQL statements, click the
SQL list at the top of the SQL Text panes to select the SQL statements you want to compare.
The Execute function provides an efficient way of testing SQL. It runs the selected SQL statements in the database
and the SQL statements that exceed the termination time are cancelled. For SQL statements such as INSERT,
DELETE and UPDATE, each statement is run in a transaction that is ROLLBACK, therefore maintaining the
consistency of your data.
- 19 -
Quest SQL Optimizer for Oracle – Users Guide
9. To prepare to execute the source and the alternative SQL statements, click Options .
10. Select the Tuning Lab | Execution | Execution Criteria branch.
11. In the Run Time Retrieval Method section, select the following option that best suits your SQL statement.
Original SQL twice using second run time and all others once
The first time you access data from table, the data is cached into memory. This process takes a few
moments. The next time you access that data, it is already in memory so the following SQL statements
run faster. So to have a comparable test, the first SQL is run twice and the time from the second run is
compared to the time from the other statements.
All SQL twice using the second run time
Running all SQL twice enables you to eliminate some factor that can affect the accuracy of the results. If
some SQL statements have been recently executed, then the SQL information is likely to be resident in
the cache and it may execute faster because of that. Also, if the SQL statements use different indexes,
one index may be resident in the cache and the other not. This option eliminates these factors since it
runs all SQL statements twice, throws out the first execution time and uses the second one when all SQL
statements and indexes should have the necessary items in the cache.
All SQL Once
For long running SQL there is no need to run any statement twice since the effect from caching is
diminished over time.
12. In the SQL Termination Criteria section, select Cancel execution by the fastest SQL run time.
13. Click the Tuning Lab | Execution | Execution Method branch.
14. In the Execution Method section, select Run on server. With this option, the Execute function retrieves
the time the SQL statement executes in the database and does not retrieve the result set from the
database server to the client. Therefore it does not create additional network traffic.
15. Click the down arrow on the right of Execute and select Execute All.
16. Look at the progress bar in the bottom right corner of the Tuning Lab to see the progress of the execution
process. When the execution is finished, the Execution Statistics layout is displayed.
17. Once you have identified the alternative SQL statement you want to use, you can copy and paste it back
in your application.
The Deploy Outline feature leverages the Oracle plan stability strategy called stored outlines. In Oracle 9i and
above, the stored outlines enables you to influence the execution plan of a SQL statement without having to modify
the SQL statement syntax. The major advantage of deploying a outline is that you can optimize the SQL statement
without altering the SQL text. This is an ideal solution for when you do not have the source code from a vendor but
want to improve the performance of the database application. In this case, you cannot change the source code that
contains a poor performing SQL statement, but you can deploy a stored outline to force Oracle to use a specific
execution plan for that SQL statement.
In the Tuning Lab, you can optimize to find the semantically equivalent SQL statements with alternative executions
plans and then choose the best SQL statement and deploy it as a outline.
1. In the Tuning Lab, optimize and execute a SQL statement using the SQL Optimizer Tutorial.
2. Select the alternative SQL statement whose execution plan you want Oracle to use in place of the
execution plan for the original SQL statement.
3. In the Scenario Explorer window, click the Green Push Pin icon.
Note: The Green Push Pin is only an indication that the alternative SQL statement should be able to be
deployed as a stored outline. It is not 100% accurate, so you many find that SQL alternatives without the
green push pin may also be deployed for the original SQL statement.
4. In the Outline name box, enter a name for the stored outline.
- 20 -
Quest SQL Optimizer for Oracle – Users Guide
5. In the Category box, select a category name or enter a new name to create a new category. The default
category name is SQL_OPTIMIZER.
Note: At this point, it is a good idea to put this outline in a category that is disable until you have finished
testing the execution of the SQL statement with and without the use of the outline. You can move the
stored outline to another category using the Outline Manager.
7. Click Deploy.
If you are satisfied with the performance improvement for the SQL statement with the stored outline, then move
the stored outline to a category that is enabled.
8. Click the Outlines tab to open the Outline Manager window.
9. In the Category/Outline pane, select the stored outline.
Outlines are stored in a category. A category is either set as enabled or disabled. If the category is enabled, all
outlines in the category will be used when corresponding SQL statement is executing. If a category is disabled,
then when the SQL statement is executed, Oracle retrieves the execution in the normal manner at the time of
execution.
13. Click the category name in the Category/Outline tree.
The Index Expert in the Tuning Lab enables you to determine the best possible indexes for a SQL statement. The
Index Expert generates multiple index sets for a single SQL statement.
- 21 -
Quest SQL Optimizer for Oracle – Users Guide
The Index Expert generates index sets by analyzing the syntax of a SQL statement and the tables it references. It
generates the individual index candidates and then groups these indexes into index sets of one or more indexes.
In the Index Type options you can select to generate B-Tree and Bitmap indexes. You can specify to parallelize the
indexes and to what degree. For B-Tree indexes, you can specify key-compressed.
When generating the indexes, it determines the selectivity of the data from the sample data size that you specific
in the Index Options. You can also determine the maximum number of columns that will be used in a composite
index, the maximum number of indexes in an index set, along with setting quotas for how many individual indexes
and index sets are generated.
Note: Index Expert requires Oracle 8i or above. It also requires the use of the Oracle cost-based optimizer. If your
are using the rule-based optimizer, cost-based optimization will be enforced by using the ALL_ROWS or
FIRST_ROWS hint. This is required in order to create virtual indexes in Oracle. If the SQL statement has the rule
hint /*+ RULE */, you must remove it before generating the Index sets.
The virtual execution plan for the SQL statement is retrieved using each index set that is generated. Each plan is
compared to all the other virtual execution plans. One index set is selected for each unique virtual execution
plan. Although the index generation process may generate several index sets, you will see only some of the index
sets since the sets with a duplicate virtual execution plan are eliminated.
It retrieves the virtual execution plan for every index set without physically creating of the indexes in your
database because it uses virtual indexes.
You can review the virtual execution plans and the Oracle cost estimations to assist you in selecting which Index
Sets to test and implement. The original SQL statement can be executed using index sets to identify which index
set will yield the greatest performance gain for the SQL statement. The execution process physically creates the
indexes in the index set on your database, executes the original SQL statement, and then drops the indexes from
the database.
You can do an Index Impact Analysis to see the impact that creating new indexes would have on the execution
plans of your SQL statements before you actually create the indexes on your database. The Index Impact Analysis
evaluates the effect of the creation of the indexes in the database system without affecting database performance.
It shows which SQL statements are impacted by the index sets and identifies the index set that yields the highest
performance gain with the least impact on the database system.
Index Expert analyzes the syntax of a SQL statement, the relation between tables, and selectivity of the data to
identify columns as index candidates. Index candidates are combined into multiple index sets and it gives you all
the alternative index sets that generate a unique execution plan for the SQL statement. It does this without
physically creating the indexes in the database. Index Expert provides performance estimations for every index set
to assist you in selecting which index set alternatives to test, evaluate, or implement. The SQL statement can be
executed using the index alternatives to identify which set will yield the greatest performance gain for the SQL
statement.
2. If the Create a New Tuning Lab window does not appear, click Create a new session .
- 22 -
Quest SQL Optimizer for Oracle – Users Guide
3. In the Connection box, click Down Arrow and select a previously created database connection or click
Ellipsis to create a new Connection Profile. Click OK.
4. Enter the SQL statement in the SQL Text window.
The Execute function provides an efficient way of testing the indexes. It physically creates the indexes on the
database, runs the SQL statement, and then drops the indexes.
Note: This process may impact the performance of other SQL statements.
6. Select the index sets that you would like to test.
7. Click the down arrow on the right of Execute and select Execute Selected.
8. Look at the progress bar in the bottom right corner of the Tuning Lab to see the progress of the batch run
process. When the batch run is finished, the Execution Statistics layout is displayed for you to review the
results
9. Before creating new indexes you can do an Index Impact Analysis.
You can analyze the impact that creating new indexes would have on the execution plans of your SQL statements
before you actually create the indexes on your database. To do this, you use the Impact Analyzer module to store
the current execution plans of your SQL statements. Then you can do a simulation of creating the indexes by
creating virtual indexes and compare the execution plans before and after the index simulation to see what affect
the indexes would have on the execution of your SQL statements. You can do an Index Impact Analysis from the
Tuning Lab or Global Indexing. This tutorial starts from the Tuning Lab.
1. In order to do an Index Impact Analysis, you must have already created an Analyzer in the Impact
Analyzer module. If you have not done this, following the steps in the Impact Analyzer Tutorial.
2. Generate Index candidates using the Index Expert Tutorial in the Tuning Lab.
3. From the Scenario Explorer window in the SQL Details layout in the Tuning Lab, right-click the virtual
index you want to do an analysis on and select Index Impact Analysis.
4. The Select a Group window appears. Select the Impact Analyzer Group which contains the SQL Repository
that you want to analyze.
5. The Impact Analyzer window is opened and you are prompted with the Impact Analysis - Add Snapshot
wizard.
6. The Impact Analysis - Add Snapshot wizard consists of the following:
General Page
7. Select the Analyzer which contains the SQL statements you want to analyze in the Analyzer tree.
Box Description
Name The name is automatically generated for a virtual index snapshot.
Type The snapshot type of Virtual Index Simulation is automatically entered.
Description Enter the description for the Snapshot to be created.
Last generated Displays the last generated date and time. This will be blank since you are
creating the Snapshot for the first time.
Add to Analyzer Displays the Analyzer location where the Snapshot will be saved.
Select an Analyzer to From the tree structure, select an Analyzer. When you are doing an Index
analyze its SQL Impact Analysis from the Tuning Lab, the Analyzer must have been
statements previously created in the Impact Analyzer.
- 23 -
Quest SQL Optimizer for Oracle – Users Guide
8. Click Next.
9. The virtual index set that you selected in the Scenario Explorer is selected. You may select addition index
sets.
10. Click Finish.
Best Practices within the Tuning Lab does an overall analysis of a SQL statement and your database and then
proposes common ways to improve performance. However, review these recommendations to see if they are the
correct solution for your database environment and thoroughly test the recommendations before you apply them to
your production system. A recommendation may help to improve a specific SQL performance, but it may affect
other SQL statements as well. When evaluating the recommendations, you need to take into account that database
performance is a result of the complex mix of the following:
1. Click Options . Select Tuning Lab | Best Practices | General. Check Include Best
Practices module in Tuning Lab. Click OK.
2. Click the Tuning Lab tab.
3. If the Create a New Tuning Lab window does not appear, click Create a new session .
4. In the Connection box, click Down Arrow and select a previously created database connection or click
Ellipsis to create a new Connection Profile. Click OK.
5. Enter a SQL statement into the SQL Text window.
- 24 -
Quest SQL Optimizer for Oracle – Users Guide
Global Indexing analyzes a group of SQL statements and determines the best common index set for all of the SQL
statements in the group. It does the analysis and index generation without physically creating the indexes on the
database. It is necessary to create the indexes if you want to do a comparison of the run times with and without
the indexes.
Note: Global Indexing is only available for Oracle 8i or above.
Global Indexing generates a set of indexes by analyzing all the SQL statements in a group of statements and the
tables that are referenced by all the statements. While generating the index set, no indexes are physically created
on the database. Instead, each index in the proposed set of indexes is created as a virtual index and an virtual
execution plan is retrieved for each SQL statement in the group. This virtual execution plan simulates the execution
plan that Oracle would generate if the indexes were physically created.
The SQL statements can be executed first without and then with the index set to compare the run times to see
whether there would be any performance gain from creating the proposed index set. The execution process
executes the SQL statement before creating the indexes. Next, it physically creates the indexes on the database,
executes the SQL statements again, and then drops the indexes from the database. You can compare the run times
with and without the indexes and also compare the virtual execution plan to the actual execution plan.
You can do an Index Impact Analysis to see the impact that creating the indexes would have on the execution
plans of other SQL statements used in your application before you permanently create the indexes on your
database. The Index Impact Analysis evaluates the effect of the creation of the indexes in the database system
without affecting database performance since it uses virtual indexes instead of creating indexes on the database. It
identifies the SQL statements which have execution plans that are impacted by the creation of the indexes.
Note: The options for executing SQL statements are shared between the Tuning Lab and Global Indexing. The
execution settings for Global Indexing are found under the Tuning Lab Execution Criteria and Execution Method
options. Some of the options for generating indexes are shared between the Tuning Lab/Index Expert and Global
Indexing. These settings are found under the Tuning Lab/Index Expert Options and Index Type.
- 25 -
Quest SQL Optimizer for Oracle – Users Guide
Global Indexing enables you to analyze a set of SQL statements and determine the best common index for all of
the SQL statements.
3. If the Create a New Global Indexing window does not appear, click Create a new session .
4. In the Connection box, click Down Arrow and select a previously created database connection or click
Ellipsis to create a new Connection Profile. Click OK.
7. Click Execute . This executes the all the SQL statement to obtain the run time. Then, it
creates the indexes in the tablespace you specify and executes all of the SQL statements again. After the
execution is finished, the indexes are dropped. The Results layout displays showing execution statistics in
the Scenario Explorer window.
Note: This physically creates the indexes on the database, runs the SQL statement, and then drops the
indexes. This may impact the performance of other SQL statements.
8. Before creating new indexes you can do an Index Impact Analysis.
9. Deploy the index advice into a production environment by using Index Script . This
button sends the index scripts and statistic generation commands to the SQL Editor for editing and final
deployment opens another Quest product such as Toad or SQL Navigator and copies a index script that
you can use to create the set of indexes. If you do not have a Quest product that can execute the script,
the script is copied into a dialog where you can save the it to a file or copy and paste it to another
program.
- 26 -
Quest SQL Optimizer for Oracle – Users Guide
Impact Analyzer provides a way to determine the effects on SQL performance before a change is made to the
database or after a change has occurred. You can find out what will happen to the performance of the SQL
statements if you were to add an index or change a database configuration parameter before you make the change
in the database. You can also find the SQL statements that have been affected as the result of changes that have
occurred in the database environment. The Impact Analyzer helps you to ensure reliable database performance by
tracking execution plan and Oracle cost changes for SQL statements.
All kinds of changes can affect SQL performance. Before and after these changes take place, you can predict and
track the impact of changes. Impact Analyzer helps you find where the SQL statements that are effect by changes
and to fix the problem quickly. The following are some of the changes that can have significant impact on the
performance of your SQL:
- 27 -
Quest SQL Optimizer for Oracle – Users Guide
The Impact Analyzer enables you to save the SQL statements whose performance you would like to track in a “SQL
Repository”. The execution plan is saved along with the SQL text. You can then use those SQL statement in one or
more "Analyzers."
Analyzer
An Analyzer is set up so that you can find the changes in the execution plans for SQL statements that are critical to
the performance of your production application. In an Analyzer, you create a "Baseline Snapshot" which saves the
execution plan for each SQL statement you have placed in the Analyzer. The execution plans in the Baseline
Snapshot are used as the bases for comparison to execution plans for the same SQL statements under differing
database conditions.
Script
"Scripts" are used so that you can do various "what if" analysis to determine what impact changing the database
configuration would have on the performance of the SQL statements.
You can set up an Analyzer so that you can take a snapshot on a periodic bases to obtain the current execution
plan to find out if any of the execution plans have changed over a period of time. You can also take a snapshot
each time a change has taken place in the database such as a updating of the statistics for tables and indexes. For
those statements with changes, you can use the SQL Optimizer to see if a SQL statement performance would be
improved by optimizing it.
You can set up an Analyzer to save the execution plans for the SQL statements in the development environment.
Then when the application is ready to be placed into the production environment, you can take a snapshot to
obtain the execution plans on the production server to find the SQL statements that have different execution plans
and need to be optimized for the production environment.
You can set up an Analyzer to save the execution plans for the SQL statements in your current version of Oracle.
Then you can connect to a new version of Oracle and take a snapshot to obtain the execution plans on the new
version to find the SQL statements that have different execution plans and need to be optimized for the Oracle
version.
You can set up an Analyzer to analyze what effect adding an index will have on the execution plans for SQL
statements. This way you can evaluate the affect the new index will have on performance before you create the
index. You can analyze the effect the index will have on the execution plan for each SQL and also see the total
effect on all SQL. This aids you in determining if the index is right for the overall performance of your database.
Note: Virtual indexes are use to create the snapshot so that no indexes are created on your database by this
analysis.
You can set up an Analyzer to analyze what effect changing various database parameter will have on the execution
plans for SQL statements. This way you can evaluate the affect of a change on performance before you actual
make the change. To simulate the change before it is made, you create an script that would make the proposed
change. Then create a snapshot using the script to obtain what the execution plan would be for each SQL
statement in the Analyzer if you actually made the change. You can analyze the effect that change will have on the
execution plan for each SQL and also see the total effect on all SQL. This aids you in determining if the change is
right for your database.
- 28 -
Quest SQL Optimizer for Oracle – Users Guide
Scripts
When creating a Script, you set up a Pre-script and a Post-script. The Pre-script is run to change the database
environment. Then the execution plan is retrieved for each SQL statement in the Analyzer. The post-script can be
used to set the database back to its original state.
Note: It is recommended that you use the ALTER SESSION command in the scripts so as to not affect other users
on the database.
SQL statements are saved to the Impact Analyzer so that you can track and analyze changes to the execution plan
of a SQL statement under different database environments. This allows the prediction of the overall performance
improvement or degradation in different database environments.
1. In the SQL Scanner or SGA Inspector, highlight a job in the Job Grid.
The Impact Analyzer saves the execution plan for SQL statements so that you can track changes to the database
environment such as: parallel processing, database system changes, data growth, database migration, database
version upgrade, development to production deployment, data reorganization, index changes, virtual index
simulation, database re-design, rule-based to cost-based optimizing, and any other database environment change.
The Impact Analyzer shows how these changes affect the execution plans. It enables you to save and compare the
execution plans before and after these changes so that you can see how these changes impact the performance of
your SQL statements.
The Impact Analyzer stores the SQL statements and their execution plan information in this directory on your PC:
C:\Documents and Settings\user\Application Data\Quest Software\Quest SQL Optimizer for Oracle\Analyzer Data
The location of the directory can be changed in the Options window under the Analyzer page.
The SQL statements that you save in the Impact Analyzer are listed under the SQL tab located at the bottom left of
the Impact Analyzer window. You may save a SQL statement from another module (see Save SQL Statements to
the Impact Analyzer Tutorial) or from within Impact Analyzer module.
3. Click the SQL tab at the bottom left corner of the window.
4. Right-click in the SQL pane and select Add SQL to open the Add SQL wizard.
- 29 -
Quest SQL Optimizer for Oracle – Users Guide
5. On the General page, enter a name for your SQL statement in the Name box.
6. If you would like to create a new folder to store the SQL statement, click Add Folder .
7. In the pane at the bottom of the Add SQL page, click the folder where you want to store the SQL
statement.
8. On the SQL Information page, enter your SQL statement.
9. Click Check SQL to check the syntax and retrieve the execution plan.
10. Click Finish to save the SQL.
You must have saved a SQL statement before you can perform any comparison in the Impact Analyzer. (See Save
SQL Statements to the Impact Analyzer Tutorial or SQL Tab, step 3.)
The Analyzer tab can contain more than one Analyzer. Every Analyzer is an individual unit that contains the
analysis of different SQL statements’ execution plans. Every Analyzer can have one or more SQL statements
grouped in what is called a SQL Repository. For the SQL statements in the SQL Repository, you can take one or
more execution plan snapshots under different database environments.
11. Click the Analyzer tab at the bottom left corner of the window.
12. Right-click in the Analyzer pane and select Add Analyzer to open the Add Analyzer wizard.
13. On the General page, enter a name for your Analyzer in the Name box.
14. If you would like to create a new folder to store the Analyzer, click Add Folder .
15. In the pane at the bottom of the General page, select the folder where you want to store the Analyzer.
16. On the SQL page, select the SQL statements you would like to add to the Analyzer from your predefined
SQL statements, or you may add a statement to this Analyzer by clicking Add SQL in the right corner
of this window.
17. On the Plan Snapshot page, the first time you are on this page, it brings up the Add Baseline Snapshot
wizard. This snapshot of the SQL statements and execution plans is used as the comparison for all other
snapshots in the Analyzer.
After the first execution plan is saved, if you would like to add another SQL snapshot to this Analyzer, click
Note: You can add a new Oracle script by clicking the Add Script .
21. Click Finish to close the Add Baseline or Plan Snapshot wizard.
22. To add more snapshots, repeat from step 17.
- 30 -
Quest SQL Optimizer for Oracle – Users Guide
23. Click Finish to close the Add Analyzer Wizard. The Analyzer makes the connection to the database and
retrieves the execution plan under the different snapshots.
24. The Plan Generation Summary window displays information regarding the retrieval of the execution plans.
There you can see if the retrieval is successful or if an error occurred. Click OK to close the window.
25. To review the Plan Analyzer summary, see View the Execution Plan Changes, step 34.
26. Click the Script tab at the bottom left corner of the window.
27. Right-click in the Script pane and select Add Script to open the Add Script wizard.
28. On the General page, enter a name for your Script in the Name box.
29. One the Scripts page, you will see an area for a Pre-Script and a Post-Script.
30. In the Pre-Script area, enter the Oracle commands to be executed before the execution plan is retrieved.
31. In the Post-Script area, enter the Oracle commands to be executed after the execution plan is retrieved.
32. In order to check your script in a pre-selected database, click Check Script . This will allow you to
verify that you your scripts execute.
33. Click Finish to save the scripts.
34. Click the Analyzer tab at the bottom left corner of the window.
35. Expand the tree in the left pane to find the SQL statement for which you would like to analysis the various
execution plans.
36. To view the SQL text and the execution plans for each snapshot, click the name you gave the SQL
statement in the left pane.
37. In the right pane, you will see the SQL statement with tabs at the bottom of the pane to display the
execution plan and SQL classification for each snapshot. This interface allows you to compare side by side
the execution plan for the SQL statement under different snapshots. It also displays the SQL Classification
associated with every execution plan.
38. To view a summary of the performance change from the SQL statement in the Baseline snapshot and a
comparison snapshot, click the name of the comparison snapshot in the left pane.
39. In the right pane, you will see a table (in the center pane) that summarizes the comparison of the
Baseline execution plan and the snapshot execution plan. It shows the Baseline Snapshot Oracle Cost, the
Snapshot Oracle Cost, Cost difference (Snapshot cost – Baseline cost), YES/NO Plan Changed, SQL
Classification for the Baseline Snapshot, SQL Classification for the Snapshot, and what type of change
occurs, Improved/Unchanged/Degraded.
From here you can identify the SQL statements that may experience performance improvement (Oracle
cost in the comparison snapshot is smaller than the cost in the Baseline snapshot), or performance
degradation (Oracle cost in comparison snapshot is higher than the cost in the Baseline snapshot). You
can also analyze how the complexity of the execution plan changes between snapshots by comparing
changes in the SQL Classification.
Note: Oracle only provides a cost for the execution plan for SQL statements under the cost-based
optimizer. If no cost is displayed, this means that the SQL statement is using the rule-based optimizer.
40. At the top right pane, you can see a graph or a summary of Oracle cost changes, which indicate overall
performance improvement or degradation. The summary also displays overall performance improvement
or degradation of the SQL Classification. Clicking any portion of one of these graphs will highlight the
statements that are being represented in these graphs in the table summary discussed in the previous
point (step 39).
- 31 -
Quest SQL Optimizer for Oracle – Users Guide
A stored outline consists primarily of a set of "hints" that is equivalent to the Oracle optimizer's execution plan for a
particular SQL statement.
In Oracle, stored outlines enable you to influence the optimization of a SQL statement without having to modify the
SQL statement syntax. If you cannot change the source code that contains your SQL statement, you can use a
stored outline to force Oracle to use a specific execution plan for a SQL statement. This is particularly useful if you
have third party applications where you do not have access to the source code.
Stored outlines are used to preserve the performance characteristics of SQL statements by stabilizing the execution
plan. The execution plan for a SQL statement can change due these and other factors:
- 32 -
Quest SQL Optimizer for Oracle – Users Guide
When these changes occur, the Oracle optimizer may select a different execution plan which in turn affects the
performance of the SQL statement. By creating a stored outline for a SQL statement, you can stabilize and
preserve performance characteristics of the statement. Therefore, using outlines can prevent performance
degradation of SQL statements due to database environment changes.
Warning: The SQL text that is saved with the outline needs to be identical to the SQL statement in the source
code or the outline will not be used. Oracle will consider two SQL statements as not identical if there is any
difference in spacing, carriage return, embedded hints, comments, and upper/lowercase.
A stored outline is saved to a category. A category must be "enabled" before the stored outlines that are saved in it
are used when the SQL statements are executed. When a SQL statement is executed, Oracle first searches the
enabled category and then the DEFAULT category to see if the SQL statement has a stored outline associated with
it. If a stored outline is found, then Oracle will use the hints in the outline to determine the execution path for the
SQL statement instead of using the execution plan.
Note: By default the Outline Manager module is not displayed. You can specify to display this module from the
General page of the Outlines options.
The current plan is to remove the Outline Manager module from Quest SQL Optimizer for Oracle in the next
release.
The Outline Manager allows you to manage Oracle outlines after they have been deployed.
1. Click Options . Select Outlines. Check Show Outline Manager. Click OK.
2. Click the Outlines tab.
3. If the Create a New Outline window does not appear, click Create a new session .
4. In the Connection box, click Down Arrow and select a previously created database connection or click
Ellipsis to create a new Connection Profile. Click OK.
5. For a category, use the Outline Manager to drop, enable, or rename it.
6. For an outline, use the Outline Manager to drop, move, or rename it, or reset the "unused flag".
- 33 -
Quest SQL Optimizer for Oracle – Users Guide
Options Settings
General Options
General Options
- 34 -
Quest SQL Optimizer for Oracle – Users Guide
Restore layouts
You may customize any of the module windows by arranging the individual windows within the module. The default
layout can be restored.
Click Restore .
Select the modules to restore the default arrangement of the windows.
Restore All (Default)
Specify to restore all the default window arrangements for every module.
Restore selected layouts
Specify to restore the default window arrange for the layouts that you select from the following modules:
Assistant
Batch Optimizer
SQL Scanner
SGA Inspector
Tuning Lab
Global Indexing
Impact Analyzer
Outline Manager
Select Batch Optimizer or Tuning Lab to optimize SQL sent from other applications
Batch Optimizer
Specify to send text to the Batch Optimizer. You can send multiple SQL statements embedded in text to the
Batch Optimizer.
Tuning Lab
Specify to send the text to the Tuning Lab. Only a single SQL statement can be optimized in the Tuning Lab.
Ask me every time (Default)
Specify to prompt you to select the module each time text is send to Quest SQL Optimizer from another
application.
Create a new batch every time when sending to Batch Optimizer
Specify to automatically create a new batch or to be prompted to select an existing batch each time you send text
to the Batch Optimizer.
- 35 -
Quest SQL Optimizer for Oracle – Users Guide
Click Setting .
Select the copy to be launched.
Quest SQL Optimizer for Oracle
Quest SQL Optimizer for Oracle Trial
Quest SQL Optimizer for Oracle Beta
Ask me every time
When the execution plan for a SQL statement is retrieved from Oracle, the SQL statement is classified as Simple,
Complex, or Problematic. SQL statements are categorized according to their suspected level of performance to help
you focus on the SQL statement that are more likely to be causing performance problems. These SQL
classifications are user defined in the Options.
Problematic SQL statements are the highest level of potentially under-performing SQL statements that should be
optimized. Using the default settings, a SQL statement is classified as Problematic SQL when the execution plan
contains at least one of the following:
Note: You have the option to include or exclude the SYS.DUAL table in each definition.
Using the default settings, a SQL statement is classified as Complex SQL when the execution plan contains at least
one of the following and does not meet any rules for Problematic SQL.
- 36 -
Quest SQL Optimizer for Oracle – Users Guide
3 or more fast full index scans. INDEX FAST FULL SCAN (Count >= 3) - Excluding DUAL
Note: You have the option to include or exclude the SYS.DUAL table in each definition.
A SQL statement is classified as Simple SQL when the execution plan does not meet any of the rules for either the
Problematic or Complex SQL classifications.
If the execution plan is not retrieved successfully, then the SQL statement is classified as "Invalid SQL". A SQL
statement can be can be classified as Invalid SQL if the database object it references does not exist, the database
user does not have privileges to access the database object, or the schema used is not the correct one for the SQL
statement.
The SQL Classification rules which determine whether a SQL statement is classified as Simple SQL, Complex SQL,
or Problematic SQL.
- 37 -
Quest SQL Optimizer for Oracle – Users Guide
2. Under Step 1, select the template to use for the new rule.
Template Description
Count the number of references to This rules determines the maximum number of times one
database objects or more database objects is referenced before the SQL
statement is placed in the classification that you select.
Count the number of a specific This rules determines the maximum number of times a
operation specific operation, which you select, can be performed
before the SQL statement is placed in the classification
that you select.
Check the BYTES in a specific This rules determines the maximum number of bytes that
operation can be in a operation, which you select, before the SQL
statement is placed in the classification that you select.
Check the BYTES in the child steps This rules determines the maximum number of bytes that
under a specific operation can be in the child steps of a operation, which you select,
before the SQL statement is placed in the classification
that you select.
Check the CARDINALITY in a specific This rules determines the maximum size of the cardinality
operation of a specific operation, which you select, before the SQL
statement is placed in the classification that you select.
Check the CARDINALITY in the child This rules determines the maximum size of the cardinality
steps under a specific operation of the child steps in a specific operation, which you select,
before the SQL statement is placed in the classification
that you select.
- 38 -
Quest SQL Optimizer for Oracle – Users Guide
Check the BYTES in a step that is This rules determines the maximum number of bytes that
iterated by a NESTED LOOP can be in a step that is in a NESTED LOOP before the SQL
statement is placed in the classification that you select.
Check the CARDINALITY in a step before the SQL statement is placed in the classification
that is iterated by a NESTED LOOP that you select.
3. Under Step 2, click the underlined text to select or enter your desired value for the rule you selected.
4. Under Step 3, select Complex SQL or Problematic SQL.
5. Under Step 4, edit the default name for the rule.
6. Click Create.
In addition to being classified as Simple, Complex, or Problematic, some SQL statements are classified as "Invalid
SQL" to indicated that execution plan could not be retrieved from the database. The Oracle error message which
indicates that the execution plan was not retrieved is displayed to help you determine why the SQL statement was
classified as invalid. The Invalid SQL classification may result from one of the following:
The current user does not have privilege to the tables, views, or other database objects referenced in the SQL
statement even though the syntax of the SQL statement is correct.
The SQL Scanner is unable to identify SQL statements that are dynamically constructed at run time. This type of
SQL is found in the source code on several command lines and the exact construct of the SQL statement is not
determine until the application is executed. The SGA Inspector can be used to trap all executed or real-time SQL
statements.
Incorrect Schema
The schema that was used when the execution plan was retrieved was not the correct schema for the SQL
statement.
- 39 -
Quest SQL Optimizer for Oracle – Users Guide
Each time a SQL statement is executed in the Tuning Lab and Global Indexing, the trace statistics from the
execution can be retrieved. The Oracle SQL tracing function writes the statistics to a trace log on the server. In
order to view this information in the Tuning Lab after the execution is finished, you must set up the file access
method for retrieving the statistics from the log files on the server.
Note: By default, the trace log is stored in the location specified by the Oracle USER_DUMP_DEST parameter.
However, you can customize the location of the trace log in the init.ora file.
Three methods are provided for retrieving the information from the trace log.
Trace Setup
In the Connection box, click Down Arrow to select a previously created database connection or click Ellipsis
to create a new connection.
Access Method
- 40 -
Quest SQL Optimizer for Oracle – Users Guide
3. Follow the prompts for the access method you have chosen.
4. Click Validate to validate the trace log location and access method.
or
Click Run Trace Wizard to use the Trace Setup wizard which will guide you
through these steps.
Note: The size of the trace log file is determined by the setting for the MAX_DUMP_FILE_SIZE Oracle parameter.
The Trace Setup options can be entered with the help of the Trace File Setup Wizard. This wizard allows you to
setup one of the following trace file options for transferring the statistics from the server to your local computer:
An File Transfer Protocol connection must exist for the Oracle instance to which you want to connect. The wizard
FTP option window contains the following:
Using the Network File Server option, you can select any directory that you can directly access from your local
computer.
- 41 -
Quest SQL Optimizer for Oracle – Users Guide
3. Enter, or browse for, the trace file path by using the Fully Qualified Trace Log Directory field. For
remote NFS connections the Browse path and the user_dump_dest path are different. The Browse path
contains the mapped path and the user_dump_dest path displays the local path for the remote machine.
Tip: You can copy the user_dump_dest value displayed in the wizard and paste it in this box.
3. Click Validate to test the supplied setup information.
4. Click Next.
5. Click Finish.
UTL_FILE Package
If you cannot access the trace log files using the File Transfer Protocol (FTP) or Network File Server (NFS) options,
you can use the Oracle UTL_FILE package option. The transfer of the statistics from the trace log to the local
computer will be slower with this option than with the other options.
The directory specification for the Oracle parameters USER_DUMP_DEST and UTL_FILE_DIR must be defined in
INIT.ORA. The UTL_FILE package must be installed on the Oracle instance. If it is not installed, the wizard will
install it for you.
Disable Tracing
If you do not want to see the trace statistics after the a SQL statement is executed in the Tuning Lab or Global
Indexing, you can disable the function so that the statistics are not retrieved from the trace log files.
- 42 -
Quest SQL Optimizer for Oracle – Users Guide
Execution Plan
The Execution Plan page of the Options window allows you to select the settings for all execution plan windows
displayed throughout all the modules.
TABLE ACCESS FULL warning threshold (Default = 1000, Range 0 to 32,767)
Specify the number of rows that must exist in a table before the icon in the execution plan is changed from green
to red to draw your attention to the full table scan.
Abbreviate JOIN Text (Default = unchecked)
Specify to abbreviate the text that is displayed in the execution plan for the table joins. The abbreviation feature
reduces the large amount of join text associated with a large query so that you can focus on the overall steps in
the execution plan.
Execution Plan Display Settings
The color and font can be set for each item in the execution plan which is listed in the Name column.
Color
Specify the color of the individual items in the execution plan by clicking the Color column in the row for the
item and selecting the new color from the Color dialog.
Font
Specify the font settings of the individual items in the execution plan by clicking the Font column in the row
for the item and selecting the new settings from the Font dialog.
Note: The execution plan is displayed in several layouts. The color and font settings in this Option windows
controls the settings in all the Execution Plan windows. You can customize which elements of the execution plan
are displayed in each individual Execution Plan window using the Execution Plan Options window.
- 43 -
Quest SQL Optimizer for Oracle – Users Guide
The display of the Execution Plan window can be customized for each module or layout in which it is included. You
can select which elements of the execution plan you would like displayed in the text of the execution plan. You can
also have the element displayed in a separate column.
- 44 -
Quest SQL Optimizer for Oracle – Users Guide
Note: The execution plan is displayed in several module and layouts. The color and font settings for all the
Execution Plan windows is set using the General—Execution Plan page of the Options window.
The Test for Scalability function sends the selected SQL statements to Quest's Benchmark Factory program. If you
have Benchmark Factory 5.0.1 or earlier installed on your computer, you will be prompted by the Benchmark
Factory wizard to select the settings for the test for scalability If you have Benchmark Factory 5.5 or later installed
on your computer, you can set up the test with the following options.
Number of virtual users to execute the SQL statements
Specifies the number of users that Benchmark Factory will simulate to test the performance of each SQL
statement.
Latency Think Time
Latency Think Time is used to simulate an amount of time "to think" about the results of a previous transaction. It
controls the period between receiving results of one transaction and sending the next transaction to the server. The
distribution model is used to calculate the exact milliseconds that are used each time for the delay between the
execution of the SQL statement.
Distribution Model
Select the Distribution module.
- 45 -
Quest SQL Optimizer for Oracle – Users Guide
Duration (milliseconds)
Specify the number of milliseconds to delay between each execution of a SQL statement.
Execute each SQL statement by
Select either to execute the SQL statement a certain length or a certain number of times.
Duration (seconds)
Specify to continually execute each SQL statement with latency for the specified number of seconds.
Number of times
Specify to execute each SQL statement the specified number of times.
Data Directories
- 46 -
Quest SQL Optimizer for Oracle – Users Guide
The Batch Optimizer settings consists of the following pages that allow you to select the options settings used
throughout the three processes preformed in the Batch Optimizer: scanning for SQL statements, transforming the
SQL text through optimization, and executing the SQL statements to test the run times and find a best alternative
SQL.
Options
Execution
Execution Criteria
Execution Method
Auto Execution
- 47 -
Quest SQL Optimizer for Oracle – Users Guide
Options
The Batch optimization consists of three steps: scanning to find SQL statements, rewriting the SQL syntax, and
executing the SQL alternatives to find the best. Each one of these steps has option settings that control how the
Batch Optimizer works.
1. Search for SQL statements in your code
Automatically start extracting SQL when job is added (Default = checked)
Specify to start the first step of the Batch Optimizer process, which is to scan the text of the job, when the job is
added to a batch. If this option is not selected, then you must manually start the scanning process using the Job
- 48 -
Quest SQL Optimizer for Oracle – Users Guide
View Optimization options shared between Batch Optimizer and SQL Optimizer in Tuning Lab
The options for the SQL optimization process are shared between the SQL Optimizer in the Tuning Lab and the
Batch Optimizer. The optimization settings are found under the Optimizer options in the Tuning Lab section.
3. Execute the alternatives to determine the best replacement SQL
Types of SQL statements to execute automatically after optimization
Specify which type of SQL statement, along with its alternatives, that will be automatically executed to retrieve the
run time statistics. When a INSERT, UPDATE, or DELETE statement is executed, it is always rolled back. This
maintains the integrity of your data and provides that the initial data is the same for each SQL alternative so that
the test is comparable.
SELECT (Default = checked)
INSERT (Default = cleared)
UPDATE (Default = cleared))
DELETE (Default = cleared))
View Execution options that are used by the Batch Optimizer
The Executions options used by the Batch Optimizer are not shared with any other module,
Execution
Execution Criteria
- 49 -
Quest SQL Optimizer for Oracle – Users Guide
- 50 -
Quest SQL Optimizer for Oracle – Users Guide
Execution Method
Execution Method
- 51 -
Quest SQL Optimizer for Oracle – Users Guide
Important Note: If you enable this feature, remember that this is not comparing the way the SQL
statement is actually being executed in the application since you are not retrieving all of the data. It is good
only for a quick test. The execution results may be different when you retrieve all the records.
Number of rows returned in a single network transfer (Range 25 to 32,767, Default = 1000)
Specify the number of rows that will be retrieved at one time when fetching the data from the server. The
default value is 1000.
Auto Execution
When SQL statements are optimized in the Batch Optimizer, hundreds of alternative SQL statements may be
generated. When the original SQL statement and the alternative SQL statements are executed, you can limit the
alternatives that are executed.
Two options are provided for selecting the SQL alternatives. The first option selects a representative selection from
all the SQL alternatives. It uses an Intelligence engine to first group the SQL statements based on the Oracle cost
and then selects one SQL statement from each group. The second option adds more SQL alternatives to the SQL
alternatives selected by the first option.
This process of selecting which SQL alternatives to execute starts by selecting the SQL alternatives from each
group using the value you specify in Number of SQL alternative to select as the representatives. Then it
checks the setting for Execute these additional SQL alternatives to determine if additional SQL alternatives
should be selected.
- 52 -
Quest SQL Optimizer for Oracle – Users Guide
- 53 -
Quest SQL Optimizer for Oracle – Users Guide
The Scanner page of the Options window allows you to select the settings for the scanning of database objects,
source code files, or SGA Inspector files in the SQL Scanner and the Batch Optimizer.
Scanner Options
Optimizer
Optimizer Settings
The Optimizer settings for the Tuning Lab and the Batch Optimizer in the Options window consists of the following
pages that allow you to select the options settings used when a SQL statement is optimized.
- 54 -
Quest SQL Optimizer for Oracle – Users Guide
• Intelligence
• Optimization
• Hints
• Access Path
• Join Order
• Optimization Approaches
• Parallel Execution
• Query Transformation
• Other
• Quota
Intelligence (Optimizer)
Optimization Intelligence settings enables you to either customize all the optimization settings used during
optimization or allows you to select the predefined levels for these settings.
Intelligence Level
Custom
Use Custom to enable you to select the individual settings on the Optimization, Access Paths Hints, Join Order
Hints, Optimization Approach Hints, Parallel Execution Hints, Query Transformation Hints, Other Hints, and Quota
pages.
- 55 -
Quest SQL Optimizer for Oracle – Users Guide
Predefined (Default)
Use Predefined to enable you to select an Intelligence Level which has all the optimization settings pre-selected for
you. The items selected on the Optimizer options pages change according to the level you select. The higher the
level the more intelligent the SQL Optimizer is, the more options are selected, and the more likely you are to find a
better SQL alternative. It may also take more time to optimize a SQL statement at the higher Intelligence Levels.
The Predefined settings are groups into these setting categories:
Use Data Warehouse / OLAP Uses all the settings on the Optimization page and only the Oracle
hints which are commonly used in Data Warehouse or OLAP
databases.
Do not use Oracle optimization Uses only the settings on the Optimization page.
hints
Use Access Paths hints only Uses all the settings on the Optimization page and only the Oracle
hints that control access paths.
Use Query Transformations hints Uses all the settings on the Optimization page and only the Oracle
only hints that control query transformations.
Use Join Orders / Operations hints Uses all the settings on the Optimization page and only the Oracle
only hints that control join orders and join operations.
Use Parallel Execution hints only Uses all the settings on the Optimization page and only the Oracle
hints that control parallel execution.
The Predefined Intelligence Level Use Oracle Optimization Hints uses all the optimization settings. The
intelligence levels range from 1 to 10. Level 4 is the default setting. As the level is increased more options are
selected.
The Predefined Intelligence Level Use Data Warehouse / OLAP Hints only uses the options on the Optimization
pages and the Oracle optimization hints that are commonly used in Data Warehouse or OLAP databases. The
intelligence levels range from 1 to 5. Level 3 is the default setting. As the level is increased more options are
selected.
All Data Warehouse and OLAP hints are applied at every intelligence level. Only the settings on the Optimization
page and the Quota page are changed for each intelligence level.
The Predefined Intelligence Level Do Not Use Oracle Optimization Hints uses only the settings on the
Optimization page and the Quota page. None of the Oracle optimization hints are applies to the original SQL
statement or the SQL alternatives. The intelligence levels range from 1 to 5. Level 3 is the default setting. As the
level is increased more options are selected.
- 56 -
Quest SQL Optimizer for Oracle – Users Guide
The Predefined Intelligence Level Use Access Paths Hints only uses the options on the Optimization pages and
the Oracle optimization hints that control access paths. The intelligence levels range from 1 to 5. Level 3 is the
default setting. As the level is increased more options are selected.
All Access Paths hints are applied at every intelligence level. Only the settings on the Optimization page and the
Quota page are changed for each intelligence level.
The Predefined Intelligence Level Use Query Transformations Hints only uses the options on the Optimization
pages and the Oracle optimization hints that control query transformations. The intelligence levels range from 1 to
5. Level 3 is the default setting. As the level is increased more options are selected.
All Query Optimization hints are applied at every intelligence level. Only the settings on the Optimization page and
the Quota page are changed for each intelligence level.
The Predefined Intelligence Level Use Join Orders / Operations Hints only uses the options on the Optimization
pages and the Oracle optimization hints that control join orders and join operations. The intelligence levels range
from 1 to 5. Level 3 is the default setting. As the level is increased more options are selected.
All Join Order and Join Operations hints are applied at every intelligence level. Only the settings on the
Optimization page and the Quota page are changed for each intelligence level.
The Predefined Intelligence Level Use Parallel Execution Hints only uses the options on the Optimization pages
and the Oracle optimization hints that control parallel execution. The intelligence levels range from 1 to 5. Level 3
is the default setting. As the level is increased more options are selected.
All Parallel Execution hints are applied at every intelligence level. Only the settings on the Optimization page and
the Quota page are changed for each intelligence level.
- 57 -
Quest SQL Optimizer for Oracle – Users Guide
Optimization
On the Optimization page, you can control whether a few of the SQL transformation rules are applied. Most of the
transformation rules used to rewrite the syntax of your original SQL statement are always reviewed during the
optimization process to see if the rule can be applied. The transformation rules on the Optimization options page
are only applied if they are selected.
The View to inline view transformation is only applicable if the SQL statement is using a view to access
information from the database. When a SQL statement is using a view, the SQL Optimizer rewrites the view's SQL
statement along with the original SQL statement as one of the SQL transformations. The SQL Optimizer inserts the
view's SELECT SQL statement into the original SQL statement in every place the view is referenced. Therefore the
view's SQL is going to be rewritten along with the original SQL. This is very useful when you want to optimize a
SQL statement that is using a poor performing view but you do not want to change the view's SQL.
Original SQL
SELECT *
FROM V_DEPT
WHERE DPT_MANAGER = 'SMITH'
- 58 -
Quest SQL Optimizer for Oracle – Users Guide
Specify whether to transform the view in the text of the SQL statement to an inline view, or in other words, to
transform the view to a subquery used as a table in the FROM clause.
Transformation level (Range = 1 to 99)
Specify how many levels to search for a view. This is applicable if a view uses another view so that lower
level views can also be inserted into the original SQL statement.
Ignore SYS Views
Specify whether to ignore SYS schema views when applying the View to inline view transformation.
Apply MERGE hint to transformed inline view
Specify whether to apply the Oracle MERGE hint to the View's SELECT statement.
Apply NO_MERGE hint to transformed inline view
Specify whether to apply the Oracle NO_MERGE hint to the View's SELECT statement.
The Query to inline view transformation is applicable only to SQL statements with an IN or an EXISTS. It takes
an original SQL statement and transforms the IN or EXISTS to a derived table.
Specify whether to transform the query to an inline view – a subquery used as a table in a FROM clause.
Original SQL
SELECT *
FROM DEPARTMENT
WHERE DPT_ID IN (SELECT EMP_DEPT
FROM EMPLOYEE)
Alternative SQL
SELECT DEPARTMENT.*
FROM DEPARTMENT,
(SELECT DISTINCT EMPLOYEE.EMP_DEPT COL1
FROM EMPLOYEE) TEMP0
WHERE DEPARTMENT.DPT_ID = TEMP0.COL1
Join Tables
Specify to use the JOIN clause from the Ansi-92 SQL standard when generating the SQL alternatives. During the
optimization, the SQL statement is converted to the Ansi-92 SQL standard and then the SQL syntax transformation
rules are applied to rewrite the converted SQL statement. Next, the Oracle hints are applied to the original SQL and
the transformed SQL. So you may see SQL alternatives that use the join syntax from the original statement SQL,
but these SQL alternatives are simply the original SQL with an Oracle hint applied.
The OUTER JOIN is not including in this conversion because Ansi-92 OUTER JOIN syntax does not always retrieve
the same result set as the OUTER JOIN using the (+) operator. So to avoid producing the wrong result set, the
conversion of the OUTER JOIN syntax cannot be applied.
- 59 -
Quest SQL Optimizer for Oracle – Users Guide
For example:
SELECT DPT_ID
FROM EMPLOYEE
INNER JOIN DEPARTMENT
ON EMP_DEPT = DPT_ID
Specify to join tables in the FROM clause without the JOIN syntax or using a comma. The join analysis occurs in the
WHERE clause which specifies that the column in one table is compared to a column in another table. During the
optimization, the SQL statement is converted from the Ansi-92 SQL standard and then SQL syntax transformation
rules are applied to rewrite the converted SQL. Next, the Oracle hints are applied to the original SQL and the
transformed SQL. So you may see SQL alternatives that use the JOIN syntax from the original SQL statement, but
these SQL alternatives are simply the original SQL with an Oracle hint applied.
The OUTER JOIN is not including in this conversion because Ansi-92 OUTER JOIN syntax does not always retrieve
the same result set as the OUTER JOIN using the (+) operator. So to avoid producing the wrong result set, the
conversion of the outer join syntax cannot be applied.
For example:
SELECT DPT_ID
FROM EMPLOYEE,
DEPARTMENT
WHERE DPT_ID = EMP_DEPT
Specify to join tables in the FROM clause with or without join type syntax (excluding OUTER JOIN operator).
Hints
Optimization Approaches
The Optimization Approaches hints page under the Optimizer branch of the Options window allows you to decide
which Oracle optimization hints are applied to the original SQL statement and the alternative SQL generated during
the optimization process. The optimization hints are selected from 6 pages: Access Paths Hints, Join Order Hints,
Optimization Approaches Hints, Parallel Execution Hints, Query Transformation Hints, and Other Hints.
By adding hints, the Oracle optimizer can be forced to choose a particular execution plan.
- 60 -
Quest SQL Optimizer for Oracle – Users Guide
Optimization Approaches
Hint Description
ALL_ROWS The ALL_ROWS hint suggests executing a SQL statement with the objective of
returning all rows as fast as possible.
FIRST_ROWS The FIRST_ROWS hint suggests executing a SQL statement with the objective of
finding the shortest time for the return of the first row from the query.
FIRST_ROWS (N) The FIRST_ROWS(N) hint return the first n rows as fast as possible.
RULE The RULE hint suggests using the rule-based approach even if statistics are
available.
Note: The RULE optimization hint does not retrieve an Oracle Cost value.
CPU _COSTING The CPU_COSTING hint turns CPU costing on for the SQL statement. The Oracle
optimizer estimates the number and type of I/O operations and the number of CPU
cycles that will be performed during execution. System statistics are used to convert
the CPU cycles and I/O operations to the estimated query execution time. The
CPU_COST column of the PLAN_TABLE stores the CPU cost.
NO_CPU _COSTING The NO_CPU_COSTING hint turns off CPU costing for the SQL statement. The Oracle
optimizer uses the I/O cost model, which measures everything in single-block reads
and ignores the CPU cost.
Access Paths
The Access Paths hints page under the Optimizer branch of the Options window allows you to decide which Oracle
optimization hints are applied to the original SQL statement and the alternative SQL generated during the
optimization process. The optimization hints are selected from 6 pages: Access Paths Hints, Join Order Hints,
Optimization Approaches Hints, Parallel Execution Hints, Query Transformation Hints, and Other Hints.
- 61 -
Quest SQL Optimizer for Oracle – Users Guide
By adding hints, the Oracle optimizer can be forced to choose a particular execution plan.
Access Paths
Hint Description
FULL The FULL hint suggests using a full table scan to access a table.
ROWID The ROWID hint suggests that a table is scanned using the rowid.
CLUSTER The CLUSTER hint suggests that a table is scanned using a cluster scan. This hint is only
useful if you have clustered objects.
HASH The HASH hint suggests that a table is scanned using a hash scan. It is used only if the
tables are stored in a cluster.
INDEX The INDEX hint suggests to use a specific index to access a table.
NO_INDEX The NO_INDEX hint will not use an index scan to access a table.
INDEX_ASC The INDEX_ASC hint suggests to use a specific index to access a table. The index entries
are scanned in ascending order.
INDEX_DESC The INDEX_DESC hint suggests to use a specific index to access a table. The index entries
are scanned in descending order.
INDEX_COMBINE The INDEX_COMBINE hint suggests that a table is accessed using a bitmap access path.
INDEX_JOIN The INDEX_JOIN hint suggests that an index join be used to access a table.
INDEX_FFS The INDEX_FFS hint suggests that a fast full index scan be used to access a table.
NO_INDEX_FFS The NO_INDEX_FFS hint suggests that an index full fast scan not be used.
INDEX_SS The INDEX_SS hint suggests to use an index skip scan.
NO_INDEX_SS The NO_INDEX_SS hint suggests not to use an index skip scan.
INDEX_SS_ASC The INDEX_SS_ASC hint suggests to use an index skip scan in ascending mode.
INDEX_SS_DESC The INDEX_SS_DESC hint suggests to use an index skip scan in descending mode.
- 62 -
Quest SQL Optimizer for Oracle – Users Guide
Query Transformation
The Query Transformation Hints under the Optimizer branch of the Options window allows you to decide which
optimization hints are applied to the original SQL statement and the alternative SQL generated during the Oracle
optimization process. The optimization hints are selected from 6 pages: Access Paths Hints, Join Order Hints,
Optimization Approaches Hints, Parallel Execution Hints, Query Transformation Hints, and Other Hints.
By adding hints, the Oracle optimizer can be forced to choose a particular execution plan.
Query Transformation
Hint Description
STAR_TRANSFORMATION The STAR_TRANSFORMATION hint forces the Oracle optimizer to use the best
execution plan in which the internal transformation has been used. This hint
can be beneficial when many small tables are joined to a central large table
via single column bitmap indexes.
NO_STAR_TRANSFORMATION Suggests to not use the star query transformation.
USE_CONCAT Suggests that all ORs in the WHERE cause be transferred to a query using
UNION ALL.
NO_EXPAND Suggests not using the OR expansion for SQL statements which have an OR
or IN condition in the WHERE clause.
MERGE Suggests merging a view on a per-query basis so that it will evaluate
complex views or subqueries before the main query.
REWRITE The REWRITE hint enables internal transformation from a SQL statement and
transforms tables or views into a SQL statement accessing one or more
materialized views.
NO_REWRITE Suggests disabling internal SQL rewrites.
- 63 -
Quest SQL Optimizer for Oracle – Users Guide
NO_FACT Suggests that the specified table should not be used as a fact table.
NO_QUERY_TRANSFORMATION Prevents the Oracle optimizer from performing query transformations.
UNNEST Suggests that the a subquery be merged into the main portion of a statement
which enables the Oracle optimizer to evaluate the tables in the subquery
along with the tables in the main portion when determining joins and access
paths.
NO_UNNEST Suggests disabling subquery unnesting.
Join Order
The Join Order hints page under the Optimizer branch of the Options window allows you to decide which Oracle
optimization hints are applied to the original SQL statement and the alternative SQL generated during the
optimization process. The optimization hints are selected from 6 pages: Access Paths Hints, Join Order Hints,
Optimization Approaches Hints, Parallel Execution Hints, Query Transformation Hints, and Other Hints.
By adding hints, the Oracle optimizer can be forced to choose a particular execution plan.
Join Order
Hint Description
LEADING Suggests using the specified tables be used first in the join order.
USE_HASH Suggests using a hash join method for joining two tables.
NO_USE_HASH Suggests using some other join method besides a hash join to join for joining two
tables.
USE_MERGE Suggests using sort-merge joins for joining two tables.
NO_USE_MERGE Suggests using some other join method besides a sort-merge join for joining two
tables.
USE_NL Suggests using a nested loops join for joining two tables.
NO_USE_NL Suggests excluding nested loops joins.
- 64 -
Quest SQL Optimizer for Oracle – Users Guide
USE_NL_WITH_INDEX Suggests using a Use a nested loop join with an index join.
HASH_SJ Suggests using a hash semi-join to access a table in the EXISTS sub-query.
HASH_AJ Suggests using a hash anti-join to access a table for a NOT IN sub-query.
MERGE_SJ The MERGE_SJ hint forces merge semi-join to access a specified table for a
correlated EXISTS sub-query.
MERGE_AJ The MERGE_AJ hint forces merge anti-join to access a specified table for a NOT IN
sub-query.
NL_SJ The NL_SJ hint forces a nested loop anti-join to access a specified table for a
correlated EXISTS sub-query.
NL_AJ The AL_AJ hint forces a nested loop anti-join to access a specified table for a NOT IN
sub-query.
ORDERED The ORDERED hint forces the Oracle optimizer to join tables in the order in which
they appear in the FROM clause.
STAR The STAR hint forces the Oracle optimizer to use nested loop joins to join the largest
table in the SQL statement last. The STAR hint should be applied to SQL statements
with at least 3 tables with the largest table’s concatenated index having at least 3
columns.
Parallel Execution
The Parallel Execution hints page under the Optimizer branch of the Options window allows you to decide which
optimization hints are applied to the original SQL statement and the alternative SQL generated during the Oracle
optimization process. The optimization hints are selected from 6 pages: Access Paths Hints, Join Order Hints,
Optimization Approaches Hints, Parallel Execution Hints, Query Transformation Hints, and Other Hints.
By adding hints, the Oracle optimizer can be forced to choose a particular execution plan.
Parallel Execution
Hint Description
PARALLEL Suggests using parallel processing with the specified number of concurrent servers
(Degree) during an operation.
PARALLEL_INDEX Suggests using parallel processing for a index scan using the specified number of
(Degree) concurrent servers during an operation.
NO_PARALLEL Suggests using serial processing for the execution of this SQL state.
NO_PARALLEL_INDEX Suggests overriding a PARALLEL attribute setting on an index to avoid a parallel index
scan operation.
- 65 -
Quest SQL Optimizer for Oracle – Users Guide
Other
The Other hints page under the Optimizer branch of the Options window allows you to decide which Oracle
optimization hints are applied to the original SQL statement and the alternative SQL generated during the Oracle
optimization process. The optimization hints are selected from 6 pages: Access Paths Hints, Join Order Hints,
Optimization Approaches Hints, Parallel Execution Hints, Query Transformation Hints, and Other Hints.
By adding hints, the Oracle optimizer can be forced to choose a particular execution plan.
Other
Hint Description
DRIVING_SITE Suggests that the rows retrieved from one table are sent to the remote site to be
joined there and the results are returned to the local site. This hint is only
applicable for distributed SQL statements.
ORDERED_PREDICATES Suggests that the items in the WHERE clause be evaluated in the order they are
presented, except for a predicate that is used as an index key.
CURSOR_SHARING_EXACT If the Oracle CURSOR_SHARING parameter is enabled, this hint will disable it for
the execution of this SQL statement.
PUSH_SUBQ Suggests that, when a subquery is not being joined using the merge join method,
it be evaluated as soon as possible.
PUSH_PRED Pushes the outer join predicate between a table and a view into the view.
NO_PUSH_PRED Prevents pushing the outer join predicate between a table and a view into the
view..
NO_PUSH_SUBQ Suggests that, when a subquery is not being joined using the merge join method,
it be last.
DYNAMIC_SAMPLING Suggests performing a dynamic sampling to provide more accurate estimates of
the cardinality and selectivity of the data.
SPREAD_MIN_ANALYSIS Minimizes the rules' compile time on spreadsheets.
- 66 -
Quest SQL Optimizer for Oracle – Users Guide
Quota
Quotas are used to control the number of SQL alternatives that are generated by the optimization process since
thousands of alternatives may be generated for a complicated SQL statement.
The first step of the SQL optimization process is to rewrite the syntax of the original SQL statement. The Syntax
transformation quota is applied to this step. Then the Oracle optimization hints are added to the original SQL
statement and the SQL alternatives. The Hints Quota is applied to this second step.
Note: Bear in mind that the higher the quotas, the longer it may take to optimize a complicated SQL statement.
- 67 -
Quest SQL Optimizer for Oracle – Users Guide
This table order rearrangement is actually one of the rules in the Syntax Transformation rules which are applied in
the first step of the optimization process. The Table join permutation quota is used to control how many SQL
syntax transformations are created using only this one rule. This is to prevent all syntax transformations from
being created using only this one rule.
If you use 2 tables in a SQL statement, there are 2 ways you can join the tables. If you use 3 tables, the number of
ways you can join the tables is 3! (3*2*1) or 6 ways, which means the optimization process could generate 6 SQL
statements.
If you have 6 tables using 6! which is 720, the optimization process could generate 720 SQL statements using this
one syntax transformation rule. If the quota for SQL syntax (the Syntax transformation quota) is 100, then you can
see that one rule which could generate 720 statements could use up the entire quota. The SQL Optimizer Engine
has more than 60 other rules to apply to the original SQL statement to find alternative ways to write syntax. So,
the Table join permutation quota limits the number of attempts that the SQL Optimizer Engine will try to find a
driving path by rearranging the order in which the tables are joined.
After the syntax of a SQL statement is transformed during the optimization process, the Oracle optimization hints
are applied to the original SQL statement and the SQL alternatives. When a SQL statement has several SELECT
statements contained within it, the hints are applied in the following manner.
For a SQL statement with multiple SELECTs such as this one:
SELECT *
FROM DEPARTMENT
WHERE DPT_ID IN (SELECT EMP_DEPT
FROM EMPLOYEE
WHERE EMP_ID > @emp_id)
AND exists (SELECT *
FROM EMPLOYEE E
WHERE NOT EXISTS (SELECT 'X'
FROM EMP_SMALL S
WHERE S.EMP_ID = E.EMP_ID))
AND DPT_MANAGER IN (73716, 73745, 76777)
First Transformation
SELECT /*+ First Rows*/ *
&ldots;IN (SELECT &ldots;
AND exists (SELECT *
&ldots; (SELECT 'X' &ldots;))
Second Transformation
SELECT /*+ First Rows*/ *
&ldots;IN (SELECT /*+ First Rows*/ &ldots;
AND exists (SELECT *
&ldots; (SELECT 'X' &ldots;))
Third Transformation
- 68 -
Quest SQL Optimizer for Oracle – Users Guide
The SQL Optimizer tries every possible combination of the first hint, in this case /*+ First Rows*/. In this example,
there are 15 different transformations using only the first hint. Then it moves on to the second hint. It applies the
first hint to one SELECT and the second hint to another SELECT and so one until it tries every possible combination
of applying all the selected hints or it has reached the Quota. This method requires a large Hints Quota if you
would like the optimization process to apply several of the Oracle optimization hints when there are multiple
SELECT statements in one SQL statement.
Index Expert
The Index Expert settings on the Options window consist of 3 pages that allow you to select the level of index
generation intelligence for creating indexes and index types while using the Index Expert.
Settings include:
Intelligence
Options
Index Type
- 69 -
Quest SQL Optimizer for Oracle – Users Guide
The Index Expert Intelligence settings enables you to either customize all the index generate settings used during
creation of index candidates in the Tuning Lab or allows you to select the predefined levels for these settings.
Intelligence Level
Custom
Use Custom to enable you to select the individual settings on the Index Options page.
Predefine
Use Predefined to enable you to select an Intelligence Level which has all the index generation settings preselected
for you. The Index Options page will change according to the level selected. Levels range from 0 to 10. The higher
the level the more intelligent the Index Expert is and the more likely that you will find a better index
recommendation.
The Index Type page settings can be adjusted independent from the Intelligence Level.
- 70 -
Quest SQL Optimizer for Oracle – Users Guide
Options
The Options settings for the Index Expert allows you to select index options used when generating index
alternatives. Some of these options are also used by Global Indexing.
- 71 -
Quest SQL Optimizer for Oracle – Users Guide
Automatically enforce cost based index simulation when statistics are not collected
Using ALL_ROWS
Using FIRST_ROWS
Specify whether to force cost-based index simulation when statistics are not available on a table. You can
select that the Oracle ALL_ROWS and FIRST_ROWS hints added to the original SQL statement to force the
use of the cost-based optimizer.
Important Note: The Oracle virtual index function used by the Index Expert is only available for the cost-
based optimizer. Therefore, if your original SQL statement uses the rule-based optimizer, the index
generation process must force it to use the cost-based optimizer in order for the Index Expert to be able to
generate index candidates for the SQL statement. In this case, you need to take into consideration that the
virtual execution plans that are generated for each index set will naturally be different from the actual
execution plan retrieved if you actually created these indexes and executed the SQL statement using the
rule-based optimizer.
Eliminate index sets which produce similar execution plan with the same cost
Specify whether to eliminate similar execution plan which has the exact same Oracle cost. Similar execution plans
are plans with the same structure and cost. Selecting this option will possibly reduce the number of Index Sets
generated.
Evaluate columns in SELECT list
Specify whether to consider creating an index on the columns specified in the SELECT list.
Quota
Index prefix
- 72 -
Quest SQL Optimizer for Oracle – Users Guide
Index Type
The Index Type settings for the Index Expert allows you to select the index type. Some of these options are also
used by Global Indexing.
Index Type
Execution Plan
- 73 -
Quest SQL Optimizer for Oracle – Users Guide
Best Practices
The Best Practices module in the Tuning Lab reviews the tables, indexes, database statistics, and the execution
plan used in your original SQL statement and provides recommendations. By default, this is not displayed in the
Tuning Lab. You can select to display this module from the Best Practices General option page.
Some of the recommendations are based on the values in Best Practices option settings.
The Option settings include:
General
Table
Index
Statistics
Plan
Note: If the Best Practices function is taking a long time to complete, you can set one or more of these option
settings to speed up the process.
- 74 -
Quest SQL Optimizer for Oracle – Users Guide
Table
The Best Practices module in the Tuning Lab reviews the tables used in your original SQL statement and provides
recommendations for improving SQL performance. Some of these recommendations are based on the values in
these option settings.
Table
Index
The Best Practices module in the Tuning Lab reviews the indexes on the tables used in your original SQL statement
and provides recommendations for improving SQL performance. Some of these recommendations are based on the
values in these option settings.
- 75 -
Quest SQL Optimizer for Oracle – Users Guide
Index
Consider rebuilding index if % of deleted rows in index is more than (%): (Default = 20, Range 1 to
100)
Specify the percentage of rows that have been deleted to the total number of rows in an index when you should
consider rebuilding the index.
Consider re-creating or rebuilding index if the index has more extents than: (Default = 10, Range 1 to
99,999)
Specify the number of extents an index can have before you should consider rebuilding the index.
Determine selectivity when there are no statistics: (Default = Compute)
Select one of the followin76g:
Options Description
Compute Specify to calculate the selectivity of the index only when the index does not have statistics. If
the index has statistics, than the value from the statistics is used.
Compute All Specify to calculate the selectivity for all indexes even if an index has statistics.
Note: This option may take some time as the selectivity value is calculated for every index.
Ignore Specify to skip an index that does not have statistics and consequently, you will not be warned
when the selectivity of the index is low. If the index has statistics, than the value from the
statistics is used.
Warning when selectivity for the index is less than (%): (Default = 20, Range 1 to 100)
Specify the percentage for the selectivity of the index when you should consider disabling the index for a SQL
statement so that SQL statement will be executed using a full table scan instead of using the index.
Compute selectivity by sampling (%): (Default = 0.10, Range 0.0001 to 99.99)
Specify the percentage of the data that will be used to calculate the selectivity when you have selected the
Compute or Compute all option to determine the selectivity. This option is used when you are connected to
Oracle 9i and later. It uses the SAMPLE BLOCK clause to determine the selectivity: SELECT * FROM TABLE SAMPLE
BLOCK n. With this clause, only part of the table is scanned to calculated the selectivity for the index.
For 8i and below, the selectivity is calculated by sending a "SELECT COUNT(*)..." to the database.
The selectivity is calculated using the following formula:
Selectivity=count(unique values of a column) / count(all values of a column) * 100%
Note: If the table has a large number of rows, this action will take a while to complete.
Determine if index tree is unbalanced (Default = Ignore)
Specify to check an index to see if the tree is unbalanced, or in other words if one branch has more nodes than
another branch. When the index tree is unbalanced, an index scan will take longer.
- 76 -
Quest SQL Optimizer for Oracle – Users Guide
Statistics
The Best Practices module in the Tuning Lab reviews the statistics for the tables and indexes used in your original
SQL statement and provides recommendations for improving SQL performance. Some of these recommendations
are based on the values in this option setting.
Statistics
Warning for stale statistics when data changes are greater than (%): (Default = 10, Range 1 to 100)
Specify what percentage of the data in a table must have been modified since the last time the statistics were
updated in order to receive a message that the statistics may need to update again.
Plan
The Best Practices module in the Tuning Lab reviews the execution plan for your original SQL statement and
provides recommendations for improving SQL performance. Some of these recommendations are based on the
values in these option settings.
Plan
Threshold for small table with full table scan when it has fewer blocks than: (Default 10, Range 1 to
99,999)
Specify your definition for the size of a small table by entering the number of blocks in the table. This is the table
size when you would consider keeping a small table in cache. This message will appear when a table is less than or
equal to the value you specify.
Warning for large table with full table scan when it has more blocks than: (Default 200, Range 1 to
99,999)
Specify your definition for a large table by entering the number of blocks in the table. This is the table size when
you would consider optimizing a SQL statement that is doing a full table scan. This message will appear when a
table is greater than or equal to the value you specify and a TABLE ACCESS FULL operation is found in the
execution plan of the SQL statement.
- 77 -
Quest SQL Optimizer for Oracle – Users Guide
Execution
Execution Criteria
The Execution Criteria page under the Tuning Lab allows you to select the options when executing the SQL
alternatives and index sets.
- 78 -
Quest SQL Optimizer for Oracle – Users Guide
statement does not need to be cached. Also, if some of the SQL statements use different indexes, one index
may be resident in the cache and the other may not. So running the SQL statements twice, makes sure that
each index is cached.
This option eliminates time variation caused by caching since it runs all SQL statements twice, throws out the
first execution time when the caching would occur and uses the second run time when all SQL statements
and indexes should have the necessary items in the cache. Consequently, the time to cache has been
eliminated and you get a more accurate comparison of the run time of each alternative SQL statement.
All SQL once
For long running SQL, there is no need to run any statement twice since the effect from caching is diminished
over time.
- 79 -
Quest SQL Optimizer for Oracle – Users Guide
Execution Method
The Execution Method page under the Tuning Lab allows you to select the options when executing the SQL
alternatives and index sets.
Execution Method
- 80 -
Quest SQL Optimizer for Oracle – Users Guide
When SELECT SQL statements are executed, a comparison of the result is done to further insure that result set for
an alternative SQL statement is the same as the original SQL statement. When you select the Run on Client
option, the comparison is done between the hash values of the data. To compare the result set of the original and
alternative SQL statements, each row of the result set is hashed and then the hash values are stored in the
memory of the client computer to compare the hash results of the original SQL statement with the hash results of
the SQL alternatives. The data is not stored in memory nor on the disk drive of the client computer.
Limit rows retrieved to (Default = unchecked) (Default = 100, Range 100 to 32,767)
Specify the number of rows you want retrieved during the execution. The default value is 100.
Important Note: If you enable this feature, remember that this is not comparing the way the SQL
statement is actually being executed in the application since you are not retrieving all of the data. It is good
only for a quick test. The execution results may be different when you retrieve all the records.
Number of rows returned in a single network transfer (Default = 1000, Range 25 to 32,767)
Specify the number of rows that will be retrieved at one time when fetching the data from the server.
Multi-Execute
- 81 -
Quest SQL Optimizer for Oracle – Users Guide
Auto Execution
The Auto Execution page under the Tuning Lab allows you to select the options used when executing the SQL
alternatives and index sets.
- 82 -
Quest SQL Optimizer for Oracle – Users Guide
Auto Execution
Memory Thresholds
The chart below these options shows the current memory usage on your client computer and the values that you
select for these options.
The options for executing SQL statements are shared between the Tuning Lab and Global Indexing. The execution
settings for Global Indexing are found under the Tuning Lab Execution Criteria and Execution Method options.
Some of the options for generating indexes are shared between the Tuning Lab/Index Expert and Global Indexing.
These settings are found under the Tuning Lab/Index Expert Options and Index Type.
- 83 -
Quest SQL Optimizer for Oracle – Users Guide
The Impact Analyzer page in the Options window allows you to select the language for the data in the database for
the Impact Analyzer module.
Character Set
Character set
Specify the language set that is used to enter and display the SQL text and the data from the database. This
setting does not affect the language of the program interface. It is always in English.
Outlines Options
General
- 84 -