[MDEV-28246] Optimizer uses all partitions during an update in MariaDB 10.6.x but not in 10.2.x Created: 2022-04-06 Updated: 2022-05-24 Resolved: 2022-05-19 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Optimizer, Partitioning |
| Affects Version/s: | 10.3, 10.4, 10.5, 10.6, 10.7 |
| Fix Version/s: | 10.3.36, 10.4.26, 10.5.17, 10.6.9, 10.7.5, 10.8.4 |
| Type: | Bug | Priority: | Major |
| Reporter: | Sven Heidrich | Assignee: | Oleg Smirnov |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | optimizer, partitioning, update | ||
| Environment: |
Windows Server |
||
| Attachments: |
|
||||||||||||||||
| Issue Links: |
|
||||||||||||||||
| Description |
|
We used 10.2.x for a long time, where update commands on a partition were quite fast.
|
| Comments |
| Comment by Sergei Petrunia [ 2022-04-06 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
oleg.smirnov, please check why prune_partitions prunes different sets of partitions in UPDATE and SELECT, and then let's discuss it. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Oleg Smirnov [ 2022-04-13 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Looking at the history of this code I can see:
Determining prune_cond was extracted to separate function get_saragable_cond() and the logic has changed:
Part of get_saragable_cond() related to our case:
While debugging during execution of statement
I found out that table->pos_in_table_list->embedding is not NULL for trg table while table->pos_in_table_list->embedding->on_expr is NULL. This results in an empty sargable condition and thus no partition pruning. While adding one more check to the condition:
seems to fix the issue and doesn't break the tests, I'm not sure embedding is set correctly here for the trg table. This doesn't look to be the case mentioned in the comment
If embedding is set correctly then we probably need to update the comment to describe other possible scenarios. If not - I'll go looking for the code responsible for that. psergei, any ideas on that? | ||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2022-05-17 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Ok to push after addressing trivial input provided on Slack. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Oleg Smirnov [ 2022-05-19 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Pushed into 10.2, to be merged upstream. |