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 *
could be written as:
FROM EMPLOYEE
WHERE DEPTNO IN ('D11', 'D21', 'E21')SELECT *
FROM EMPLOYEE, (VALUES 'D11', 'D21', 'E21) AS V(DNO)
WHERE DEPTNO = V.DNOThis 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.