Bug #59278 | "not exists" optimization seen in EXPLAIN but not used | ||
---|---|---|---|
Submitted: | 4 Jan 2011 12:50 | Modified: | 17 Jan 2011 21:01 |
Reporter: | Guilhem Bichot | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | MySQL Server: Optimizer | Severity: | S3 (Non-critical) |
Version: | 5.6, trunk | OS: | Any |
Assigned to: | CPU Architecture: | Any |
[4 Jan 2011 12:50]
Guilhem Bichot
[17 Jan 2011 21:01]
Guilhem Bichot
I was probably grepping in the wrong directory: not_exists_optimize is tested by the join buffering code, see bool calc_check_only_first_match(const JOIN_TAB *t) const { return (t->last_sj_inner_tab == t && t->get_sj_strategy() == SJ_OPT_FIRST_MATCH) || (t->first_inner && t->first_inner->last_inner == t && t->table->reginfo.not_exists_optimize); } in sql_select.h. If the part of the condition above which is about not_exists_optimizer is commented out, we observe that a query does more disk reads: CURRENT_TEST: main.join_outer_jcl6 --- /home/mysql_src/bzrrepos_new/mysql-next-mr-opt-backporting-wl4800/mysql-test/r/join_outer_jcl6.result 2011-01-17 17:58:42.000000000 +0300 +++ /home/mysql_src/bzrrepos_new/mysql-next-mr-opt-backporting-wl4800/mysql-test/r/join_outer_jcl6.reject 2011-01-17 23:52:02.000000000 +0300 @@ -1245,7 +1245,7 @@ Handler_read_last 0 Handler_read_next 9 Handler_read_prev 0 -Handler_read_rnd 3 +Handler_read_rnd 9 Handler_read_rnd_next 6 DROP TABLE t1,t2; CREATE TABLE t1 (c int PRIMARY KEY, e int NOT NULL); This observation proves that the optimization is actually working with join buffering.