How to find the access path selected by an optimizer for a SQL statement used in a DB2 program?

DB2DatabaseBig Data Analytics

The access path gives us the path selected by the optimizers in order to fetch the result of the SQL query. It gives us an idea about what all indexes and parameters will be used by the optimizer.

To get the details of the access path used for the SQL statements within COBOL-DB2 program we can use the EXPLAIN option during the BIND step. Below is the JCL step which can be used.

//BIND EXEC PGM=IKJEFT01
//STEPLIB DD DSN=DIS.TEST.LOADLIB,DISP=SHR
//SYSOUT DD SYSOUT=*
//SYSTSIN DD *
DSN SYSTEM(TB3)
BIND PLAN(PLANA) -
PKLIST(PACKA) -
ACQUIRE(ALLOCATE) -
ISOLATION (RS) -
EXPLAIN(YES)
/*

The EXPLAIN BIND option with YES parameter will insert the access path related information in the PLAN_TABLE DB2 table. We can refer to this table after the execution of the BIND step to get an idea about the access path.

raja
Published on 11-Sep-2020 12:45:17
Advertisements