mirror of
https://github.com/MariaDB/server.git
synced 2025-01-17 12:32:27 +01:00
21b1b5f040
Applied the fix for bug #47217 from the mysql-6.0 codebase. The patch adds not null predicates generated for the left parts of the equality predicates used for ref accesses. This is done for such predicates both in where conditions and on conditions. For the where conditions the not null predicates were generated but in 5.0/5.1 they actually never were used due to some lame merge from 4.1 to 5.0. The fix for bug #47217 made these predicates to be used in the condition pushed to the tables. Yet only this patch generates not null predicates for equality predicated from on conditions of outer joins. This patch introduces a performance regression that can be observed on a test case from null_key.test. The regression will disappear after the fix for bug #57024 from mariadb-5.1 is pulled into mariadb-5.3. The patch contains many changes in the outputs of the EXPLAIN commands since generated not null predicates are considered as parts of the conditions pushed to join tables and may add 'Usingwhere' in some rows of EXPLAINs where there used to be no such comments.
22 lines
1 KiB
Text
22 lines
1 KiB
Text
drop table if exists t1, t2;
|
|
create table t1 (a int);
|
|
insert into t1 values (0),(1),(2),(3);
|
|
create table t2 (a int primary key, b int)
|
|
as select a, a as b from t1 where a in (1,2);
|
|
explain select t1.a from t1 left join t2 on t2.a=t1.a;
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
|
1 SIMPLE t1 ALL NULL NULL NULL NULL 4
|
|
set optimizer_switch='table_elimination=off';
|
|
explain select t1.a from t1 left join t2 on t2.a=t1.a;
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
|
1 SIMPLE t1 ALL NULL NULL NULL NULL 4
|
|
1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.a 1 Using where; Using index
|
|
set optimizer_switch='table_elimination=on';
|
|
explain select t1.a from t1 left join t2 on t2.a=t1.a;
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
|
1 SIMPLE t1 ALL NULL NULL NULL NULL 4
|
|
set optimizer_switch='table_elimination=default';
|
|
explain select t1.a from t1 left join t2 on t2.a=t1.a;
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
|
1 SIMPLE t1 ALL NULL NULL NULL NULL 4
|
|
drop table t1, t2;
|