MySQL Internals Manual  /  ...  /  OR Relations OR Relations

An ORed search has the form "condition1" OR "condition2", as in this example:

WHERE column1 = 'x' OR column2 = 'y'

Here the optimizer's decision is to use a sequential scan.

There is also an option to use index merge under such circumstances. For more information, see Section, “Overview” and Index Merge Optimization.

The above warning does not apply if the same column is used in both conditions. For example:

WHERE column1 = 'x' OR column1 = 'y'

In such a case, the search is indexed because the expression is a range search. This subject will be revisited during the discussion of the IN predicate.

User Comments
Sign Up Login You must be logged in to post a comment.