← All questionsToo earlyData and databases
Why isn't my SQL query using the index or plan I expect?
You are not the only one. Asked 2 times since November 2026, 4 of them in the last 4 weeks.
Times asked per week
9 Sept – 1 Dec
Week of 9 SeptTimes asked0Week of 16 SeptTimes asked0Week of 23 SeptTimes asked0Week of 30 SeptTimes asked0Week of 7 OctTimes asked0Week of 14 OctTimes asked0Week of 21 OctTimes asked0Week of 28 OctTimes asked0Week of 4 NovTimes asked0Week of 11 NovTimes asked0Week of 18 NovTimes asked04Week of 25 NovTimes asked4
Week of 9 SeptWeek of 25 Nov
Coloured columns are the last 4 weeks.
What people answer
- One saysIn practice the optimizer does not reliably reorder predicates, so the order of conditions in a query can change performance, especially in data warehouse setups where it may not know about things like partitioning.
- One saysOR evaluation short-circuits once one operand is true, so the order of OR operands could affect how much work is done.
- One saysMySQL does many query rewrites, but it probably doesn't do the specific one of pulling out an IN-style test from an OR tree, which is hard when other conditions are mixed in.
- One saysWith perfect statistics and a perfect optimizer, predicate order would make no difference, but real optimizers fall short of that.
MySQL
A language model summarised 4 public replies and posts. Views are mixed. These are other people's views, not advice from Navigara.
What people asked
Each line is our one-sentence summary. The link opens the original discussion.
- Does short-circuit evaluation of OR conditions affect MySQL query performance compared with using IN?Open thread →
- Why does the order of operands in a MySQL OR condition affect query performance compared with IN?Open thread →
- Why can't MySQL rewrite consecutive OR conditions on the same column, such as WHERE id = 1 OR id = 2, into an IN list, and why can't this be done when OR conditions on different columns are mixed in?Open thread →
Where it is asked
- Hacker News4