The bug is present both with MATERIALIZATION and with IN-TO-EXISTS,
but not with SEMIJOIN:
set @@optimizer_switch='materialization=on,in_to_exists=on,semijoin=off';
set @@optimizer_switch='materialization=off,in_to_exists=on,semijoin=off';
set @@optimizer_switch='materialization=on,in_to_exists=off,semijoin=off';
The bug is present both with MATERIALIZATION and with IN-TO-EXISTS, switch= 'materializatio n=on,in_ to_exists= on,semijoin= off'; switch= 'materializatio n=off,in_ to_exists= on,semijoin= off'; switch= 'materializatio n=on,in_ to_exists= off,semijoin= off';
but not with SEMIJOIN:
set @@optimizer_
set @@optimizer_
set @@optimizer_