Entering content frame

 Search Conditions Linked with OR 

For SQL statements that contain search conditions linked with OR, the Optimizer initially analyzes each search condition individually.

If the system finds an equality condition for key columns, it ignores the other search conditions linked with OR.

b1 AND b2 AND (b3 OR b4 AND b5)

The expressions b1, b2 and (b3 OR b4 AND b5) are initially analyzed individually. If an equality condition is found for key columns for b1 or b2, then (b3 OR b4 AND b5) is not considered when the search strategy is selected, since the search range cannot be effectively restricted any further.

If the system does not find any equality conditions for key columns, then the other search conditions linked with OR (not yet considered by the system) are analyzed. The Optimizer proceeds as follows:

..

       1.      Convert to disjunctive normal form

b1 AND b2 AND (b3 OR b4 AND b5)

is converted to the disjunctive normal form

(b1 AND b2 AND b3) OR (b1 AND b2 AND b4 AND b5)

       2.      Analyze the new expression
The new parenthesized expressions are analyzed separately.

       3.      Determine costs
The costs of the various search strategies for the parenthesized expressions of the disjunctive normal form are totaled. If this total is lower than the initial determined cost for the search strategy, without considering the search conditions linked with OR, then these various search strategies are used.

If the total costs of (b1 AND b2 AND b3) and (b1 AND b2 AND b4 AND b5) are lower than the costs for the search strategy for b1 and b2, then the strategies for (b1 AND b2 AND b3) and (b1 AND b2 AND b4 AND b5) are used.

 

Leaving content frame