立即与支持人员聊天
与支持团队交流

SQL Optimizer for DB2 LUW 4.4.1 - User Guide

SQL Optimizer for IBM® DB2® LUW
UsageStatistics Getting Started Options SQL Scanner SQL Optimizer SQL Formatter SQL Inspector Database Explorer SQL Repository Index Impact Analyzer Index Usage Analyzer User-Defined Temp Table Editor Functions SQL Functions SQL Information and Functions Activity Log
Tutorials About us Copyright

About the SQL Rewrite Function

The SQL Rewrite function analyzes the input SQL statement and uses an Artificial Intelligence Engine to produce a group of semantically equivalent versions of the statement, known as SQL alternatives. You can then test run these alternatives in the SQL Optimizer window to determine the best-performing version of the SQL.

Tip: After you run SQL Rewrite, run the Generate Indexes function to add alternatives that incorporate virtual indexes. You can then test run the SQL alternatives along with index-set alternatives to measure performance. See Generate Index-Set Alternatives for more information.

The SQL Rewrite process includes these phases:

Show Plan

Retrieves the access plan and the DB2 optimized text that the DB2 LUW optimizer has chosen for the specific SQL alternative. SQL Rewrite classifies the SQL statement according to characteristics that cause performance problems. 

Rewrite

Rewrites the original SQL statement to produce a list of semantically equivalent versions, or SQL alternatives.

Run Time/Batch Run

Allows the users to test run the original and the SQL alternatives to select which SQL version gives the best performance. For each alternative, Batch Run provides the run time for retrieving all records and for retrieving only the first record. You can use this information to identify which alternative is most suitable for your application.

Execute

Executes alternatives against the original SQL and displays the returned data for comparison in the SQL Optimizer window.

 

Related Topics

What Function Should l Use to Retrieve the Run Time?

The SQL Optimizer provides two different measurements of performance; the run time for retrieving all records and the run time for retrieving the first n records. Both measurements give you an indication on the fastest running SQL statement—but with two different aims. You must understand the use of the SQL statement in the application. Generally, if the SQL statement is used for reports, then you should use the Run for All Record or Batch Run with Run Time Mode set to All Records. If the SQL statement is used for online query, then use the Run for First Record or Batch Run with Run Time Mode set to First n Record.

Note: If the aim of the SQL statement is unknown, then use All Records as a performance indication.

 

Unsatisfactory Performance Results

After optimization and execution testing, you may discover that the performance of the optimized SQL statements is still not satisfactory. To remedy this, first check that the searching quota has not been reached in the Optimization Details window. If it has, then you should increase the intelligence level or optimization options in the Options window and optimize again to ensure all transformed SQL statements are given. Rerun the SQL statement optimization after the review.

You can also review the access plan of the optimized SQL statement to check if there should be any alterations to the database structure such as adding a new index. The Index Expert module is used to generate alternative Index Sets for a SQL statement.

 

SQL Functions

The following SQL Functions are available in the SQL Optimizer window to retrieve the access plan, the run time, result set and to convert parameter markers:

Show Plan

Run Result (SQL alternatives only)

Run for First Record

Record for All Records

Convert Parameter Markers

Test for Scalability

 

相关文档

The document was helpful.

选择评级

I easily found the information I needed.

选择评级