Comment 1 for bug 944706

Revision history for this message
Sergey Petrunia (sergefp) wrote : Re: Query with impossible HAVING takes 1 millisec on 5.2 and 8 sec on 5.3

(comment based on the original, non-simplified testcase. The testcase posted here looks ok but I did not do a real check with it)

This bug demonstrates a problem with the optimizer, in particular with the choice between IN->EXISTS and Materialization strategies.

We have a query:

  const1 IN (SELECT inner_expr FROM ... )

Why would the optimizer pick Materialization, when we have "const1" on the left side, and so will make only one lookup in the materialized table? It is obvious that IN->EXISTS will always be better than Materialization for such cases.