mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
MWL#17: Table elimination:
- Fix a trivial problem when OR-merging two multi-equalities - Amend testsuite to provide full gcov coverage mysql-test/r/table_elim.result: MWL#17: Table elimination: - Amend testsuite to provide full gcov coverage mysql-test/t/table_elim.test: MWL#17: Table elimination: - Amend testsuite to provide full gcov coverage
This commit is contained in:
@ -352,3 +352,69 @@ explain select t1.a from t1 left join t3 on t3.pk1=t1.a and t3.pk2 IS NULL;
|
||||
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,t3;
|
||||
#
|
||||
# Multi-equality tests
|
||||
#
|
||||
create table t1 (a int, b int, c int, d int);
|
||||
insert into t1 values (0,0,0,0),(1,1,1,1),(2,2,2,2),(3,3,3,3);
|
||||
create table t2 (pk int primary key, b int, c int);
|
||||
insert into t2 select a,a,a from t1 where a in (1,2);
|
||||
explain
|
||||
select t1.*
|
||||
from t1 left join t2 on t2.pk=t2.c and t2.b=t1.a and t1.a=t1.b and t2.c=t2.b
|
||||
where t1.d=1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using where
|
||||
explain
|
||||
select t1.*
|
||||
from
|
||||
t1
|
||||
left join
|
||||
t2
|
||||
on (t2.pk=t2.c and t2.b=t1.a and t1.a=t1.b and t2.c=t2.b) or
|
||||
(t2.pk=t2.c and t2.b=t1.a and t1.a=t1.b and t2.c=t2.b)
|
||||
where t1.d=1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using where
|
||||
#This can't be eliminated:
|
||||
explain
|
||||
select t1.*
|
||||
from
|
||||
t1
|
||||
left join
|
||||
t2
|
||||
on (t2.pk=t2.c and t2.b=t1.a and t2.c=t1.b) or
|
||||
(t2.pk=t2.c and t1.a=t1.b and t2.c=t1.b)
|
||||
where t1.d=1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using where
|
||||
1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.b 1
|
||||
explain
|
||||
select t1.*
|
||||
from
|
||||
t1
|
||||
left join
|
||||
t2
|
||||
on (t2.pk=t2.c and t2.b=t1.a and t2.c=t1.b) or
|
||||
(t2.pk=t2.c and t2.c=t1.b)
|
||||
;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 4
|
||||
explain
|
||||
select t1.*
|
||||
from t1 left join t2 on t2.pk=3 or t2.pk= 4;
|
||||
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 index PRIMARY PRIMARY 4 NULL 2 Using index
|
||||
explain
|
||||
select t1.*
|
||||
from t1 left join t2 on t2.pk=3 or t2.pk= 3;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 4
|
||||
explain
|
||||
select t1.*
|
||||
from t1 left join t2 on (t2.pk=3 and t2.b=3) or (t2.pk= 4 and t2.b=3);
|
||||
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 range PRIMARY PRIMARY 4 NULL 2 Using where
|
||||
drop table t1, t2;
|
||||
|
Reference in New Issue
Block a user