Quest SQL Optimizer for IBM® DB2® LUW maximizes SQL performance by automating the manual, time-intensive and uncertain process of ensuring that SQL statements are performing as fast as possible. SQL Optimizer analyzes, rewrites, and evaluates SQL statements within multiple database objects, files, or SQL statements captured by the DB2 Event Monitor. With SQL Optimizer, you can analyze and optimize all your problem SQL from multiple sources. SQL Optimizer also provides you a complete index optimization and plan change analysis solution, from index recommendations to simulated index impact analysis, through comparison of multiple SQL access plans.
SQL Optimizer provides you with the following main modules.
SQL Optimizer (including SQL Rewrite and Generate Indexes functions)
The Batch Run function is used to retrieve run times for a group of index-set and SQL alternatives. You can then evaluate run-time results to determine the best performing alternative.
To setup and start the Batch Run
Click .
The Batch Run Criteria window is divided into the following tabs:
Select the batch run criteria.
The settings can be saved for next optimization by selecting the Save settings for next batch run checkbox. By default, this checkbox is unselected.
The Batch Run window displays the run-time criteria and posts the run time for each alternative as it is retrieved. Stop Current and Stop Batch Run functions are available to terminate the currently running alternative and to stop the Batch Run process. Each selected SQL statement is executed one by one, retrieving the run time unless it is terminated.
To terminate the complete batch run process
Click .
To terminate the current SQL statement
Select SQL | Stop Current.
When you log on to SQL Optimizer, it extracts the logical structure of the database, and maintains this connection throughout the application execution. Another database session is required for when executing the SQL statements for retrieve the run time. This connection is established when the Run for First Record, Run for All Records, or Batch Run functions are initiated and then this new session is dropped after the execution is complete.
SQL Optimizer identifies variables defined within the SQL statement for each SQL or index-set alternative and highlights them in red in the SQL Optimizer window. When the test run process begins, SQL Optimizer prompts you to enter a value for the variable and to select the data type from the Parameters window.
The run time calculation from the Run for All Records, Run for First Record and the Batch Run is used to compare the alternative SQL and index-set alternatives in the SQL Optimizer window. It is used to help determine the best performing SQL statement versions and the best indexes for your applications. All run times are calculated to the nearest milliseconds in the format of HH:MM:SS.MS.
The calculation of the run time is based on the CPU time of the database server. The data is not moved to the client computer.
If you execute an alternative more than once, there will be a slight fluctuation in the run time as database optimizer will store the SQL statement in memory. The optimizer does not need to re-parse the SQL statement because the parse tree and the access plan are already in the available cache. Other factors, such as, memory cache status, data pages and index pages distribution status, also affect the performance of SQL statements. In addition, other jobs may be competing for CPU time while the SQL statement is executing. These factors all contribute to a fluctuation of the run time from one execute to the next.
The execution process retrieves the run time for all records using the following steps.
Set the Row array size for getting elapsed time according to the Options setting on the General tab. This will have the server allocate enough buffer to accommodate the specified number of records for each Fetch call.
Get the current time as the start time.
Run the SQL.
Fetch the data until no more record are returned. Each fetch will retrieve the specific number of records from the Row array size for getting elapsed time setting to the buffer in the database server. Note that records are not actually transferred back to the client but are put into a buffer in database.
Get the current time as the end time.
Calculate the run time (end time - start time = run time).
For example: if you have a SQL that returns 250 records and the Options setting for array size is 100, then the calls that contribute to the run time would be:
Get the current time as the start time.
Execute the SQL.
Fetch (first 100 records)
Fetch (second 100 records)
Fetch (last 50 records)
Get the current time as the end time.
Calculate the run time (end time - start time = run time).
Note: Each of the calls to the network does involve the network time, since the call travels over the network from the client computer to database server. However, the data does not travel over the network, since it is retrieved to a database buffer.
Now with the same SQL but the array size changed to 500, the number of calls would be:
Get the current time as the start time.
Execute the SQL.
Fetch (all 250 records)
Get the current time as the end time.
Calculate the run time (end time - start time = run time).
You can see from this example how the Row array size for getting elapsed time setting in the Options affects the number of fetch calls and in turn affects the amount of network traffic because each fetch travels over the network.
The run time for retrieving the first record is calculated using the following steps.
Set the row array to 1.
Get the current time as the start time.
Run the SQL.
Fetch the first record to the database buffer.
Get the current time as the end time.
Calculate the run time (end time - start time = run time).
© ALL RIGHTS RESERVED. Nutzungsbedingungen Datenschutz Cookie Preference Center