[MDEV-17381] Wrong query result with LATERAL DERIVED optimization and join_cache_level=6 Created: 2018-10-05 Updated: 2020-08-25 Resolved: 2018-10-09 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Optimizer |
| Affects Version/s: | 10.4 |
| Fix Version/s: | 10.3.11 |
| Type: | Bug | Priority: | Critical |
| Reporter: | Sergei Petrunia | Assignee: | Igor Babaev |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Issue Links: |
|
||||||||
| Description |
|
This bug is originally from 10.2-compatibility branch. It cannot be reproduced on 10.4, because 10.4 will not use LATERAL DERIVED optimization for this testcase. However, if one changes the cost numbers, one can get the query plan that produces wrong query results. First, apply this patch to 10.4:
Then, prepare the testcase:
Then, run this query:
The EXPLAIN:
Query output:
If one disables LATERAL DERIVED: set optimizer_switch='split_materialized=off';, then they get correct result which is:
|
| Comments |
| Comment by Igor Babaev [ 2018-10-06 ] | |||||||||||||||||||||||||||||||||||||||||||
|
The problem is reproducible in 10.3 as well.
| |||||||||||||||||||||||||||||||||||||||||||
| Comment by Igor Babaev [ 2018-10-06 ] | |||||||||||||||||||||||||||||||||||||||||||
|
The following modification of the test case reproduces the problem without any additional patches:
Here we see a wrong result set as well:
EXPLAIN for this query 'explains' why it happens. The server tries to use simultaneously splitting technique
| |||||||||||||||||||||||||||||||||||||||||||
| Comment by Igor Babaev [ 2018-10-06 ] | |||||||||||||||||||||||||||||||||||||||||||
|
Another problem that with optimizer_switch='split_materialized=off' we have:
It does not make sense to use hash join by the key created for a derived table, because this key is already a hash key. | |||||||||||||||||||||||||||||||||||||||||||
| Comment by Igor Babaev [ 2018-10-06 ] | |||||||||||||||||||||||||||||||||||||||||||
|
I've created | |||||||||||||||||||||||||||||||||||||||||||
| Comment by Igor Babaev [ 2018-10-09 ] | |||||||||||||||||||||||||||||||||||||||||||
|
This problem was fixed by the patch for mdev-17382. The test case was pushed into 10.3 |