A query optimization class is a set of query rewrite rules and optimization techniques for compiling queries. It is one of the most important determinants in the evaluation and selection of an access plan for a particular query. DB2 provides multiple ways to specify optimization class.
For dynamic queries, optimization class can be explicitly specified by using the special register CURRENT QUERY OPTIMIZATION as follows:
SET CURRENT QUERY OPTIMIZATION = <VALUE>
For static queries, the optimization class can be explicitly specified during the BIND time ( Refer to the link  ). If the optimization class is not specified explicitly, then the effective optimization class is the one, specified by the dft_queryopt database configuration parameter.
As there are multiple ways to specify optimization class, it might be difficult to identify which optimization class is used by DB2. Here, explain_from_section can be collected to figure out the actual optimization class in effect for a specific query. The value of "Optimization Level:" field should be checked in the formatted explain_from_section output. Please refer to the link , for more information about explain_from_section.
Let us take a very simple example of a dynamic query explained from CLP prompt:
connect to <dbname>
set current explain mode explain
execute the query
set current explain mode no
db2exfmt -d <dbname> -1 -o query_exfmt.out
Here, the optimization class was not specified explicitly by SET CURRENT QUERY OPTIMIZATION statement. So, it would be the one specified by the dft_queryopt database configuration parameter.
Disclaimer: The postings on this site are my own and don't necessarily represent IBM's positions, strategies or opinions