Unofficial Hacker News companion — get notified on comment replies, and more.

Why MySQL OR is slower than IN (opens external site)

22 points by millspore 3 days ago | www.percona.com | 14 comments on HN | Vote on HN (opens Hacker News) |

View full thread · View on Hacker News

Comment thread (3)

  1. The hypergraph optimizer orders expensive predicates last (where “expensive” is stuff like subqueries). The old (default) optimizer only does reordering more-or-less by accident, AFAIK.
    Replies (1)
    1. > where “expensive” is stuff like subqueries

      Subqueries aren't always going to be more expensive

      Replies (1)
      1. This is true, but the optimizer considers them so. They're more expensive than e.g. adding two ints.

        Of course, if they're rewritten to a semijoin or similar, they won't be subqueries anymore or indeed not conditions at all, so sorting them is not applicable.