Semi-join neglects the semijoin_with_cache flag when firstmatch=off
| Affects | Status | Importance | Assigned to | Milestone | |
|---|---|---|---|---|---|
| MariaDB |
Fix Released
|
High
|
Igor Babaev | ||
Bug Description
When the 'firstmatch' flag is off a semi-join may use join cache even in the cases with 'semijoin_
This this reproducible in MariaDB-5.3 with the following test case:
create table t1 (a int);
insert into t1 values (7), (1), (5), (3);
create table t2 (a int);
insert into t2 values (4), (1), (8), (3), (9), (2);
set @tmp_otimizer_
set optimizer_
set optimizer_
set optimizer_
explain
select * from t1 where t1.a in (select t2.a from t2);
select * from t1 where t1.a in (select t2.a from t2);
set optimizer_
explain
select * from t1 where t1.a in (select t2.a from t2);
select * from t1 where t1.a in (select t2.a from t2);
set optimizer_switch= @tmp_otimizer_
drop table t1,t2;
One can easily see this problem:
MariaDB [test]> set optimizer_
Query OK, 0 rows affected (0.00 sec)
MariaDB [test]>
MariaDB [test]> set optimizer_
Query OK, 0 rows affected (0.00 sec)
MariaDB [test]> explain
-> select * from t1 where t1.a in (select t2.a from t2);
+----+-
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-
| 1 | PRIMARY | t1 | ALL | NULL | NULL | NULL | NULL | 4 | Start temporary |
| 1 | PRIMARY | t2 | ALL | NULL | NULL | NULL | NULL | 6 | Using where; End temporary; Using join buffer (flat, BNL join) |
+----+-
2 rows in set (0.00 sec)
MariaDB [test]> set optimizer_
Query OK, 0 rows affected (0.00 sec)
MariaDB [test]> explain
-> select * from t1 where t1.a in (select t2.a from t2);
+----+-
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-
| 1 | PRIMARY | t1 | ALL | NULL | NULL | NULL | NULL | 4 | Start temporary |
| 1 | PRIMARY | t2 | ALL | NULL | NULL | NULL | NULL | 6 | Using where; End temporary; Using join buffer (flat, BNL join) |
+----+-
2 rows in set (0.00 sec)
| affects: | percona-pam-for-mysql → maria |
| Changed in maria: | |
| milestone: | none → 5.3 |
| importance: | Undecided → High |
| status: | New → Confirmed |
| assignee: | nobody → Igor Babaev (igorb-seattle) |
| Changed in maria: | |
| status: | Confirmed → Fix Committed |
| Changed in maria: | |
| status: | Fix Committed → Fix Released |
