The FOCUS for SQL EXPLAIN utility is an interactive development tool that helps you fine-tune FOCUS query performance. It invokes the RDBMS EXPLAIN function to analyze the efficiency of data retrieval paths for TABLE requests; you cannot use the EXPLAIN utility with MODIFY, MAINTAIN, or MATCH FILE requests. The analysis result is displayed in the FOCUS Hot Screen facility; you can save or print it for further examination. |
In this section: |
This section provides:
Given a TABLE request, the EXPLAIN utility executes the data adapter and generates SQL statements using its normal mechanisms, the FOCUS TABLE parser and Dialogue Manager.
However, instead of processing the request, FOCUS directs the RDBMS to invoke its own native EXPLAIN function and analyze the generated statements. The analysis produces a detailed evaluation of the access path, the methodology for retrieving the data for that request.
The RDBMS places this access path information into a table (DB2) or set of tables (DB2 for VM). The FOCUS EXPLAIN utility reads these tables and generates a clear and detailed report containing valuable information about the performance characteristics of your query, information that anyone familiar with the RDBMS and its performance characteristics can understand and analyze.
Enter FOCUS and execute the EXPLAIN utility with the following syntax
EX expproc
where:
EXPDB2
Is the FOCEXEC that invokes the DB2 EXPLAIN function.
EXPSQL
Is the FOCEXEC that invokes the DB2 for VM EXPLAIN function.
EXPDBC
Is the FOCEXEC that invokes the Teradata EXPLAIN function.
Press the Enter key.
Note: If the IM parameter was set to zero when the data adapter was installed, you do not have access to the EXPLAIN utility; the data adapter will generate error message FOC1638 if you attempt to use it. See the data adapter installation instructions for more information.
The EXPLAIN utility cannot analyze an interactive TABLE request; you must provide the name of a FOCEXEC on the main window. However, you can access the TED editor from the FOCUS EXPLAIN utility and create or change the TABLE request at will.
If you do not have the tables required for executing the RDBMS EXPLAIN function, the FOCUS EXPLAIN utility attempts to create them. In DB2, you need appropriate authorization for creating tables, otherwise an SQLCODE of -551 results. The report results from the FOCUS EXPLAIN utility are displayed in Hot Screen; you can save or print them for later examination.
The main window presents three choices:
To make a selection, move your cursor under one of the numbers and press the Enter key. To exit the utility and return to the FOCUS command line, press the PF3 key. The choices are:
1. |
Explain a FOCEXEC |
Invokes the RDBMS EXPLAIN command for the TABLE request in your FOCEXEC. |
2. |
Edit a FOCEXEC |
Invokes the TED editor from within the FOCUS EXPLAIN utility. You can create a new FOCEXEC or edit an existing one. |
3. |
Leave this utility |
Returns you to FOCUS, deleting any entries made in the RDBMS EXPLAIN tables. |
At any point, you can use the PF3 key to return to a previous window.
If you select Choice 1 or 2, you are asked for the name of your FOCEXEC:
If you are creating a new FOCEXEC, the same FOCEXEC naming conventions apply here as for the FOCUS EXECUTE (EX) command. Specify the MVS member name or the CMS filename. If you have already used TED (Choice 2), the name of the most recent FOCEXEC is automatically supplied.
Press the Enter key and continue with either the EXPLAIN option or the TED editor:
For DB2 and DB2 for VM, the option to explain a FOCEXEC requires a query number, an internal control number used by the RDBMS when populating the EXPLAIN tables. You can choose any number between 1 and 32,767. However, if you choose a number that already exists, the EXPLAIN utility informs you of its existence and deletes all entries with that number before processing your request. Therefore, make sure the number you choose does not correspond to an existing entry that you would like to keep. If there are no existing entries in the EXPLAIN tables, any number will do.
For Teradata, no query number is needed. If you are prompted for a query number, press Enter again.
For example, the query number 1000 has been entered on the following screen:
At this point, the message PLEASE WAIT, PROCESSING YOUR REQUEST displays, followed by your EXPLAIN report.
Your EXPLAIN report is displayed in the Hot Screen facility. All Hot Screen options are available. When you exit Hot Screen, you return to the first window and can evaluate another request.
Note:
FOCEXEC RPT1 contains the following TABLE request:
TABLE FILE INVQ5
SUM PRICE BY PARTNO
WHERE DESCRIPTION EQ 'BOLT' OR 'NUT' OR 'SCREW'
WHERE PRICE GT .30
IF TOTAL PRICE GT 1
END
The EXPLAIN output consists of two reports. The first is a one-page report:
PAGE 1 |
The second is a four-page report:
PAGE 1 |
PAGE 2 |
PAGE 3 |
PAGE 4 |
For information about the EXPLAIN report, consult the DB2 Administration Guide.
Suppose you want to analyze the following request, stored as SAMP1 FOCEXEC:
JOIN EMP_ID IN EMPINFO TO ALL WHO IN FUNDTRAN
TABLE FILE EMPINFO
WRITE AVE.CURRENT_SALARY ED_HRS BY WHO BY LAST_NAME
IF DEPARTMENT_CD IS MIS
END
The EXPLAIN utility produces a two-page report:
PAGE 1 EXPLAIN REPORT FOR SAMP1 RUN ON 10/10/99 -_ 1) First, we lock JANE.T2 for read, and we lock JANE.T1 for read. |
PAGE 2 EXPLAIN REPORT FOR SAMP1 RUN ON 10/10/99 |
Information Builders |