Personal tools
You are here: Home DB2 How To's How to improve performance on statements with clause IN
Navigation
Log in


Forgot your password?
 
Document Actions

How to improve performance on statements with clause IN

DB2_INLIST_TO_NLJN

If you set the variable below to yes, you can improve your performance on statements with clause IN.

DB2_INLIST_TO_NLJN

  • Operating system: All
  • Default=NO, Values: YES or NO
  • In some situations, the SQL and XQuery compiler can rewrite an IN list predicate to a join. For example, the following query:
        SELECT *
    FROM EMPLOYEE
    WHERE DEPTNO IN ('D11', 'D21', 'E21')
    could be written as:
        SELECT *
    FROM EMPLOYEE, (VALUES 'D11', 'D21', 'E21) AS V(DNO)
    WHERE DEPTNO = V.DNO

    This revision might provide better performance if there is an index on DEPTNO. The list of values would be accessed first and joined to EMPLOYEE with a nested loop join using the index to apply the join predicate.

    Sometimes the optimizer does not have accurate information to determine the best join method for the rewritten version of the query. This can occur if the IN list contains parameter markers or host variables which prevent the optimizer from using catalog statistics to determine the selectivity. This registry variable causes the optimizer to favor nested loop joins to join the list of values, using the table that contributes the IN list as the inner table in the join.

Security Awareness
Would you like your company to implement gamification into your security awareness program?





Polls