The EXPLAIN statement obtains information about access path selection for a SELECT statement. The information obtained is placed in a user table named DB2ePLANTABLE.
The EXPLAIN statement is supported on the following platforms:
Invocation
This statement can be used in an application program using the CLI functions or issued through the CLP.
Syntax
>>-EXPLAIN--SET QUERYNO=integer--FOR--SELECT-statement---------><
Description
Rules
The integer value must be positive.
Notes
create table "DB2ePLANTABLE" (query_no int, plan_no int, table_name char(18), index_name char(18), sort_temp char(1), expl_timestamp timestamp, remarks varchar(300))
Tabelle 15 describes DB2ePLANTABLE columns.
Tabelle 15. DB2ePLANTABLE column information
Example
When developing a new application, it is desirable to determine what access path is chosen for a SELECT statement. In this example, a new application queries the SALES and EMPLOYEES tables. The EXPLAIN statement shows whether the appropriate indexes are chosen for the SELECT statement.
EXPLAIN SET QUERYNO = 100 FOR SELECT E.EMPNAME, S.SALES_AMOUNT FROM SALES S, EMPLOYEES E WHERE S.EMPNO = E.EMPNO AND S.MONTH = ? Index XSALES on SALES(MONTH) Index XEMP on EMPLOYEES(EMPNO) SELECT QUERY_NO, PLAN_NO, TABLE_NAME, INDEX_NAME, SORT_TEMP FROM "DB2ePLANTABLE" QUERY_NO PLAN_NO TABLE_NAME INDEX_NAME SORT_TEMP ------------------------------------------------------------------------------------------- 100 1 SALES XSALES - 100 2 EMPLOYEE XEMP -
Zugehörige Referenzen