DB2 10.5 for Linux, UNIX, and Windows

CURRENT QUERY OPTIMIZATION special register

The CURRENT QUERY OPTIMIZATION special register specifies an INTEGER value that controls the class of query optimization performed by the database manager when binding dynamic SQL statements.

The QUERYOPT bind option controls the class of query optimization for static SQL statements. The possible values range from 0 to 9. For example, if the query optimization class is set to 0 (minimal optimization), then the value in the special register is 0. The default value is determined by the dft_queryopt database configuration parameter. The value can be changed by invoking the SET CURRENT QUERY OPTIMIZATION statement.

Example: Using the SYSCAT.PACKAGES catalog view, find all plans that were bound with the same setting as the current value of the CURRENT QUERY OPTIMIZATION special register.
   SELECT PKGNAME, PKGSCHEMA FROM SYSCAT.PACKAGES
     WHERE QUERYOPT = CURRENT QUERY OPTIMIZATION