Question

I have generated an access plan for a query using db2exfmt utility but I'm unable to understand the same.

Please can anyone explain me the access plan (like what the numbers in brackets means, /-----+------\ etc)

    Access Plan:
    -----------
    Total Cost:    15.1619
    Query Degree:  1

          Rows 
         RETURN
         (   1)
          Cost 
           I/O 
            |
            3 
         HSJOIN
         (   2)
         15.1619 
            2 
     /-----+------\
    4                3 
 TBSCAN           TBSCAN
 (   3)           (   4)
 7.58097          7.58036 
    1                1 
    |                |
    4                3 
 TABLE: DB2INST1  TABLE: DB2INST1
  TABA             TABB
   Q2               Q1
Was it helpful?

Solution

Read it from the bottom up. Each node is an operation that is done to satisfy the query. TBSCAN means that the entire table is scanned (which will often happen when your tables are small). HSJOIN is a 'Hash Join' -- joining rows from two tables in memory with a hashmap.

Let's look at one node

          4
       TBSCAN
       (   3)
       7.58097
          1
          |
          4
   TABLE: DB2INST1.TABA

The top '4' is the number of rows returned The next row 'TBSCAN' is the algorithm used (TBSCAN means table scan. HSJOIN means join by hashmap). In DB2, this is called the 'Operator' The '(3)' is the sequence number. You can find this query is decomposed into 4 steps The 7.58097 is the cumulative cost to perform this query up to this step, in something called 'timerons'. It's adjusted based on how your database is configured, and the optimizer will choose an access plan that minimizes this cost The bottom 4 is the cost of the operation in terms of I/O.

There is a lot more information from db2exfmt that you have omitted. But the graph tells you how DB2 will execute the query.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top