Tuning SQL statements
Use the Tuning Actions window from an editor.
From the pop-up menu action to open the Tuning Actions window, you can choose these actions:- Visual Explain: Generates a graphical representation of a query path.
- Statistics Advisor: Generates RUNSTATS for a query.
- Capture Query Environment: Captures the runtime environment for a query.
Before you start
- Gather the following information from a Db2 for z/OS administrator:
- The port to use to connect to the server.
- The name of a database connection profile that has EXPLAIN tables configured. During the following procedure, you can also create a database connection profile and generate EXPLAIN tables for it.
- To create a connection to the server:
- In the Remote Systems view, expand a z/OS system connection, and then expand the Db2 for z/OS subsystem.
- Right-click SQL Tuning Services Servers and select .
- Log in to the remote system using your Db2 user ID and password.
- Enter the HTTP port into the Port text field.
- Optionally, you can customize the host, connection name, user, or password for the connection.
- Select the Test Connection to validate the settings enable connectivity.
- Select the Apply and Close button to save your connection settings.
- To configure tuning services of your Db2 for z/OS connection:
- In the Db2 for z/OS subsystem, expand Db2 for z/OS Connections, right-click a database connection, and select Properties.
- From the list of properties pages, click Tuning.
- From the SQL Tuning Services server list, select the tuning server to use when tuning statements in files associated with this Db2 for z/OS connection.
- Optionally, if you want to use a tuning profile, check the Use tuning connection profiles checkbox. Then select a pre-existing Database connection profile from the list or use the New button to create a profile.
- To use Multi-Factor Authentication (MFA) when performing tuning operations, make sure the Use tuning connection profiles checkbox is unchecked, and on the General tab of your Db2 for z/OS Connection set the Login Method to MFA Token. When these options are selected, you will be prompted to enter an MFA token each time you send a tuning request.
- Click Apply and Close.
- Getting started with SQL Tuning Services (links to the IBM Documentation for Db2 for z/OS)
- Investigating SQL performance by using EXPLAIN (links to the IBM Documentation for Db2 for z/OS)
- Creating a database profile and EXPLAIN tables
Tuning SQL
After you connect to a Db2 SQL Tuning Services server, you can select and tune SQL statements from the COBOL, PL/I, SQL, or z Systems® LPEX Editor.
- Open the editor on a file that contains SQL statements.
- Select an SQL statement, and then right-click and select
(Ctrl+Alt+T or
⌥+⌘+T).Tip: To set options for the Tune SQL commands select the Tune SQL Options menu item. The context-sensitive helps contain descriptions of the options on the Tune SQL Options page.
- On the Tuning Actions window,
select one or more tuning actions, and then click OK.
The tuning data is displayed in the Remote System Details view.
- To see the output of each tuning action, select it and click Open Results.
Tuning without a Tuning Profile
If you decide to not use a tuning profile, the authentication information of the Db2 for z/OS) connection associated with the edited file will be used to establish connectivity from the tuning server to the Db2 for z/OS server. Tuning without a profile supports security mechanism 3 (User ID and Password) and is required for security mechanism 7 and 9 (Encrypted User ID and Password).
If you are tuning SQL without a tuning profile and you are using MFA, you will be prompted to enter an MFA token twice: when you first connect to the Db2 for z/OS) server and again when you initiate the tuning action. The tokens must be unique. Use the IBM Verify app to generate these MFA tokens.