diff options
author | Sergei Petrunia <psergey@askmonty.org> | 2019-05-10 12:47:44 +0300 |
---|---|---|
committer | Sergei Petrunia <psergey@askmonty.org> | 2019-05-16 13:03:58 +0300 |
commit | d448cfc92a47b9afbb2078ec6c94f24a6d83c7e8 (patch) | |
tree | 1a4a34fe1b7adebc79769e87e16fa9646b19e5dd /mysql-test/main/subselect4.test | |
parent | b1f828a82afb93d19421c24b48eb09aa0e37b03a (diff) | |
download | mariadb-git-d448cfc92a47b9afbb2078ec6c94f24a6d83c7e8.tar.gz |
MDEV-19134: EXISTS() slower if ORDER BY is defined
Step #2: "[ORDER BY ...] LIMIT n" should not prevent EXISTS-to-IN
conversion, as long as
- the LIMIT clause doesn't have OFFSET
- the LIMIT is not "LIMIT 0".
Diffstat (limited to 'mysql-test/main/subselect4.test')
-rw-r--r-- | mysql-test/main/subselect4.test | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/mysql-test/main/subselect4.test b/mysql-test/main/subselect4.test index 5c5dd797353..07fdbc310ff 100644 --- a/mysql-test/main/subselect4.test +++ b/mysql-test/main/subselect4.test @@ -2083,19 +2083,36 @@ 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); -insert into t1 select +insert into t1 select A.a + B.a*10, A.a + B.a*10 from t0 A, t0 B; create table t2 as select * from t1; ---echo # This will not be able to convert to semi-join but will not require filesort: ---replace_column 9 # -explain -select * from t1 where exists (select * from t2 where t2.a=t1.a order by t2.b); +--echo # This will be converted to semi-join: +explain +select * from t1 +where exists (select * from t2 where t2.a=t1.a order by t2.b); + +--echo # query with a non-zero constant LIMIT is converted to semi-join, too: +explain +select * from t1 +where exists (select * from t2 where t2.a=t1.a order by t2.b limit 2); + +--echo # Zero LIMIT should prevent the conversion (but it is not visible atm +--echo # due to MDEV-19429) +explain +select * from t1 +where exists (select * from t2 where t2.a=t1.a order by t2.b limit 0); + +--echo # LIMIT+OFFSET prevents the conversion: +explain +select * from t1 +where exists (select * from t2 where t2.a=t1.a order by t2.b limit 2,3); --echo # This will be merged and converted into a semi-join: -explain +explain select * from t1 where t1.a in (select t2.a from t2 order by t2.b); + drop table t0, t1, t2; |