KR editions 104 to 106
KR-104 (EXPLAINing itself-I) Hi everyone,
Have you come across EXPLAIN(NO) in programming (in DB2)?
Note: The table PLAN_TABLE is a standard DB2 table (but it isn't mandatory that it should be present in all systems). If not present then it can be created in the system by the DB admin. Again though the plan table is present the statement table might not be. EXPLAIN can still be used but it will only insert into the plan table.
The access path details (whether index is used etc) can be found in the plan table while the cost of the SQL is present in the statement table. We'll take a closer look into the plan table in the next edition... Tips/facts on EXPLAIN are welcome.
KR-105 (EXPLAIN - II) Hi everyone, Continuing with the EXPLAIN feature..... Some columns in the PLAN_TABLE are: 1)QUERYNO- every SQL is given a query number 2)PROGNAME- the program name 3)METHOD- denotes whether a join has been used (anything other than 0 is a join). 4)TNAME- the table accessed by this SQL. 5)ACCESSTYPE- how the table is being accessed in this SQL (values of I, I1 and N denote indexed access). 6)MATCHCOLS- the number of index columns present in the SQL (the where condition) which can be used by DB2; useful only if the access type is an indexed-access. 7)QBLOCKTYPE - denotes the type of SQL (SELECT or UPDATE etc). Let's say our program (called testcode) has one select SQL: SELECT * FROM mytab.dummy_t WHERE colB='05' AND colC='20' Let's say that our table mytab.dummy_t has an index on columns colA, colB, colC (they are the date columns). The result of EXPLAIN will be: 1)PROGNAME- testcode 2)METHOD- 0 3)TNAME- mytab.dummy_t 4)ACCESSTYPE- I 5)MATCHCOLS - 0 6)QBLOCKTYPE - SELECT Food for thought: Note something peculiar? MATCHCOLS is 0 even though we use are using the index columns in our query! That's all for this week; have a great weekend... any notes or useful points regarding EXPLAIN are welcome.
KR-106(EXPLAIN - III) KR celebrates one year! Continuing with the EXPLAIN command... Recap: Our SQL was SELECT * FROM mytab.dummy_t WHERE colB='05' AND colC='20' and the result in PLAN_TABLE (using EXPLAIN) said that ACCESSTYPE is I and MATCHCOLS is 0. Explanations:
Go back to the main contents page
Copyright © 2020 Sethu Subramanian All rights reserved. Reach me via email at ssbell @ gmail.com