← 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.

Read what people asked

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.

Named in the answersMySQL

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.

Show 1 more

Where it is asked

  • Hacker News4

Goes straight to the person who runs this site. No account needed.