Repository navigation
Commit d405cdf
Optimize logical optimizer: skip map_subqueries + in-place rewriting
Three optimizations that together yield ~23-25% faster optimization on
TPC-H/TPC-DS and up to 33% on expression-heavy queries:
1. map_subqueries short-circuit: skip expression tree walks when no
subquery expressions exist. Previously rewrite_with_subqueries
called map_subqueries at every plan node, walking all expression
trees via ownership-based transform_down even with no subqueries.
2. plan_has_subqueries per-pass check: when no subqueries exist in
the plan, bypass rewrite_with_subqueries entirely and use the
cheaper rewrite_plan_in_place path.
3. rewrite_plan_in_place with Arc::make_mut: new map_children_mut
method that mutates children in-place, avoiding the
Arc::unwrap_or_clone + Arc::new allocation cycle at every node.
The owned-plan rule API is bridged with std::mem::take, which is
allocation-free: LogicalPlan::default() is an EmptyRelation that
shares the process-wide static empty schema.
Also adds optimizer-only benchmarks that isolate optimizer performance
from SQL parsing and analysis overhead.
Co-Authored-By: Claude Opus 4.6 <[email protected]>
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>1 parent 102da39 commit d405cdf
3 files changed
Lines changed: 727 additions & 5 deletions
File tree
- datafusion
- core/benches
- expr/src/logical_plan
- optimizer/src
0 commit comments