You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
EnforceDistribution: adjust_input_keys_ordering returns Transformed::yes unconditionally for non-join plans #21946
adjust_input_keys_ordering in EnforceDistribution returns Transformed::yes unconditionally in the default else branch (line 421), 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.
To Reproduce
Any query without joins or aggregates (e.g. a simple SELECT * FROM table WHERE ... ORDER BY ... LIMIT N) will have every node in the tree rebuilt during adjust_input_keys_ordering, even though no key reordering is needed.
Expected behavior
When requirements.data is empty (no parent key ordering to push down) and the plan node is not a join/aggregate/projection/repartition/window, adjust_input_keys_ordering should return Transformed::no to skip the rebuild.
Impact
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. CPU profiling showed this contributes to unnecessary work in the physical optimizer chain.
Proposed fix
Add an early return with Transformed::no when requirements.data.is_empty() in the default else branch of adjust_input_keys_ordering. Will submit a PR.
Activity
Skip unnecessary plan rebuild in adjust_input_keys_ordering for non-j…
Skip unnecessary plan rebuild in adjust_input_keys_ordering for non-j…
Skip unnecessary plan rebuild in adjust_input_keys_ordering for non-j…