1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

MDEV-19134: EXISTS() slower if ORDER BY is defined

Step 1: Removal of ORDER BY [LIMIT] from the subquery should be done
earlier and for broader class of subqueries.

The rewrite was done in Item_in_subselect::select_in_like_transformer(),
but this had problems:
- It didn't cover EXISTS subqueries
- It covered IN-subqueries, but was done after the semi-join transformation
  was considered inapplicable, because ORDER BY was present.

Remaining issue:
- EXISTS->IN transformation happens before
  check_and_do_in_subquery_rewrites() is called, so it is still prevented
  by the present ORDER BY.
This commit is contained in:
Sergei Petrunia
2019-05-04 21:33:39 +03:00
parent 366bf10475
commit b1f828a82a
9 changed files with 82 additions and 32 deletions

View File

@ -2049,7 +2049,7 @@ insert t1 values (1),(2),(3),(1);
explain select 1 from dual where exists (select max(a) from t1 group by a union select a+2 from t1);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
2 SUBQUERY t1 ALL NULL NULL NULL NULL 4 Using temporary; Using filesort
2 SUBQUERY t1 ALL NULL NULL NULL NULL 4 Using temporary
3 UNION t1 ALL NULL NULL NULL NULL 4
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL
drop table t1;