Bug #46407 | EXPLAIN says that FirstMatch is used while optimizer_switch.firstmatch is off | ||
---|---|---|---|
Submitted: | 27 Jul 2009 14:50 | Modified: | 3 Nov 2009 14:46 |
Reporter: | Elena Stepanova | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | MySQL Server: Optimizer | Severity: | S3 (Non-critical) |
Version: | 6.0 | OS: | Any |
Assigned to: | Guilhem Bichot | CPU Architecture: | Any |
Tags: | firstmatch, optimizer_switch, subquery |
[27 Jul 2009 14:50]
Elena Stepanova
[27 Jul 2009 15:06]
Sveta Smirnova
Thank you for the report. Verified as described.
[15 Sep 2009 12:22]
Guilhem Bichot
quick debugging says that: - FirstMatch in EXPLAIN comes from this line sql_select.cc:1228: int setup_semijoin_dups_elimination(JOIN *join, ulonglong options, uint no_jbuf_after) { ... case SJ_OPT_LOOSE_SCAN: { ... if (pos->n_sj_tables > 1) { tab[pos->n_sj_tables - 1].do_firstmatch= tab; This setting of do_firstmatch provokes FirstMatch in EXPLAIN (see else if (tab->do_firstmatch) in select_describe()). So it's LooseScan which causes FirstMatch-in-EXPLAIN. And using loosescan=off makes FirstMatch go away. I still don't know if it's correct that LooseScan uses do_firstmatch.
[22 Sep 2009 9:31]
Guilhem Bichot
discussion at http://lists.mysql.com/internals/37322
[3 Nov 2009 14:46]
Guilhem Bichot
So it's not a bug (see discussion), LooseScan uses FirstMatch on the second table; FirstMatch here is a sub-strategy of LooseScan, and optimizer_switch='firstmatch=off' doesn't have the intention to disable that, it should apply only when FirstMatch is the top strategy for the semi-join.