[MDEV-27201] Non-merged derived table: do not compute unused fields Created: 2021-12-08 Updated: 2023-12-22 |
|
| Status: | In Review |
| Project: | MariaDB Server |
| Component/s: | Optimizer |
| Fix Version/s: | 11.5 |
| Type: | Task | Priority: | Critical |
| Reporter: | Sergei Petrunia | Assignee: | Sergei Petrunia |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | optimizer, optimizer-easy | ||
| Issue Links: |
|
||||||||
| Description |
| Comments |
| Comment by Sergei Petrunia [ 2023-06-08 ] | |||||||||||||||||||||||||||||||||||||||||
|
A Description of the current solution: Preparation: table->read_set is not set to all 1 for temporary (derived) tables. Then, at mysql_derived_optimize() phase, we know which table columns are used and which are not. Then, if we see a sum function that produces a column that is not used, | |||||||||||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2023-06-09 ] | |||||||||||||||||||||||||||||||||||||||||
|
Take aways from the discussions: It's hard to handle WITH ROLLUP as it copies aggregate functions. It doesn't seem to be worth it - WITH ROLLUP in a derived table is not that useful. | |||||||||||||||||||||||||||||||||||||||||
| Comment by Oleg Smirnov [ 2023-06-20 ] | |||||||||||||||||||||||||||||||||||||||||
|
bb-11.1-mdev-27201 presents the first version of the functionality, although a couple of tests still fail and need addressing. commit 4c19fb9ed7dee5e2bd988737f8c334b37252c989 (HEAD -> bb-11.1-mdev-27201, origin/bb-11.1-mdev-27201)
This optimization shows a significant improvement in performance for a scenario where a view has multiple aggregate field but only few of them are selected:
Average time of the SELECT execution for bb-11.1-mdev-27201 is 9.156 seconds for 1 million rows against 12.525 seconds for the mainstream 11.1. Current limitations and possible TODOs. | |||||||||||||||||||||||||||||||||||||||||
| Comment by Oleg Smirnov [ 2023-08-23 ] | |||||||||||||||||||||||||||||||||||||||||
|
The recent version of bb-11.1-mdev-27201 implements the logic of derived tables/views elimination (which was listed as point 5 before). |