Skip to content

perf(optimizer): EliminateCrossJoin fast-path for join-free plans#22612

Open
zhuqi-lucas wants to merge 3 commits into
apache:mainfrom
zhuqi-lucas:perf/eliminate-cross-join-fast-path
Open

perf(optimizer): EliminateCrossJoin fast-path for join-free plans#22612
zhuqi-lucas wants to merge 3 commits into
apache:mainfrom
zhuqi-lucas:perf/eliminate-cross-join-fast-path

Conversation

@zhuqi-lucas
Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Closes #22583.

Rationale for this change

EliminateCrossJoin::rewrite is called on every plan during logical optimization. The rule's body only does real work when the root (or its Filter child) is an inner Join; in every other case it falls through to rewrite_children, which recurses into the plan, processes uncorrelated subqueries, and rewrites every direct child via map_children (clone-on-write), then calls recompute_schema on the way back.

This is paid by every query in the logical optimizer pipeline — including simple point queries with no joins anywhere in the tree.

Discussion on the issue

@neilconway raised the valid concern that a fast-path scan still does some up-front work in the case where the rewrite does fire, and that the deeper fix is mutable tree rewrites (avoiding the clone-on-write of TreeNode::rewrite entirely). @alamb agreed and pointed at the in-place map_children_mut / plan_has_subqueries infrastructure adriangb landed in #22298 as the existing precedent.

This PR follows that precedent directly:

  • Same shape as plan_has_subqueries — a read-only apply scan, early-stops on the first matching node, allocates nothing.
  • The scan cost on a query that does have joins is O(depth-to-first-join) — typically a handful of nodes, well below the cost of even one map_children clone-on-write the rewrite would otherwise do.
  • For the deeper "in-place mutable rewrite" direction, rewrite_children here recurses via optimizer.rewrite(input, config) per child — a different shape from map_children_mut's &mut traversal. Adapting that is a larger refactor and worth its own follow-up; this PR doesn't block it.

What changes are included in this PR?

  • New plan_has_joins(&LogicalPlan) -> bool helper in eliminate_cross_join.rsapply walk that returns true on the first LogicalPlan::Join it sees.
  • Fast-path at the top of EliminateCrossJoin::rewrite: if !plan_has_joins(&plan) { return Ok(Transformed::no(plan)); }. Everything else is unchanged.

Are these changes tested?

Four new unit tests in the existing mod tests:

  • plan_has_joins_detects_root_join
  • plan_has_joins_detects_nested_join (Join under Filter/Projection)
  • plan_has_joins_returns_false_for_join_free_plan
  • rewrite_short_circuits_when_plan_has_no_joins — end-to-end: rule's rewrite returns Transformed::no and the plan comes back identical (schema + display) on join-free input.

The existing 20 EliminateCrossJoin tests + the full 708-test datafusion-optimizer --lib suite still pass. cargo clippy -p datafusion-optimizer --all-targets -- -D warnings clean.

Are there any user-facing changes?

No semantic change. Pure perf optimization, no new config knobs.

Follow-ups

Closes apache#22583.

The rule's body only does real work when the root (or its Filter
child) is an inner Join; in every other case it falls through to
rewrite_children, which recurses into the plan, processes
uncorrelated subqueries, and rewrites every direct child via
map_children (clone-on-write), then calls recompute_schema on the
way back. This is paid by every query in the logical optimizer
pipeline — including simple point queries with no joins anywhere
in the tree.

Add a read-only apply scan at the top of rewrite that bails out
with Transformed::no(plan) when no LogicalPlan::Join node exists
in the tree. Mirrors the plan_has_subqueries fast-path landed in
apache#22298 — same shape (cheap up-front scan, early stop on first
match) and follows the precedent the reviewers approved there.

Four unit tests cover:
- plan_has_joins detects a root Join
- plan_has_joins detects a nested Join
- plan_has_joins returns false on join-free plans
- rewrite short-circuits with Transformed::no on join-free plans
@zhuqi-lucas zhuqi-lucas marked this pull request as ready for review May 29, 2026 07:44
Copilot AI review requested due to automatic review settings May 29, 2026 07:44
@github-actions github-actions Bot added the optimizer Optimizer rules label May 29, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a fast-path to the EliminateCrossJoin logical optimizer rule to avoid a full recursive rewrite walk when the plan contains no joins, reducing overhead for join-free queries in the optimizer pipeline.

Changes:

  • Added a plan_has_joins(&LogicalPlan) -> bool helper to detect whether a plan contains any LogicalPlan::Join nodes.
  • Added an early return in EliminateCrossJoin::rewrite to short-circuit with Transformed::no(plan) when no joins are present.
  • Added unit tests for the helper and for the short-circuit behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread datafusion/optimizer/src/eliminate_cross_join.rs
Comment thread datafusion/optimizer/src/eliminate_cross_join.rs
Copilot review found a correctness gap: `LogicalPlan::apply` does
not descend into the subquery plans referenced from
`Expr::ScalarSubquery` / `Expr::InSubquery` / `Expr::Exists` /
`Expr::SetComparison`. A query whose outer plan has no Join but
contains `IN (SELECT ... FROM a CROSS JOIN b)`-style predicates
would short-circuit and skip optimizing the subquery's join.

`rewrite_children` reaches those subqueries via
`map_uncorrelated_subqueries`, so `plan_has_joins` has to consider
them too. Extend the helper to recurse into each subquery plan
through `apply_expressions` + an `Expr::apply` walk.

New regression test `plan_has_joins_detects_join_inside_subquery`
exercises the `IN (SELECT ... CROSS JOIN ...)` shape.
@zhuqi-lucas
Copy link
Copy Markdown
Contributor Author

Filed #22616 to track the deeper "generic in-place mutable rewrite" direction @neilconway and @alamb raised on #22583. Per-rule fast-paths like this one and #22298 become redundant once that lands; until then they're contained, cheap wins on the common no-match path.

Happy to scope #22616 in a follow-up PR.

Copy link
Copy Markdown
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me -- thanks @zhuqi-lucas

if found {
return Ok(TreeNodeRecursion::Stop);
}
let _ = expr.apply(|e| {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am surprised there isn'y already soem tranversal code that recurses into subqueries

Perhaps this one?
https://docs.rs/datafusion/latest/datafusion/logical_expr/enum.LogicalPlan.html#method.apply_with_subqueries

(though maybe you can't use that because it is for LogicalPlans not Exprs 🤔 )

@alamb
Copy link
Copy Markdown
Contributor

alamb commented May 29, 2026

run benchmarks sql_planner

@adriangbot
Copy link
Copy Markdown

🤖 Criterion benchmark running (GKE) | trigger
Instance: c4a-highmem-16 (12 vCPU / 65 GiB) | Linux bench-c4579420186-370-qqpfr 6.12.68+ #1 SMP Wed Apr 1 02:23:28 UTC 2026 aarch64 GNU/Linux

CPU Details (lscpu)
Architecture:                            aarch64
CPU op-mode(s):                          64-bit
Byte Order:                              Little Endian
CPU(s):                                  16
On-line CPU(s) list:                     0-15
Vendor ID:                               ARM
Model name:                              Neoverse-V2
Model:                                   1
Thread(s) per core:                      1
Core(s) per cluster:                     16
Socket(s):                               -
Cluster(s):                              1
Stepping:                                r0p1
BogoMIPS:                                2000.00
Flags:                                   fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm jscvt fcma lrcpc dcpop sha3 sm3 sm4 asimddp sha512 sve asimdfhm dit uscat ilrcpc flagm sb paca pacg dcpodp sve2 sveaes svepmull svebitperm svesha3 svesm4 flagm2 frint svei8mm svebf16 i8mm bf16 dgh rng bti
L1d cache:                               1 MiB (16 instances)
L1i cache:                               1 MiB (16 instances)
L2 cache:                                32 MiB (16 instances)
L3 cache:                                80 MiB (1 instance)
NUMA node(s):                            1
NUMA node0 CPU(s):                       0-15
Vulnerability Gather data sampling:      Not affected
Vulnerability Indirect target selection: Not affected
Vulnerability Itlb multihit:             Not affected
Vulnerability L1tf:                      Not affected
Vulnerability Mds:                       Not affected
Vulnerability Meltdown:                  Not affected
Vulnerability Mmio stale data:           Not affected
Vulnerability Reg file data sampling:    Not affected
Vulnerability Retbleed:                  Not affected
Vulnerability Spec rstack overflow:      Not affected
Vulnerability Spec store bypass:         Mitigation; Speculative Store Bypass disabled via prctl
Vulnerability Spectre v1:                Mitigation; __user pointer sanitization
Vulnerability Spectre v2:                Mitigation; CSV2, BHB
Vulnerability Srbds:                     Not affected
Vulnerability Tsa:                       Not affected
Vulnerability Tsx async abort:           Not affected
Vulnerability Vmscape:                   Not affected

Comparing perf/eliminate-cross-join-fast-path (0b4e30c) to a7c2f7d (merge-base) diff
BENCH_NAME=sql_planner
BENCH_COMMAND=cargo bench --features=parquet --bench sql_planner
BENCH_FILTER=
Results will be posted here when complete


File an issue against this benchmark runner

@adriangbot
Copy link
Copy Markdown

🤖 Criterion benchmark completed (GKE) | trigger

Instance: c4a-highmem-16 (12 vCPU / 65 GiB)

CPU Details (lscpu)
Architecture:                            aarch64
CPU op-mode(s):                          64-bit
Byte Order:                              Little Endian
CPU(s):                                  16
On-line CPU(s) list:                     0-15
Vendor ID:                               ARM
Model name:                              Neoverse-V2
Model:                                   1
Thread(s) per core:                      1
Core(s) per cluster:                     16
Socket(s):                               -
Cluster(s):                              1
Stepping:                                r0p1
BogoMIPS:                                2000.00
Flags:                                   fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm jscvt fcma lrcpc dcpop sha3 sm3 sm4 asimddp sha512 sve asimdfhm dit uscat ilrcpc flagm sb paca pacg dcpodp sve2 sveaes svepmull svebitperm svesha3 svesm4 flagm2 frint svei8mm svebf16 i8mm bf16 dgh rng bti
L1d cache:                               1 MiB (16 instances)
L1i cache:                               1 MiB (16 instances)
L2 cache:                                32 MiB (16 instances)
L3 cache:                                80 MiB (1 instance)
NUMA node(s):                            1
NUMA node0 CPU(s):                       0-15
Vulnerability Gather data sampling:      Not affected
Vulnerability Indirect target selection: Not affected
Vulnerability Itlb multihit:             Not affected
Vulnerability L1tf:                      Not affected
Vulnerability Mds:                       Not affected
Vulnerability Meltdown:                  Not affected
Vulnerability Mmio stale data:           Not affected
Vulnerability Reg file data sampling:    Not affected
Vulnerability Retbleed:                  Not affected
Vulnerability Spec rstack overflow:      Not affected
Vulnerability Spec store bypass:         Mitigation; Speculative Store Bypass disabled via prctl
Vulnerability Spectre v1:                Mitigation; __user pointer sanitization
Vulnerability Spectre v2:                Mitigation; CSV2, BHB
Vulnerability Srbds:                     Not affected
Vulnerability Tsa:                       Not affected
Vulnerability Tsx async abort:           Not affected
Vulnerability Vmscape:                   Not affected
Details

group                                                 main                                   perf_eliminate-cross-join-fast-path
-----                                                 ----                                   -----------------------------------
logical_aggregate_with_join                           1.00   453.4±12.39µs        ? ?/sec    1.00    452.1±1.77µs        ? ?/sec
logical_correlated_subquery_exists                    1.01    284.2±6.25µs        ? ?/sec    1.00    282.7±1.49µs        ? ?/sec
logical_correlated_subquery_in                        1.00    284.2±6.24µs        ? ?/sec    1.00    285.5±1.14µs        ? ?/sec
logical_distinct_many_columns                         1.00    571.5±1.13µs        ? ?/sec    1.00    569.6±1.35µs        ? ?/sec
logical_join_4_with_agg_and_filter                    1.00    247.9±1.56µs        ? ?/sec    1.02    254.0±1.12µs        ? ?/sec
logical_join_8_with_agg_sort_limit                    1.00    425.5±3.24µs        ? ?/sec    1.01    428.8±2.01µs        ? ?/sec
logical_join_chain_16                                 1.00    675.5±3.99µs        ? ?/sec    1.01    681.1±1.57µs        ? ?/sec
logical_join_chain_4                                  1.00    119.5±0.93µs        ? ?/sec    1.02    122.1±0.41µs        ? ?/sec
logical_join_chain_8                                  1.00    246.6±1.66µs        ? ?/sec    1.01    250.1±0.59µs        ? ?/sec
logical_multiple_subqueries                           1.00    520.3±6.59µs        ? ?/sec    1.00    522.5±5.08µs        ? ?/sec
logical_nested_cte_4_levels                           1.00    265.7±1.22µs        ? ?/sec    1.02    270.5±1.29µs        ? ?/sec
logical_plan_struct_join_agg_sort                     1.01    179.9±1.91µs        ? ?/sec    1.00    178.7±0.81µs        ? ?/sec
logical_plan_tpcds_all                                1.01     86.2±0.36ms        ? ?/sec    1.00     85.0±0.12ms        ? ?/sec
logical_plan_tpch_all                                 1.01      6.2±0.02ms        ? ?/sec    1.00      6.1±0.01ms        ? ?/sec
logical_scalar_subquery                               1.00    308.5±6.05µs        ? ?/sec    1.01    312.5±3.85µs        ? ?/sec
logical_select_all_from_1000                          1.00    105.0±1.37ms        ? ?/sec    1.00    104.5±0.13ms        ? ?/sec
logical_select_one_from_700                           1.02   332.0±16.23µs        ? ?/sec    1.00    324.9±2.05µs        ? ?/sec
logical_trivial_join_high_numbered_columns            1.01   287.6±12.19µs        ? ?/sec    1.00    285.4±0.68µs        ? ?/sec
logical_trivial_join_low_numbered_columns             1.01   274.9±12.28µs        ? ?/sec    1.00    273.1±0.78µs        ? ?/sec
logical_union_4_branches                              1.00    418.7±1.31µs        ? ?/sec    1.02    426.4±1.73µs        ? ?/sec
logical_union_8_branches                              1.00    806.2±6.60µs        ? ?/sec    1.01    815.8±1.92µs        ? ?/sec
logical_wide_aggregate_100_exprs                      1.00      4.3±0.01ms        ? ?/sec    1.00      4.3±0.01ms        ? ?/sec
logical_wide_case_50_exprs                            1.00      2.4±0.01ms        ? ?/sec    1.00      2.4±0.00ms        ? ?/sec
logical_wide_filter_200_predicates                    1.00  1319.0±13.29µs        ? ?/sec    1.00   1312.5±7.91µs        ? ?/sec
logical_wide_filter_50_predicates                     1.00    393.3±7.42µs        ? ?/sec    1.00    394.0±2.43µs        ? ?/sec
optimizer_correlated_exists                           1.00    249.4±1.13µs        ? ?/sec    1.02    254.2±1.04µs        ? ?/sec
optimizer_join_4_with_agg_filter                      1.00    430.6±2.28µs        ? ?/sec    1.03    444.4±1.80µs        ? ?/sec
optimizer_join_chain_4                                1.00    178.9±3.67µs        ? ?/sec    1.01    181.5±0.43µs        ? ?/sec
optimizer_join_chain_8                                1.00    556.3±4.18µs        ? ?/sec    1.02    565.0±1.09µs        ? ?/sec
optimizer_select_all_from_1000                        1.00      4.6±0.02ms        ? ?/sec    1.00      4.6±0.01ms        ? ?/sec
optimizer_select_one_from_700                         1.00    252.7±1.03µs        ? ?/sec    1.01    254.9±0.41µs        ? ?/sec
optimizer_tpcds_all                                   1.00    252.8±0.22ms        ? ?/sec    1.01    255.7±0.31ms        ? ?/sec
optimizer_tpch_all                                    1.00     14.3±0.03ms        ? ?/sec    1.03     14.7±0.03ms        ? ?/sec
optimizer_wide_aggregate_100                          1.00      2.1±0.01ms        ? ?/sec    1.00      2.1±0.00ms        ? ?/sec
optimizer_wide_filter_200                             1.01      3.5±0.02ms        ? ?/sec    1.00      3.5±0.00ms        ? ?/sec
physical_intersection                                 1.00    571.7±1.51µs        ? ?/sec    1.03    591.6±1.42µs        ? ?/sec
physical_join_consider_sort                           1.00   1001.8±6.60µs        ? ?/sec    1.01   1016.4±3.02µs        ? ?/sec
physical_join_distinct                                1.01   267.4±12.27µs        ? ?/sec    1.00    266.1±0.91µs        ? ?/sec
physical_many_self_joins                              1.00      7.5±0.01ms        ? ?/sec    1.02      7.6±0.03ms        ? ?/sec
physical_plan_clickbench_all                          1.01    123.4±0.25ms        ? ?/sec    1.00    121.7±0.30ms        ? ?/sec
physical_plan_clickbench_q1                           1.00   1300.0±6.35µs        ? ?/sec    1.01   1313.5±6.06µs        ? ?/sec
physical_plan_clickbench_q10                          1.02  1954.8±12.95µs        ? ?/sec    1.00   1909.4±5.20µs        ? ?/sec
physical_plan_clickbench_q11                          1.02      2.1±0.00ms        ? ?/sec    1.00      2.1±0.01ms        ? ?/sec
physical_plan_clickbench_q12                          1.02      2.2±0.00ms        ? ?/sec    1.00      2.1±0.01ms        ? ?/sec
physical_plan_clickbench_q13                          1.01   1957.6±5.21µs        ? ?/sec    1.00   1930.3±6.45µs        ? ?/sec
physical_plan_clickbench_q14                          1.02      2.1±0.00ms        ? ?/sec    1.00      2.1±0.01ms        ? ?/sec
physical_plan_clickbench_q15                          1.01      2.0±0.01ms        ? ?/sec    1.00   1981.8±5.47µs        ? ?/sec
physical_plan_clickbench_q16                          1.01   1681.1±5.02µs        ? ?/sec    1.00   1670.5±8.09µs        ? ?/sec
physical_plan_clickbench_q17                          1.01   1722.8±4.92µs        ? ?/sec    1.00   1713.8±5.10µs        ? ?/sec
physical_plan_clickbench_q18                          1.01   1592.3±4.57µs        ? ?/sec    1.00   1580.0±4.90µs        ? ?/sec
physical_plan_clickbench_q19                          1.00   1938.0±5.53µs        ? ?/sec    1.00   1934.1±6.92µs        ? ?/sec
physical_plan_clickbench_q2                           1.02   1714.0±9.79µs        ? ?/sec    1.00   1688.6±5.08µs        ? ?/sec
physical_plan_clickbench_q20                          1.01   1496.6±5.60µs        ? ?/sec    1.00   1484.1±5.01µs        ? ?/sec
physical_plan_clickbench_q21                          1.01   1707.7±4.45µs        ? ?/sec    1.00   1692.0±5.63µs        ? ?/sec
physical_plan_clickbench_q22                          1.00      2.0±0.00ms        ? ?/sec    1.00      2.0±0.01ms        ? ?/sec
physical_plan_clickbench_q23                          1.00      2.2±0.00ms        ? ?/sec    1.00      2.2±0.01ms        ? ?/sec
physical_plan_clickbench_q24                          1.00      6.5±0.01ms        ? ?/sec    1.00      6.5±0.01ms        ? ?/sec
physical_plan_clickbench_q25                          1.01   1831.1±6.19µs        ? ?/sec    1.00   1821.7±5.69µs        ? ?/sec
physical_plan_clickbench_q26                          1.01   1667.2±3.76µs        ? ?/sec    1.00   1657.9±5.55µs        ? ?/sec
physical_plan_clickbench_q27                          1.02  1874.6±27.35µs        ? ?/sec    1.00   1829.5±5.20µs        ? ?/sec
physical_plan_clickbench_q28                          1.03      2.3±0.01ms        ? ?/sec    1.00      2.3±0.01ms        ? ?/sec
physical_plan_clickbench_q29                          1.01      2.4±0.01ms        ? ?/sec    1.00      2.4±0.01ms        ? ?/sec
physical_plan_clickbench_q3                           1.02   1608.8±6.52µs        ? ?/sec    1.00   1571.6±5.68µs        ? ?/sec
physical_plan_clickbench_q30                          1.00     15.0±0.06ms        ? ?/sec    1.00     15.0±0.04ms        ? ?/sec
physical_plan_clickbench_q31                          1.00      2.3±0.00ms        ? ?/sec    1.00      2.3±0.01ms        ? ?/sec
physical_plan_clickbench_q32                          1.01      2.3±0.01ms        ? ?/sec    1.00      2.3±0.01ms        ? ?/sec
physical_plan_clickbench_q33                          1.04  1974.6±11.12µs        ? ?/sec    1.00   1906.8±6.11µs        ? ?/sec
physical_plan_clickbench_q34                          1.00   1689.6±5.01µs        ? ?/sec    1.00   1691.5±5.45µs        ? ?/sec
physical_plan_clickbench_q35                          1.00   1752.4±5.26µs        ? ?/sec    1.00  1747.4±10.39µs        ? ?/sec
physical_plan_clickbench_q36                          1.00      2.0±0.00ms        ? ?/sec    1.01      2.1±0.02ms        ? ?/sec
physical_plan_clickbench_q37                          1.01      2.4±0.00ms        ? ?/sec    1.00      2.4±0.02ms        ? ?/sec
physical_plan_clickbench_q38                          1.01      2.4±0.01ms        ? ?/sec    1.00      2.4±0.01ms        ? ?/sec
physical_plan_clickbench_q39                          1.01      2.5±0.01ms        ? ?/sec    1.00      2.5±0.01ms        ? ?/sec
physical_plan_clickbench_q4                           1.01   1407.6±5.33µs        ? ?/sec    1.00   1393.1±4.99µs        ? ?/sec
physical_plan_clickbench_q40                          1.01      3.2±0.01ms        ? ?/sec    1.00      3.2±0.02ms        ? ?/sec
physical_plan_clickbench_q41                          1.00      2.7±0.01ms        ? ?/sec    1.00      2.7±0.02ms        ? ?/sec
physical_plan_clickbench_q42                          1.00      2.9±0.01ms        ? ?/sec    1.00      2.9±0.02ms        ? ?/sec
physical_plan_clickbench_q43                          1.00      3.0±0.01ms        ? ?/sec    1.00      3.0±0.01ms        ? ?/sec
physical_plan_clickbench_q44                          1.00   1483.3±5.40µs        ? ?/sec    1.00   1477.8±5.88µs        ? ?/sec
physical_plan_clickbench_q45                          1.00   1485.5±5.24µs        ? ?/sec    1.00   1483.9±6.62µs        ? ?/sec
physical_plan_clickbench_q46                          1.00   1776.4±5.33µs        ? ?/sec    1.00   1780.6±6.09µs        ? ?/sec
physical_plan_clickbench_q47                          1.01      2.5±0.01ms        ? ?/sec    1.00      2.5±0.01ms        ? ?/sec
physical_plan_clickbench_q48                          1.02      2.7±0.01ms        ? ?/sec    1.00      2.7±0.01ms        ? ?/sec
physical_plan_clickbench_q49                          1.02      2.8±0.01ms        ? ?/sec    1.00      2.7±0.01ms        ? ?/sec
physical_plan_clickbench_q5                           1.01   1536.3±5.41µs        ? ?/sec    1.00   1519.0±4.76µs        ? ?/sec
physical_plan_clickbench_q50                          1.01      2.6±0.00ms        ? ?/sec    1.00      2.6±0.01ms        ? ?/sec
physical_plan_clickbench_q51                          1.02   1902.5±5.26µs        ? ?/sec    1.00   1872.3±5.27µs        ? ?/sec
physical_plan_clickbench_q6                           1.01   1536.6±6.07µs        ? ?/sec    1.00   1514.3±4.62µs        ? ?/sec
physical_plan_clickbench_q7                           1.02   1370.5±5.48µs        ? ?/sec    1.00   1347.2±5.99µs        ? ?/sec
physical_plan_clickbench_q8                           1.01   1841.3±4.16µs        ? ?/sec    1.00   1825.4±5.33µs        ? ?/sec
physical_plan_clickbench_q9                           1.01  1824.2±10.06µs        ? ?/sec    1.00  1812.5±12.83µs        ? ?/sec
physical_plan_struct_join_agg_sort                    1.00   1287.2±7.76µs        ? ?/sec    1.01   1299.7±7.71µs        ? ?/sec
physical_plan_tpcds_all                               1.00    669.4±1.52ms        ? ?/sec    1.00    670.2±1.01ms        ? ?/sec
physical_plan_tpch_all                                1.00     43.9±0.07ms        ? ?/sec    1.01     44.2±0.06ms        ? ?/sec
physical_plan_tpch_q1                                 1.00   1484.4±3.02µs        ? ?/sec    1.00   1483.9±7.14µs        ? ?/sec
physical_plan_tpch_q10                                1.00      2.8±0.00ms        ? ?/sec    1.00      2.8±0.00ms        ? ?/sec
physical_plan_tpch_q11                                1.00      2.1±0.01ms        ? ?/sec    1.01      2.2±0.02ms        ? ?/sec
physical_plan_tpch_q12                                1.02   1184.4±9.67µs        ? ?/sec    1.00   1164.6±6.86µs        ? ?/sec
physical_plan_tpch_q13                                1.02    934.9±3.95µs        ? ?/sec    1.00    918.3±4.46µs        ? ?/sec
physical_plan_tpch_q14                                1.00   1350.6±2.04µs        ? ?/sec    1.00   1352.5±2.78µs        ? ?/sec
physical_plan_tpch_q16                                1.00   1489.8±1.99µs        ? ?/sec    1.00   1496.6±2.43µs        ? ?/sec
physical_plan_tpch_q17                                1.00   1652.5±3.45µs        ? ?/sec    1.01   1671.9±5.32µs        ? ?/sec
physical_plan_tpch_q18                                1.00   1759.4±3.15µs        ? ?/sec    1.01   1769.1±2.29µs        ? ?/sec
physical_plan_tpch_q19                                1.00   1608.0±2.76µs        ? ?/sec    1.01   1620.3±2.23µs        ? ?/sec
physical_plan_tpch_q2                                 1.00      4.0±0.00ms        ? ?/sec    1.00      4.0±0.01ms        ? ?/sec
physical_plan_tpch_q20                                1.00      2.2±0.00ms        ? ?/sec    1.00      2.2±0.00ms        ? ?/sec
physical_plan_tpch_q21                                1.00      2.9±0.01ms        ? ?/sec    1.00      3.0±0.00ms        ? ?/sec
physical_plan_tpch_q22                                1.00   1518.7±2.66µs        ? ?/sec    1.02   1556.1±3.30µs        ? ?/sec
physical_plan_tpch_q3                                 1.00   1867.1±3.18µs        ? ?/sec    1.00   1871.6±3.32µs        ? ?/sec
physical_plan_tpch_q4                                 1.00   1199.6±2.04µs        ? ?/sec    1.00   1195.1±2.70µs        ? ?/sec
physical_plan_tpch_q5                                 1.00      2.5±0.00ms        ? ?/sec    1.00      2.5±0.00ms        ? ?/sec
physical_plan_tpch_q6                                 1.00    621.0±1.68µs        ? ?/sec    1.01    628.3±1.30µs        ? ?/sec
physical_plan_tpch_q7                                 1.00      3.0±0.00ms        ? ?/sec    1.00      3.0±0.00ms        ? ?/sec
physical_plan_tpch_q8                                 1.00      4.0±0.01ms        ? ?/sec    1.00      3.9±0.01ms        ? ?/sec
physical_plan_tpch_q9                                 1.00      2.8±0.01ms        ? ?/sec    1.00      2.8±0.00ms        ? ?/sec
physical_select_aggregates_from_200                   1.00     15.4±0.02ms        ? ?/sec    1.00     15.4±0.02ms        ? ?/sec
physical_select_all_from_1000                         1.01    114.4±0.80ms        ? ?/sec    1.00    113.5±0.30ms        ? ?/sec
physical_select_one_from_700                          1.00    760.4±2.21µs        ? ?/sec    1.00    760.9±2.87µs        ? ?/sec
physical_sorted_union_order_by_10_int64               1.00      4.3±0.01ms        ? ?/sec    1.00      4.3±0.00ms        ? ?/sec
physical_sorted_union_order_by_10_uint64              1.00      8.4±0.01ms        ? ?/sec    1.00      8.4±0.01ms        ? ?/sec
physical_sorted_union_order_by_50_int64               1.00    107.5±0.24ms        ? ?/sec    1.01    108.3±0.32ms        ? ?/sec
physical_sorted_union_order_by_50_uint64              1.00    356.7±0.82ms        ? ?/sec    1.00    357.7±0.90ms        ? ?/sec
physical_theta_join_consider_sort                     1.00   1030.4±6.82µs        ? ?/sec    1.02   1046.6±2.57µs        ? ?/sec
physical_unnest_to_join                               1.00    647.9±1.55µs        ? ?/sec    1.03    666.4±1.42µs        ? ?/sec
physical_window_function_partition_by_12_on_values    1.00    720.5±1.30µs        ? ?/sec    1.01    727.8±1.49µs        ? ?/sec
physical_window_function_partition_by_30_on_values    1.00   1439.5±4.90µs        ? ?/sec    1.00   1435.5±2.31µs        ? ?/sec
physical_window_function_partition_by_4_on_values     1.00    437.7±1.10µs        ? ?/sec    1.01    440.5±1.02µs        ? ?/sec
physical_window_function_partition_by_7_on_values     1.00    539.5±2.05µs        ? ?/sec    1.02    551.6±3.35µs        ? ?/sec
physical_window_function_partition_by_8_on_values     1.00    590.5±2.25µs        ? ?/sec    1.01    596.4±4.54µs        ? ?/sec
with_param_values_many_columns                        1.00    429.7±2.64µs        ? ?/sec    1.00    428.9±2.59µs        ? ?/sec

Resource Usage

base (merge-base)

Metric Value
Wall time 1555.3s
Peak memory 19.9 GiB
Avg memory 19.8 GiB
CPU user 1872.8s
CPU sys 2.0s
Peak spill 0 B

branch

Metric Value
Wall time 1560.3s
Peak memory 19.9 GiB
Avg memory 19.9 GiB
CPU user 1875.3s
CPU sys 1.5s
Peak spill 0 B

File an issue against this benchmark runner

@neilconway
Copy link
Copy Markdown
Contributor

This PR makes sense intuitively, but considering that this PR adds overhead in some cases and improves efficiency in other cases, I wonder if there's a way to quantify the expected win more precisely. The sql_planner benchmark would be an obvious candidate, but it seems that this PR is a win for some cases but a loss for others, and overall slightly slower (although probably within the noise).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

optimizer Optimizer rules

Projects

None yet

Development

Successfully merging this pull request may close these issues.

perf(optimizer): EliminateCrossJoin walks the full plan tree even when there are no joins

5 participants