mirror of
https://github.com/MariaDB/server.git
synced 2025-12-24 11:21:21 +03:00
Fixed LP bug #899509.
The optimizer must ignore any possible hash join key when looking for the query execution plan with join_cache_level set to 0.
This commit is contained in:
@@ -192,13 +192,13 @@ pla_id test
|
||||
explain SELECT STRAIGHT_JOIN d.pla_id, m2.mat_id FROM t1 m2 INNER JOIN (SELECT mp.pla_id, MIN(m1.matintnum) AS matintnum FROM t2 mp INNER JOIN t1 m1 ON mp.mat_id=m1.mat_id GROUP BY mp.pla_id) d ON d.matintnum=m2.matintnum;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY m2 ALL NULL NULL NULL NULL 9
|
||||
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 9 Using where
|
||||
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 9 Using where; Using join buffer (flat, BNL join)
|
||||
2 DERIVED mp ALL NULL NULL NULL NULL 9 Using temporary; Using filesort
|
||||
2 DERIVED m1 eq_ref PRIMARY PRIMARY 3 test.mp.mat_id 1
|
||||
explain SELECT STRAIGHT_JOIN d.pla_id, m2.test FROM t1 m2 INNER JOIN (SELECT mp.pla_id, MIN(m1.matintnum) AS matintnum FROM t2 mp INNER JOIN t1 m1 ON mp.mat_id=m1.mat_id GROUP BY mp.pla_id) d ON d.matintnum=m2.matintnum;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY m2 ALL NULL NULL NULL NULL 9
|
||||
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 9 Using where
|
||||
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 9 Using where; Using join buffer (flat, BNL join)
|
||||
2 DERIVED mp ALL NULL NULL NULL NULL 9 Using temporary; Using filesort
|
||||
2 DERIVED m1 eq_ref PRIMARY PRIMARY 3 test.mp.mat_id 1
|
||||
drop table t1,t2;
|
||||
|
||||
@@ -5226,4 +5226,42 @@ a b c
|
||||
SET SESSION join_cache_level = DEFAULT;
|
||||
SET optimizer_switch=@tmp_optimizer_switch;
|
||||
DROP TABLE t1,t2,t3,t4;
|
||||
#
|
||||
# Bug #899509: an attempt to use hash join with join_cache_level=0
|
||||
#
|
||||
CREATE TABLE t1 (a int);
|
||||
INSERT INTO t1 VALUES (8), (7);
|
||||
CREATE TABLE t2 (a int);
|
||||
INSERT INTO t2 VALUES (8), (7);
|
||||
CREATE TABLE t3 (a int);
|
||||
INSERT INTO t3 VALUES (8), (7);
|
||||
SET @tmp_optimizer_switch=@@optimizer_switch;
|
||||
set optimizer_switch=default;
|
||||
set @@optimizer_switch='semijoin_with_cache=off';
|
||||
set @@optimizer_switch='outer_join_with_cache=off';
|
||||
SET optimizer_switch='derived_merge=off,derived_with_keys=off';
|
||||
SET join_cache_level=0;
|
||||
EXPLAIN
|
||||
SELECT * FROM (SELECT t1.* FROM t1, t2) t WHERE t.a IN (SELECT * FROM t3);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <subquery3> ALL distinct_key NULL NULL NULL 2
|
||||
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 4 Using where
|
||||
3 MATERIALIZED t3 ALL NULL NULL NULL NULL 2
|
||||
2 DERIVED t1 ALL NULL NULL NULL NULL 2
|
||||
2 DERIVED t2 ALL NULL NULL NULL NULL 2
|
||||
SELECT * FROM (SELECT t1.* FROM t1, t2) t WHERE t.a IN (SELECT * FROM t3);
|
||||
a
|
||||
8
|
||||
8
|
||||
7
|
||||
7
|
||||
SELECT * FROM ( SELECT ta.* FROM t1 AS ta, t1 ) tb WHERE a IN ( SELECT * FROM t1 );
|
||||
a
|
||||
8
|
||||
8
|
||||
7
|
||||
7
|
||||
SET SESSION join_cache_level = DEFAULT;
|
||||
SET optimizer_switch=@tmp_optimizer_switch;
|
||||
DROP TABLE t1,t2,t3;
|
||||
set @@optimizer_switch=@save_optimizer_switch;
|
||||
|
||||
@@ -432,7 +432,7 @@ WHERE t2.c = v1.c AND t2.c = v1.b AND v1.b = t3.c);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t2 system NULL NULL NULL NULL 1
|
||||
1 PRIMARY t3 ALL NULL NULL NULL NULL 2 Using where
|
||||
1 PRIMARY <derived3> ALL NULL NULL NULL NULL 3 Using where; Start temporary; End temporary
|
||||
1 PRIMARY <derived3> ALL NULL NULL NULL NULL 3 Using where; Start temporary; End temporary; Using join buffer (flat, BNL join)
|
||||
3 DERIVED t1 ALL NULL NULL NULL NULL 3
|
||||
SELECT * FROM t3
|
||||
WHERE t3.b IN (SELECT v1.b FROM v1, t2
|
||||
|
||||
Reference in New Issue
Block a user