[MDEV-317] CHEAP SQ: A query with EXISTS subquery, aggregate function in subquery, ORDER BY and LIMIT takes much longer than on main tree if optimizer_prune_level=0 Created: 2012-06-06 Updated: 2012-06-13 Resolved: 2012-06-13 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | 5.5.27 |
| Type: | Bug | Priority: | Minor |
| Reporter: | Elena Stepanova | Assignee: | Timour Katchaounov (Inactive) |
| Resolution: | Won't Fix | Votes: | 0 |
| Labels: | None | ||
| Issue Links: |
|
||||||||
| Description |
|
Note: with the provided test case, the problem is only reproducible when optimizer_prune_level=0. If you decide that it's acceptable and isn't worth fixing, I won't object, but I'm filing it so you could check if it's expected. The following query
takes ~18 times longer on Reproducible with MyISAM and Aria; with InnoDB it's sporadic. EXPLAIN on
EXPLAIN on maria/5.5:
Test case:
|
| Comments |
| Comment by Timour Katchaounov (Inactive) [ 2012-06-08 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
This is not a bug, but rather a deficiency of the current optimizer that is 1. What happens in mdev-193 The patch for mdev-193 makes MariaDB 5.5 behave like any MySQL version, or Specifically in this test case, the subquery (SELECT SUM(a) FROM t1) is If we set "optimizer_prune_level = 0" (that is, not pruning, consider all -----
-----
----- If we set "optimizer_prune_level = 1" (that is prune some plans), the optimizer -----
-----
----- However, the second plan in reality is much faster. The reason for this is that 2. Exposing the same problem in the main 5.5 branch If we substitute manually the aggregate subquery with its constant value, we can – better plan EXPLAIN – worse plan EXPLAIN | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Timour Katchaounov (Inactive) [ 2012-06-13 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
As explained in the last comment this is not a bug, but a deficiency of the current optimizer. |