Skip to content

Commit 80accb4

Browse files
author
Ajo Robert
committed
Bug#35842412 WHERE NOT IN with subquery is much slower on 8.1 than 5.7
Queries of the form SELECT DISTINCT..FROM t1 WHERE NOT IN(SELECT...) would get transformed into an anti-join if possible, starting from 8.0+. This made the optimizer not choose group skip scan for table "t1" which otherwise, it would in 5.7 resulting in performance degradation for such queries on 8.0+. Group skip scan is not chosen as the query is now no more a single table query post the anti-join transformation and this access method is enabled only for single table queries. The same behaviour can be seen even for queries which are transformed into semi-joins too. However, group skip scan access method could still be picked for such queries if the access method is used only for duplicate removal (i.e DISTINCT/GROUP BY without aggregation functions) even in these cases. Solution: Enable group skip scan when there is only one table originally in the query, irrespective of the number of semijoin tables present after internal transformations and if the query doesn't contain aggregation functions. Change-Id: I8beb8996c1751b1ade4680582446760c2a24455f
1 parent 71e50b4 commit 80accb4

File tree

12 files changed

+1257
-14
lines changed

12 files changed

+1257
-14
lines changed

mysql-test/r/explain_for_connection_small_json.result

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -487,11 +487,11 @@ QUERY: SELECT DISTINCT topic FROM t2 WHERE NOT EXISTS(SELECT * FROM t3 WHERE num
487487
STATUS:NOT_EQUAL
488488
SYNC_POINT:before_reset_query_plan
489489
Diff: EXPLAIN NORMAL vs OTHER
490-
@@ -58,2 +58,3 @@
490+
@@ -57,2 +57,3 @@
491491
"filtered": "100.00",
492492
+ "using_where": true,
493493
"not_exists": true,
494-
@@ -69,4 +70,3 @@
494+
@@ -67,4 +68,3 @@
495495
"numeropost"
496496
- ],
497497
- "attached_condition": "<if>(is_not_null_compl(t3), <if>(found_match(t3), false, true), true)"

0 commit comments

Comments
 (0)