Optimizer messages with DB2 Multisystem
The i5/OS® distributed query optimizer provides you with information messages on the current query processing when the job is in debug mode.
These messages, which show how the distributed query is processed, are in addition to the existing optimizer messages. These messages appear for the Open Query File (OPNQRYF) command, DB2® UDB Query Manager and SQL Development Kit, interactive SQL, embedded SQL, and in any high-level language (HLL). Every message appears in the job log; you only need to put your job into debug mode.
You can evaluate the performance of your distributed query by using the informational messages put in the job log by the database manager. The database manager can send any of the following distributed messages or existing optimizer messages when appropriate. The ampersand variables (&1, &X) are replacement variables that contain either an object name or another substitution value when the message appears in the job log:
- CPI4341 Performing distributed query.
- CPI4342 Performing distributed join for query.
- CPI4343 Optimizer debug messages for distributed query step &1 of &2.
- CPI4345 Temporary distributed result file &4 built for query.
These messages provide feedback on how a distributed query is run, and, in some cases, indicate the improvements that can be made to help the query run faster. The causes and user responses for the following messages are paraphrased here. The actual message help is more complete and needs to be used when you try to determine the meaning and responses for each message.
The following example shows you how to look at the distributed optimizer messages that are generated to determine how the distributed query is processed. The example uses the distributed files, EMPLOYEE and DEPARTMENT.
- CPI4341
- Performing distributed query.
This message indicates that a single distributed file was queried and was not processed in multiple steps. This message lists the nodes of the file where the query was run.
- CPI4342
- Performing distributed join for query.
This message indicates that a distributed join occurred. This message also lists the nodes where the join was run as well as the files that were joined together.
- CPI4343
- Optimizer debug messages for distributed query step &1 of &2.
This message indicates that a distributed query was processed in multiple steps and lists the current step number. Following this message are all the optimizer messages for that step.
- CPI4345
- Temporary distributed result file &4 built for query.
This message indicates that a temporary distributed result file was created and lists a reason code as to why the temporary file was required. This message also shows the partitioning key that was used to create the file and the nodes that the temporary file was created on.
SQL: SELECT A.EMPNO, B.MGRNO, C.MGRNO, D.EMPNO FROM EMPLOYEE A, DEPARTMENT B, DEPARTMENT C, EMPLOYEE D WHERE A.EMPNO=B.MGRNO AND B.ADMRDEPT=C.DEPTNO AND C.DEPTNO=D.WORKDEPT OPNQRYF: OPNQRYF FILE((EMPLOYEE) (DEPARTMENT) (DEPARTMENT) (EMPLOYEE)) FORMAT(JFMT) JFLD((1/EMNO 2/MGRNO *EQ) (2/ADMRDEPT 3/DEPTNO) (3/DEPTNO 4/WORKDEPT))The following list of distributed optimizer messages is generated:
- CPI4343 Optimizer debug messages for distributed query step &1 of &4 follow:
- CPI4345 Temporary distributed result file *QQTDF0001 built for query.
File B was directed into temporary file *QQTDF0001.
- CPI4343 Optimizer debug messages for distributed query step &2 of &4 follow:
- CPI4342 Performing distributed join for query.
Files B, C and *QQTDF0001 were joined. This was a combination of a collocated join (between files B and C) and a directed join (with file *QQTDF0001).
- CPI4345 Temporary distributed result file *QQTDF0002 built for query.
Temporary distributed file *QQTDF0002 was created to contain the result of joining files B, C and *QQTDF0001. This file was directed.
- CPI4343 Optimizer debug messages for distributed query step &3 of &4 follow:
- CPI4345 Temporary distributed result file *QQTDF0003 built for query.
File A was directed into temporary file *QQTDF0003.
- CPI4343 Optimizer debug messages for distributed query step &4 of &4 follow:
- CPI4342 Performing distributed join for query.
Files *QQTDF0002 and *QQTDF0003 were joined. This was a repartitioned join, because both files were directed before the join occurred.
Additional tools that you might want to use when tuning queries for performance include the CL commands Print SQL Information (PRTSQLINF), which applies to SQL programs and packages, and Change Query Attributes (CHGQRYA).
Parent topic:
Query design for performance with DB2 Multisystem