[MDEV-22248] Optimizer chooses wrong strategy on delete Created: 2020-04-15 Updated: 2023-11-20 |
|
| Status: | Open |
| Project: | MariaDB Server |
| Component/s: | Optimizer |
| Affects Version/s: | 10.4.12 |
| Fix Version/s: | 10.4 |
| Type: | Bug | Priority: | Major |
| Reporter: | Oli Sennhauser | Assignee: | Lena Startseva |
| Resolution: | Unresolved | Votes: | 1 |
| Labels: | subquery | ||
| Environment: |
Ubuntu 18.04, n.a. |
||
| Attachments: |
|
||||||||||||
| Issue Links: |
|
||||||||||||
| Description |
|
5 different queries which should do the same thing but 3 different execution plans: 1st case customer complained (cdrs_process is much smaller than cdrs):
Can/should the optimizer not do this automatically with the new features? Rewriting to multi-table delete helped. We have seen some strange behaviour with aliasing but could not reproduce it. The next CEP seems ok:
But this one is a bit less optimal compared to the previous 3:
Should be reproducible with the attached test data. |
| Comments |
| Comment by Sergei Petrunia [ 2020-05-12 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
oli, thanks for reporting this. I am not sure why joining with USING (...) produces different plan from joining with ON, this will need to be investigated. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Oli Sennhauser [ 2021-06-01 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Still a problem in 10.3 to 10.5.
-----
----- Execution time: With SELECT it does materialization: SQL> EXPLAIN -----
-----
----- With multi-table delete it does materialization: SQL> EXPLAIN -----
-----
----- Ececution time: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Oli Sennhauser [ 2021-06-01 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I was told that optimizers from other RDBMS can do materialization in this case. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Oli Sennhauser [ 2021-06-04 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I just did a test with a competitive product. With v8.0 this problem is solved. In 5.7 it also exists. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Oli Sennhauser [ 2022-01-04 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
We had the same case again today with an UPDATE statement. Same solution. I was told that MS SQL Server also solves query without problems. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2023-11-03 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Most of this should have been fixed in lstartseva, could you check this? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Lena Startseva [ 2023-11-20 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
After fix in in
|