diff options
author | Sergei Petrunia <psergey@askmonty.org> | 2016-10-14 00:05:13 +0300 |
---|---|---|
committer | Sergei Petrunia <psergey@askmonty.org> | 2016-10-14 00:05:13 +0300 |
commit | b8b1b928ffa9da49588eec4ebe05c864c9847be2 (patch) | |
tree | d2280d38135b204457294dc8a189bc11dca4d013 /mysql-test/r/join_outer.result | |
parent | 9208b87f18b3dc84bb22551957a8e2f709e768a8 (diff) | |
download | mariadb-git-b8b1b928ffa9da49588eec4ebe05c864c9847be2.tar.gz |
MDEV-8359: WHERE condition referring to inner table of left join can be sargable
Implement a technique mentioned in the MDEV. Under certain conditions,
cond(inner_table.col) can be substituted for cond(outer_table.col) for
the purpose of range analysis.
Diffstat (limited to 'mysql-test/r/join_outer.result')
-rw-r--r-- | mysql-test/r/join_outer.result | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/mysql-test/r/join_outer.result b/mysql-test/r/join_outer.result index 8b4ee17f20e..77932b65857 100644 --- a/mysql-test/r/join_outer.result +++ b/mysql-test/r/join_outer.result @@ -2337,4 +2337,27 @@ id select_type table type possible_keys key key_len ref rows filtered Extra Warnings: Note 1003 select `test`.`t1`.`i1` AS `i1`,`test`.`t1`.`v1` AS `v1`,`test`.`t2`.`i2` AS `i2`,`test`.`t2`.`v2` AS `v2`,`test`.`t3`.`i3` AS `i3`,`test`.`t3`.`v3` AS `v3` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`v3` = 4) and (`test`.`t1`.`i1` = `test`.`t3`.`i3`) and (`test`.`t2`.`i2` = `test`.`t3`.`i3`)) drop table t1,t2,t3; +# +# MDEV-8359: WHERE condition referring to inner table of left join can be sargable +# +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, b int, key(a)); +insert into t1 select A.a+10*B.a+100*C.a, A.a+10*B.a+100*C.a from t0 A, t0 B, t0 C; +create table t2 (a int, b int); +insert into t2 select a,a from t0; +# The following must remain an outer join +# but it must be able to use range access on table t1: +explain extended +select * +from +t1 left join t2 on t2.a=t1.a +where +t1.a<3 or t2.a<4; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 range a a 5 NULL 4 100.00 Using index condition +1 SIMPLE t2 ALL NULL NULL NULL NULL 10 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where ((`test`.`t1`.`a` < 3) or (`test`.`t2`.`a` < 4)) +drop table t0,t1, t2; SET optimizer_switch=@save_optimizer_switch; |