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
Avoid rerunning logical optimizer rules on unchanged plans #22411
The logical optimizer reruns every rule on each optimizer pass, even when a rule already returned Transformed::no for the current logical plan and no later rule has changed that plan before the next invocation of the same rule.
This adds avoidable planning cost on queries that need multiple optimizer passes. ClickBench queries are a good example: many converge only after a second pass, but most rules in that pass see the exact same input they already reported as unchanged.
Proposed improvement
Track a cheap logical plan version during optimization. Increment the version whenever a rule reports transformed = true. If a rule previously returned Transformed::no at the current plan version, skip rerunning it until some rule changes the plan.
This keeps the existing optimizer fixed-point behavior while avoiding repeated no-op work for unchanged rule inputs.
Local measurement
Using a temporary local ClickBench logical planning probe over all 51 ClickBench queries, 30 iterations:
Baseline optimizer-only: 607.259 us/query
Patched optimizer-only: 409.473 us/query and 423.034 us/query
Activity
saadtajwar commentedon Jun 30, 2026
Hey @Dandandan , saw you had a PR for this earlier - is this still open/needing to be worked on? Happy to help if so :)