Commit 05a6c45
committed
Skip unnecessary plan rebuild in adjust_input_keys_ordering for non-join plans (apache#21947)
Closes apache#21946
`adjust_input_keys_ordering` returns `Transformed::yes` unconditionally
in the default else branch, even when `requirements.data` is empty and
no changes were made. This triggers unnecessary `with_new_children`
rebuilds on every node in the plan tree for non-join/non-aggregate
queries.
For plans with custom `ExecutionPlan` nodes whose `with_new_children` is
expensive (e.g. nodes that re-evaluate cost functions on rebuild), this
causes significant overhead.
Add an early return with `Transformed::no` when
`requirements.data.is_empty()` in the default else branch of
`adjust_input_keys_ordering`. This skips the unnecessary plan tree
rebuild for simple scan/filter/limit plans that have no join key
reordering requirements.
Yes, two unit tests added:
- `adjust_input_keys_ordering_no_transform_for_scan` — verifies a bare
parquet scan returns `Transformed::no`
- `adjust_input_keys_ordering_no_transform_for_filter_scan` — verifies a
filter→scan tree returns `Transformed::no` via `transform_down`
No. This is a performance optimization that does not change query
results or plan structure.1 parent 7768d24 commit 05a6c45
2 files changed
Lines changed: 33 additions & 0 deletions
File tree
- datafusion
- core/tests/physical_optimizer
- physical-optimizer/src
Lines changed: 30 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3676 | 3676 | | |
3677 | 3677 | | |
3678 | 3678 | | |
| 3679 | + | |
| 3680 | + | |
| 3681 | + | |
| 3682 | + | |
| 3683 | + | |
| 3684 | + | |
| 3685 | + | |
| 3686 | + | |
| 3687 | + | |
| 3688 | + | |
| 3689 | + | |
| 3690 | + | |
| 3691 | + | |
| 3692 | + | |
| 3693 | + | |
| 3694 | + | |
| 3695 | + | |
| 3696 | + | |
| 3697 | + | |
| 3698 | + | |
| 3699 | + | |
| 3700 | + | |
| 3701 | + | |
| 3702 | + | |
| 3703 | + | |
| 3704 | + | |
| 3705 | + | |
| 3706 | + | |
| 3707 | + | |
| 3708 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
425 | 425 | | |
426 | 426 | | |
427 | 427 | | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
428 | 431 | | |
429 | 432 | | |
430 | 433 | | |
| |||
0 commit comments