I have an Oracle query that is structured as followed:
SELECT *
FROM table
WHERE X=\'true\' OR
Y IN (complicated subquery)
<
Regardless of what the optimizer may or may not do with AND
and OR
, if for any reason you must enforce a specific order of evaluation, you can rewrite the query, using other tools where short-circuit evaluation is guaranteed.
For example:
select * from table 1
where case when X = 'true' then 1
when Y in (select ....) then 1
end = 1
If X is 'true' then the case expression evaluates to 1, the second "when" is skipped and the condition evaluates to TRUE. If X is not 'true' then the IN condition is evaluated.