When a query with OR causes a dramatic performance drop and the default execution plan is poor, you can manually restructure the SQL to guide the optimizer. This article covers two common scenarios — OR in filter predicates and OR in join conditions — with practical rewrite techniques for a gbase database.

Optimizing OR in Filter Predicates

Single Column, Multiple Values (A=XX OR A=YY)

Transform multiple OR checks into a single equality check. For numeric columns, use the DECODE function:

-- Original