I have an Oracle query that is structured as followed:
SELECT *
FROM table
WHERE X=\'true\' OR
Y IN (complicated subquery)
<
Caveat: Oracle is not my primary area of expertise.
The cost-based optimizer should know that the cost of X = 'true' is less than the sub-query, so it will likely evaluate the simpler alternative first. But the AND and OR conditions in SQL are not short-circuited like && and || are in C and its derivatives.
The sub-query can be one of two forms: correlated and non-correlated.
Example correlated sub-query:
SELECT *
FROM Table1
WHERE X = 'true'
OR Y IN (SELECT Z FROM Table2 WHERE Table2.A = Table1.B)
Example non-correlated sub-query:
SELECT *
FROM Table1
WHERE X = 'true'
OR Y IN (SELECT Z FROM Table2 WHERE Table2.A > 13)