Troubleshooting optimization guidelines and profiles
Diagnostics support for optimization guidelines (passed by optimization profiles) is provided by EXPLAIN tables.
You will receive an SQL0437W warning with reason
code 13 if the optimizer does not apply an optimization guideline.
Diagnostic information detailing why an optimization guideline was
not applied is added to the EXPLAIN tables. There are two EXPLAIN
tables for receiving optimizer diagnostic output:
- EXPLAIN_DIAGNOSTIC - Each entry in this table represents a diagnostic message pertaining to the optimization of a particular statement. Each diagnostic message is represented using a numeric code.
- EXPLAIN_DIAGNOSTIC_DATA - Each entry in this table is diagnostic data relating to a particular diagnostic message in the EXPLAIN_DIAGNOSTIC table.
The following steps can help you troubleshoot problems that occur
when you are using optimization guidelines:
- Verify that optimization guidelines have been used.
- Examine the full error message using the built-in EXPLAIN_GET_MSGS table function.
If you finish these steps but cannot yet identify the source of the problem, begin collecting diagnostic data and consider contacting IBM Software Support.
CREATE TABLE EXPLAIN_DIAGNOSTIC
( EXPLAIN_REQUESTER VARCHAR(128) NOT NULL,
EXPLAIN_TIME TIMESTAMP NOT NULL,
SOURCE_NAME VARCHAR(128) NOT NULL,
SOURCE_SCHEMA VARCHAR(128) NOT NULL,
SOURCE_VERSION VARCHAR(64) NOT NULL,
EXPLAIN_LEVEL CHAR(1) NOT NULL,
STMTNO INTEGER NOT NULL,
SECTNO INTEGER NOT NULL,
DIAGNOSTIC_ID INTEGER NOT NULL,
CODE INTEGER NOT NULL,
PRIMARY KEY (EXPLAIN_REQUESTER,
EXPLAIN_TIME,
SOURCE_NAME,
SOURCE_SCHEMA,
SOURCE_VERSION,
EXPLAIN_LEVEL,
STMTNO,
SECTNO,
DIAGNOSTIC_ID),
FOREIGN KEY (EXPLAIN_REQUESTER,
EXPLAIN_TIME,
SOURCE_NAME,
SOURCE_SCHEMA,
SOURCE_VERSION,
EXPLAIN_LEVEL,
STMTNO,
SECTNO)
REFERENCES EXPLAIN_STATEMENT ON DELETE CASCADE);
CREATE TABLE EXPLAIN_DIAGNOSTIC_DATA
( EXPLAIN_REQUESTER VARCHAR(128) NOT NULL,
EXPLAIN_TIME TIMESTAMP NOT NULL,
SOURCE_NAME VARCHAR(128) NOT NULL,
SOURCE_SCHEMA VARCHAR(128) NOT NULL,
SOURCE_VERSION VARCHAR(64) NOT NULL,
EXPLAIN_LEVEL CHAR(1) NOT NULL,
STMTNO INTEGER NOT NULL,
SECTNO INTEGER NOT NULL,
DIAGNOSTIC_ID INTEGER NOT NULL,
ORDINAL INTEGER NOT NULL,
TOKEN VARCHAR(1000),
TOKEN_LONG BLOB(3M) NOT LOGGED,
FOREIGN KEY (EXPLAIN_REQUESTER,
EXPLAIN_TIME,
SOURCE_NAME,
SOURCE_SCHEMA,
SOURCE_VERSION,
EXPLAIN_LEVEL,
STMTNO,
SECTNO,
DIAGNOSTIC_ID)
REFERENCES EXPLAIN_DIAGNOSTIC ON DELETE CASCADE);
Note: The EXPLAIN_REQUESTOR, EXPLAIN_TIME, SOURCE_NAME, SOURCE_SCHEMA,
SOURCE_VERSION, EXPLAIN_LEVEL, STMTNO, and SECTNO columns are part
of both tables in order to form the foreign key to the EXPLAIN_STATEMENT
table and the parent-child relationship between EXPLAIN_DIAGNOSTIC
and EXPLAIN_DIAGNOSTIC_DATA.
This DDL is included in the EXPLAIN.DDL file located in the misc subdirectory of the sqllib directory.