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