DB2 Explain Training

download DB2 Explain Training

of 6

Transcript of DB2 Explain Training

  • 8/7/2019 DB2 Explain Training

    1/6

    (1) Create a PLAN_TABLE in the default database. Ensure that your userID owns the

    object it creates , making it the SCHEMA . Here is the complete DDL .

  • 8/7/2019 DB2 Explain Training

    2/6

  • 8/7/2019 DB2 Explain Training

    3/6

  • 8/7/2019 DB2 Explain Training

    4/6

  • 8/7/2019 DB2 Explain Training

    5/6

    (2) Browse the newly created Plan_Table . It should be empty.

    (3) Select a Table with data. The table T_NLTR_TRD is selected whose creator isNLD1DBO . This table has following indexes defined on it .

    NLTRCU00

    NLTRNN01NLTRNN02

    NLTRCU00 has following columns in it .TRD_SYMB

    TRD_DT

    ACCT_NBRORD_NBR

    ORIG_ID

    NLTRNN01 has following columns in it .

    TRD_STAT

    NLTRNN02 has following columnsDAYOLD_IND

  • 8/7/2019 DB2 Explain Training

    6/6

    (3) Create a SPUFI member for running dynamic EXPLAIN PLAN

    EXPLAIN PLAN SET QUERYNO =1

    FORSELECT * FROM NLD1DBO.T_NLTR_TRD

    WHERE TRD_SYMB = ? AND

    TRD_DT> ? ANDACCT_NBR = ? ;

    This is a EXPLAIN PLAN with Page Range predicate . This means that any column after

    the Page Predicate should not be matched in the search for the data for this SQL to

    execute.

    (4) To validate the PLAN table browse through the newly populated value in it . Or

    run this SPUFI to test it .

    SELECT ACCESSTYPE , MATCHCOLS, ACCESSNAME FROMA367123.PLAN_TABLE

    WHERE QUERYNO=1 ;

    The result is :

    ---------+---------+---------+---------+---------+---------+

    ACCESSTYPE MATCHCOLS ACCESSNAME---------+---------+---------+---------+---------+---------+

    I 2 NLTRCU00

    DSNE610I NUMBER OF ROWS DISPLAYED IS 1