Tips for improving performance when selecting data from more than two tables

The following suggestion is only applicable to CQE and is directed specifically to select-statements that access several tables. For joins that involve more than two tables, you might want to provide redundant information about the join columns. The CQE optimizer does not generate transitive closure predicates between 2 columns. If you give the optimizer extra information to work with when requesting a join, it can determine the best way to do the join. The additional information might seem redundant, but is helpful to the optimizer.

If the select-statement you are considering accesses two or more tables, all the recommendations suggested in Creating an index strategy apply. For example, instead of coding:

  EXEC SQL
    DECLARE EMPACTDATA CURSOR FOR
    SELECT LASTNAME, DEPTNAME, PROJNO, ACTNO
         FROM CORPDATA.DEPARTMENT, CORPDATA.EMPLOYEE,
                CORPDATA.EMP_ACT
        WHERE DEPARTMENT.MGRNO = EMPLOYEE.EMPNO
               AND EMPLOYEE.EMPNO = EMP_ACT.EMPNO
  END-EXEC.

Provide the optimizer with a little more data and code:

  EXEC SQL
    DECLARE EMPACTDATA CURSOR FOR
    SELECT LASTNAME, DEPTNAME, PROJNO, ACTNO
         FROM CORPDATA.DEPARTMENT, CORPDATA.EMPLOYEE,
                CORPDATA.EMP_ACT
         WHERE DEPARTMENT.MGRNO = EMPLOYEE.EMPNO
                AND EMPLOYEE.EMPNO = EMP_ACT.EMPNO
                AND DEPARTMENT.MGRNO = EMP_ACT.EMPNO
  END-EXEC.