Keywords: OR transformations, Internal transformation of statements, OR predicates

# OR transformations

If all the OR predicates in a WHERE clause are of the form

    simple column reference = Expression

where the columnReference is the same for all predicates in the OR chain, Derby transforms the OR chain into an IN list of the following form:

    simple column reference IN (Expression1, Expression2, ..., ExpressionN)

The new predicate might be optimizable.

For example, Derby can transform the following statement:

    SELECT * FROM Flights
    WHERE flight_id = 'AA1111'
    OR flight_id = 'US5555'
    OR flight_id = ?

into this one:

    SELECT * FROM Flights
    WHERE flight_id IN ('AA1111', 'US5555', ?)

If this transformed IN list is a static IN list, Derby also performs the static IN list transformation (see Simple IN predicate transformations).

Parent topic: Predicate transformations
Related reference
BETWEEN transformations
LIKE transformations
Simple IN predicate transformations
NOT IN predicate transformations