Skip to content

perf: compute using columns once per SELECT, not per item - #26317

Merged
alamb merged 4 commits into
apache:mainfrom
JoeryH:sql-using-columns-once
Nov 20, 2026
Merged

alamb merged 4 commits into
apache:mainfrom
JoeryH:sql-using-columns-once

Conversation

@JoeryH

@JoeryH JoeryH commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

Planning a SELECT costs O(items × input plan size), because SqlToRel::sql_select_to_rex calls LogicalPlan::using_columns() once per SELECT item. Each call walks the whole input plan, subqueries and expressions included, and the result depends only on the input plan. Nested wide SELECTs (views over views) therefore plan in roughly O(width² × depth²). The issue has the numbers. At 4000 columns × 12 levels, statement_to_plan goes from 8.0 s to 4.4 s with this change alone, and to 0.6 s once the DFSchema scan from #26314 is also gone.

What changes are included in this PR?

  • prepare_select_exprs computes plan.using_columns() once and passes it to sql_select_to_rex. plan_wildcard_options does the same for a wildcard's REPLACE items.
  • The benchmark cases moved to bench: add nested wide SELECT cases to sql_planner #27572, so the bot can compare this against main. With them, logical_nested_select_700_columns_8_levels goes from 168 ms to 50 ms (full numbers in the comments).

One behaviour difference: if using_columns() itself fails, the error now surfaces once for the SELECT instead of once per item through DataFusionErrorBuilder. using_columns only errors if the tree walk does, so I don't expect this to be observable, but I can keep the old shape with a lazily filled Option if you'd prefer.

What is the testing strategy for this PR?

The planned output is unchanged, so this relies on the existing datafusion-sql tests and sqllogictests, which pass locally. Those cover USING / NATURAL joins and wildcard expansion over them, the cases using_columns exists for. The benchmark cases in #27572 cover the performance side.

Are there any user-facing changes?

No. Planning is faster and plans are identical.


Prepared with AI assistance (Claude Code).

@github-actions github-actions Bot added sql SQL Planner core Core DataFusion crate labels Oct 14, 2026
kosiew
kosiew previously requested changes Nov 6, 2026

@kosiew kosiew left a comment

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.

@JoeryH,

Thanks for addressing the repeated USING-column discovery during SELECT planning. Sharing the result across explicit projection expressions is an appropriate optimization, and the new benchmark targets the wide, deeply nested queries described in the issue.

The architectural boundary is sound: USING-column discovery depends on the input plan, not on individual expressions, so computing it once per projection avoids redundant traversal without introducing persistent caching or changing public APIs. However, moving discovery unconditionally to the projection level also makes wildcard-only queries perform unnecessary full-plan traversals.

I'm requesting changes to preserve the existing wildcard fast paths while retaining the explicit-expression speedup. Please make discovery conditional or lazy and validate the qualified-wildcard case against the parent revision. The additional semantic and scaling coverage suggestions are non-blocking.

Comment thread datafusion/sql/src/select.rs Resolved
Comment thread datafusion/sql/src/select.rs Resolved
Comment thread datafusion/core/benches/sql_planner.rs Resolved
JoeryH and others added 2 commits November 6, 2026 09:47
SqlToRel::sql_select_to_rex called LogicalPlan::using_columns() for every
SELECT item, walking the whole input plan each time. Compute it once in
prepare_select_exprs (and once for a wildcard's REPLACE items) and pass it
down. Adds a nested wide SELECT case to the sql_planner benchmark.
Wildcard-only projections never normalize an expression, so they no longer
walk the input plan for USING columns. REPLACE items share the same lazily
collected set. Adds a width/depth matrix and a qualified-wildcard control to
the nested SELECT benchmark, and an SLT for REPLACE over a USING join.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@JoeryH
JoeryH force-pushed the sql-using-columns-once branch from e6789df to 3e532c4 Compare November 6, 2026 17:18
@github-actions github-actions Bot added the sqllogictest SQL Logic Tests (.slt) label Nov 6, 2026
@JoeryH

JoeryH commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor Author

thanks so much for the review @kosiew. I addressed your comments (with AI assistance)

@kosiew kosiew left a comment •

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.

@JoeryH,

Thanks for the follow-up changes. The projection-local lazy cache appropriately eliminates redundant USING-column traversals while preserving expression normalization and wildcard REPLACE behavior. The added regression coverage and nested-projection benchmarks address the relevant correctness and performance concerns.

The ownership boundary is appropriate: USING-column metadata belongs to the SELECT input plan and can be shared across its projection expressions. Lazy initialization also avoids unnecessary collection for wildcard-only projections, while passing the same cache through REPLACE planning preserves consistent resolution semantics.

All previous comments have been addressed, including the wildcard-traversal concern. I found no remaining blockers or actionable suggestions.

@kosiew
kosiew dismissed their stale review November 10, 2026 11:55

requested changes addressed

@JoeryH

JoeryH commented Nov 17, 2026

Copy link
Copy Markdown
Contributor Author

@kosiew thanks! anyone we should ask for a review?

@JoeryH

JoeryH commented Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

@alamb this is ready to merge if you have a moment 🙏

@alamb

alamb commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

We normally leave PRs open for at least 24 hours after approval to give time for others to review if they want to. We'll get this merged shortly

Thanks @JoeryH

@alamb

alamb commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

No. Planning is faster and plans are identical.

What evidence do we haev that planning is faster?

@JoeryH

JoeryH commented Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

No. Planning is faster and plans are identical.

What evidence do we haev that planning is faster?

The sql_planner benches added here (cargo bench -p datafusion --bench sql_planner -- logical_nested; CLICKBENCH_DATA_PATH=datafusion/core/tests/data/clickbench_hits_10.parquet is enough, the nested cases plan against an in-memory 700-column table). Rerun just now, main vs this PR:

case main this PR
700 cols × 8 levels 168.2 ms 50.3 ms
700 × 1 14.7 ms 11.0 ms
100 × 8 8.5 ms 5.9 ms
100 × 1 1.66 ms 1.57 ms
q.* 700 × 8 18.2 ms 18.3 ms
q.* 700 × 1 3.96 ms 4.01 ms

@alamb

alamb commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

Thanks @JoeryH -- can you please split the tests into their own PR so we can run them with our own bot runner to confirm?

The cases now live in apache#27572, so the benchmark bot can run them against
main before this change lands.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@JoeryH

JoeryH commented Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

@alamb done: the benchmark cases are in #27572, and this PR now holds only the planner change and its slt. Once #27572 lands I'll merge main in here so the bot can run sql_planner on it.

@github-actions github-actions Bot removed the core Core DataFusion crate label Nov 18, 2026
@kosiew kosiew mentioned this pull request Nov 19, 2026
@kosiew

kosiew commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

benchmark run corroborates comment on expected improvement

group                                                     HEAD                                   bench-26317
-----                                                     ----                                   -----------
logical_nested_qualified_wildcard_700_columns_1_levels    1.00      3.4±0.01ms        ? ?/sec    1.00      3.4±0.01ms        ? ?/sec
logical_nested_qualified_wildcard_700_columns_8_levels    1.00     15.5±0.04ms        ? ?/sec    1.01     15.6±0.04ms        ? ?/sec
logical_nested_select_100_columns_1_levels                1.05  1457.5±35.76µs        ? ?/sec    1.00   1393.4±6.39µs        ? ?/sec
logical_nested_select_100_columns_8_levels                1.35      7.1±0.03ms        ? ?/sec    1.00      5.3±0.01ms        ? ?/sec
logical_nested_select_700_columns_1_levels                1.23     11.6±0.05ms        ? ?/sec    1.00      9.4±0.02ms        ? ?/sec
logical_nested_select_700_columns_8_levels                2.65    119.8±1.20ms        ? ?/sec    1.00     45.2±0.15ms        ? ?/sec

@JoeryH

JoeryH commented Nov 19, 2026

Copy link
Copy Markdown
Contributor Author

thanks @kosiew ! I'm a little bit confused now, should I put the benchmarks back into this PR?

@kosiew

kosiew commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

@JoeryH

should I put the benchmarks back into this PR?

No, I included the above to verify the performance impact.

alamb pushed a commit to JoeryH/datafusion that referenced this pull request Nov 20, 2026
## Which issue does this PR close?

- Part of apache#26313.

## Rationale for this change

Split out of apache#26317 so the benchmark bot can compare that change against
main.

## What changes are included in this PR?

New `sql_planner` cases:

- `logical_nested_select_{100,700}_columns_{1,8}_levels`: nested SELECTs
that each name every column of the one below.
- `logical_nested_qualified_wildcard_700_columns_{1,8}_levels`: the same
nesting through qualified wildcards, as a control.

They plan against the in-memory 700-column `t700` table, so
`CLICKBENCH_DATA_PATH=datafusion/core/tests/data/clickbench_hits_10.parquet`
is enough to run them:

```
cargo bench -p datafusion --bench sql_planner -- logical_nested
```

## What is the testing strategy for this PR?

Benchmark only. The cases pass in criterion's test mode (`cargo test
--bench sql_planner -- logical_nested`).

## Are there any user-facing changes?

No.

---

Prepared with AI assistance (Claude Code).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Joery van den Hoff <joery.vandenhoff@imc.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@alamb

alamb commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

run benchmark sql_planner

@adriangbot

Copy link
Copy Markdown

🤖 Benchmark running (GKE) | trigger
Instance: c4a-highmem-16 (12 vCPU / 65 GiB) | Linux bench-c7043821768-5528-764xk 6.12.105+ #1 SMP Sat Sep 19 07:55:25 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 sql-using-columns-once (33554e7) to 904afff (merge-base) diff

Run configuration
run benchmark sql_planner

Results will be posted here when complete


File an issue against this benchmark runner

@alamb alamb left a comment

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.

Thanks @JoeryH and @kosiew -- this is a nice improvement

) -> Result<Vec<SelectExpr>> {
let mut prepared_select_exprs = Vec::with_capacity(projection.len());
let mut error_builder = DataFusionErrorBuilder::new();
let mut using_columns = LazyUsingColumns::default();

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 wonder if we could/should put this structure on the PlannerContext as it applies to all calls within that query?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks @alamb! I don't think it fits on PlannerContext: the set depends on the SELECT's input plan, and the context is shared by every SELECT in the query (derived tables, subqueries, set-operation legs, CTEs), each with a different input. Keeping it correct there would mean saving and restoring it around every SELECT like outer_queries_schemas_stack, or keying it by plan. One projection is exactly the scope where the input is fixed, so that's where the cache lives.

What's left is that each nested SELECT still walks its own input once, inner SELECTs included. Reusing an inner SELECT's set in the outer one could remove that, but it needs a way to tie sets to subtrees. Happy to file a follow-up if profiles show it's still significant after this.

@alamb alamb Nov 20, 2026 •

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.

No need for a follow up -- what I was thinking was that if there are other calls like this that can be cached it would be valuable to consolidate / make a pattern that could be easily followed rather than just a bunch of one offs

Thanks for the response

@alamb alamb added the performance Make DataFusion faster label Nov 20, 2026
@adriangbot

Copy link
Copy Markdown

🤖 Benchmark completed (GKE) | trigger

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

Comparing sql-using-columns-once (33554e7) to 904afff (merge-base) diff

Run configuration
run benchmark sql_planner
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                                                     HEAD                                    sql-using-columns-once
-----                                                     ----                                    ----------------------
logical_aggregate_with_join                               1.00    317.3±1.67µs        ? ?/sec     1.00    316.6±3.01µs        ? ?/sec
logical_correlated_subquery_exists                        1.03    215.9±2.18µs        ? ?/sec     1.00    210.0±1.27µs        ? ?/sec
logical_correlated_subquery_in                            1.03    217.6±1.75µs        ? ?/sec     1.00    210.8±1.32µs        ? ?/sec
logical_distinct_many_columns                             1.03    262.4±1.80µs        ? ?/sec     1.00    254.7±0.94µs        ? ?/sec
logical_join_4_with_agg_and_filter                        1.06    198.7±1.78µs        ? ?/sec     1.00    186.6±1.25µs        ? ?/sec
logical_join_8_with_agg_sort_limit                        1.05    342.8±3.22µs        ? ?/sec     1.00    328.1±1.60µs        ? ?/sec
logical_join_chain_16                                     1.03    633.3±3.84µs        ? ?/sec     1.00    615.5±2.28µs        ? ?/sec
logical_join_chain_4                                      1.03     76.0±0.48µs        ? ?/sec     1.00     73.9±0.25µs        ? ?/sec
logical_join_chain_8                                      1.02    201.7±1.41µs        ? ?/sec     1.00    198.7±0.80µs        ? ?/sec
logical_multiple_subqueries                               1.05    414.0±2.97µs        ? ?/sec     1.00    394.1±2.53µs        ? ?/sec
logical_nested_cte_4_levels                               1.06    201.4±2.47µs        ? ?/sec     1.00    189.4±1.24µs        ? ?/sec
logical_nested_qualified_wildcard_700_columns_1_levels    1.02      3.6±0.03ms        ? ?/sec     1.00      3.5±0.03ms        ? ?/sec
logical_nested_qualified_wildcard_700_columns_8_levels    1.01     16.2±0.13ms        ? ?/sec     1.00     16.0±0.06ms        ? ?/sec
logical_nested_select_100_columns_1_levels                1.07  1510.1±14.33µs        ? ?/sec     1.00   1411.4±5.62µs        ? ?/sec
logical_nested_select_100_columns_8_levels                1.37      7.5±0.05ms        ? ?/sec     1.00      5.5±0.04ms        ? ?/sec
logical_nested_select_700_columns_1_levels                1.24     12.4±0.09ms        ? ?/sec     1.00     10.0±0.06ms        ? ?/sec
logical_nested_select_700_columns_8_levels                2.57    125.6±2.16ms        ? ?/sec     1.00     48.8±0.31ms        ? ?/sec
logical_plan_struct_join_agg_sort                         1.04    121.6±0.95µs        ? ?/sec     1.00    117.1±1.01µs        ? ?/sec
logical_plan_tpcds_all                                    1.05     72.3±0.51ms        ? ?/sec     1.00     68.8±0.49ms        ? ?/sec
logical_plan_tpch_all                                     1.03      5.1±0.03ms        ? ?/sec     1.00      5.0±0.03ms        ? ?/sec
logical_scalar_subquery                                   1.03    223.8±1.25µs        ? ?/sec     1.00    217.7±1.50µs        ? ?/sec
logical_select_all_from_1000                              1.00      2.3±0.01ms        ? ?/sec     1.01      2.4±0.02ms        ? ?/sec
logical_select_one_from_700                               1.00   235.4±10.23µs        ? ?/sec     1.00    235.0±4.35µs        ? ?/sec
logical_trivial_join_high_numbered_columns                1.00    193.9±1.29µs        ? ?/sec     1.01    196.8±2.49µs        ? ?/sec
logical_trivial_join_low_numbered_columns                 1.00    195.1±1.26µs        ? ?/sec     1.01    196.2±2.32µs        ? ?/sec
logical_union_4_branches                                  1.02    320.0±2.31µs        ? ?/sec     1.00    314.3±1.36µs        ? ?/sec
logical_union_8_branches                                  1.03    654.5±4.99µs        ? ?/sec     1.00    635.1±1.90µs        ? ?/sec
logical_wide_aggregate_1000_exprs                         1.02     21.9±0.12ms        ? ?/sec     1.00     21.4±0.13ms        ? ?/sec
logical_wide_aggregate_100_exprs                          1.02  1517.7±10.28µs        ? ?/sec     1.00   1483.0±9.36µs        ? ?/sec
logical_wide_case_50_exprs                                1.03  1472.4±15.29µs        ? ?/sec     1.00   1433.9±6.01µs        ? ?/sec
logical_wide_filter_200_predicates                        1.03   1103.2±9.06µs        ? ?/sec     1.00   1072.5±7.46µs        ? ?/sec
logical_wide_filter_50_predicates                         1.03    328.6±1.74µs        ? ?/sec     1.00    320.3±3.09µs        ? ?/sec
optimizer_correlated_exists                               1.00    219.0±0.50µs        ? ?/sec     1.00    218.2±0.39µs        ? ?/sec
optimizer_join_4_with_agg_filter                          1.00    389.2±1.59µs        ? ?/sec     1.01    393.6±1.59µs        ? ?/sec
optimizer_join_chain_4                                    1.00    137.4±0.19µs        ? ?/sec     1.00    137.3±0.15µs        ? ?/sec
optimizer_join_chain_8                                    1.01    371.7±1.16µs        ? ?/sec     1.00    369.8±0.90µs        ? ?/sec
optimizer_select_all_from_1000                            1.00      2.4±0.01ms        ? ?/sec     1.00      2.4±0.01ms        ? ?/sec
optimizer_select_one_from_700                             1.02    242.0±1.72µs        ? ?/sec     1.00    236.8±2.07µs        ? ?/sec
optimizer_tpcds_all                                       1.00    237.8±1.01ms        ? ?/sec     1.00    237.0±1.02ms        ? ?/sec
optimizer_tpch_all                                        1.00     14.5±0.06ms        ? ?/sec     1.01     14.6±0.06ms        ? ?/sec
optimizer_wide_aggregate_100                              1.00   1760.9±2.45µs        ? ?/sec     1.01   1773.9±4.74µs        ? ?/sec
optimizer_wide_filter_200                                 1.00      3.1±0.02ms        ? ?/sec     1.00      3.1±0.01ms        ? ?/sec
optimizer_wide_projection_stack_all                       1.00      5.9±0.03ms        ? ?/sec     1.02      6.0±0.03ms        ? ?/sec
optimizer_wide_projection_stack_half                      1.00      4.1±0.02ms        ? ?/sec     1.00      4.1±0.02ms        ? ?/sec
physical_cte_materialized_chain_6                         1.02      2.5±0.04ms        ? ?/sec     1.00      2.4±0.06ms        ? ?/sec
physical_cte_materialized_one_ref                         1.01    769.4±3.03µs        ? ?/sec     1.00    762.3±5.81µs        ? ?/sec
physical_cte_materialized_two_refs                        1.00    979.6±8.25µs        ? ?/sec     1.00    982.2±6.45µs        ? ?/sec
physical_cte_mixed                                        1.02      3.3±0.06ms        ? ?/sec     1.00      3.2±0.07ms        ? ?/sec
physical_cte_not_materialized_chain_6                     1.00     18.5±0.05ms        ? ?/sec     1.01     18.6±0.13ms        ? ?/sec
physical_cte_not_materialized_one_ref                     1.00    688.0±2.03µs        ? ?/sec     1.01    696.4±3.41µs        ? ?/sec
physical_cte_not_materialized_two_refs                    1.02  1269.7±10.12µs        ? ?/sec     1.00   1248.8±8.39µs        ? ?/sec
physical_cte_unmarked_chain_6                             1.01     18.6±0.06ms        ? ?/sec     1.00     18.4±0.08ms        ? ?/sec
physical_cte_unmarked_one_ref                             1.00    689.8±7.59µs        ? ?/sec     1.03    711.8±6.14µs        ? ?/sec
physical_cte_unmarked_two_refs                            1.01  1282.9±32.00µs        ? ?/sec     1.00  1266.4±17.13µs        ? ?/sec
physical_intersection                                     1.00    529.4±2.57µs        ? ?/sec     1.00    531.4±6.91µs        ? ?/sec
physical_join_consider_sort                               1.01   1005.0±8.72µs        ? ?/sec     1.00    998.8±7.75µs        ? ?/sec
physical_join_distinct                                    1.00    190.4±1.41µs        ? ?/sec     1.01    193.2±2.45µs        ? ?/sec
physical_many_self_joins                                  1.00      5.7±0.05ms        ? ?/sec     1.01      5.7±0.05ms        ? ?/sec
physical_plan_clickbench_all                              1.08    190.2±4.96ms        ? ?/sec     1.00    175.4±4.92ms        ? ?/sec
physical_plan_clickbench_q1                               1.03  1551.3±83.75µs        ? ?/sec     1.00  1500.7±39.66µs        ? ?/sec
physical_plan_clickbench_q10                              1.10      2.5±0.08ms        ? ?/sec     1.00      2.2±0.09ms        ? ?/sec
physical_plan_clickbench_q11                              1.03      3.4±0.10ms        ? ?/sec     1.00      3.3±0.12ms        ? ?/sec
physical_plan_clickbench_q12                              1.03      3.5±0.07ms        ? ?/sec     1.00      3.4±0.08ms        ? ?/sec
physical_plan_clickbench_q13                              1.03      3.3±0.09ms        ? ?/sec     1.00      3.2±0.06ms        ? ?/sec
physical_plan_clickbench_q14                              1.04      3.4±0.11ms        ? ?/sec     1.00      3.3±0.08ms        ? ?/sec
physical_plan_clickbench_q15                              1.06      3.4±0.06ms        ? ?/sec     1.00      3.2±0.14ms        ? ?/sec
physical_plan_clickbench_q16                              1.04      2.1±0.11ms        ? ?/sec     1.00      2.0±0.12ms        ? ?/sec
physical_plan_clickbench_q17                              1.03      2.2±0.12ms        ? ?/sec     1.00      2.1±0.06ms        ? ?/sec
physical_plan_clickbench_q18                              1.06  1964.4±106.25µs        ? ?/sec    1.00  1850.7±73.56µs        ? ?/sec
physical_plan_clickbench_q19                              1.07      2.5±0.07ms        ? ?/sec     1.00      2.4±0.06ms        ? ?/sec
physical_plan_clickbench_q2                               1.12      2.8±0.08ms        ? ?/sec     1.00      2.5±0.09ms        ? ?/sec
physical_plan_clickbench_q20                              1.05      2.4±0.09ms        ? ?/sec     1.00      2.3±0.07ms        ? ?/sec
physical_plan_clickbench_q21                              1.09      2.3±0.06ms        ? ?/sec     1.00      2.1±0.10ms        ? ?/sec
physical_plan_clickbench_q22                              1.07      3.7±0.08ms        ? ?/sec     1.00      3.4±0.10ms        ? ?/sec
physical_plan_clickbench_q23                              1.04      4.1±0.07ms        ? ?/sec     1.00      3.9±0.08ms        ? ?/sec
physical_plan_clickbench_q24                              1.03      5.7±0.06ms        ? ?/sec     1.00      5.5±0.06ms        ? ?/sec
physical_plan_clickbench_q25                              1.01      3.1±0.08ms        ? ?/sec     1.00      3.0±0.07ms        ? ?/sec
physical_plan_clickbench_q26                              1.03      2.9±0.08ms        ? ?/sec     1.00      2.8±0.07ms        ? ?/sec
physical_plan_clickbench_q27                              1.04      3.1±0.13ms        ? ?/sec     1.00      2.9±0.04ms        ? ?/sec
physical_plan_clickbench_q28                              1.09      3.6±0.06ms        ? ?/sec     1.00      3.3±0.06ms        ? ?/sec
physical_plan_clickbench_q29                              1.09      3.8±0.08ms        ? ?/sec     1.00      3.5±0.07ms        ? ?/sec
physical_plan_clickbench_q3                               1.09  1935.4±87.03µs        ? ?/sec     1.00  1774.4±79.43µs        ? ?/sec
physical_plan_clickbench_q30                              1.01     12.5±0.09ms        ? ?/sec     1.00     12.4±0.21ms        ? ?/sec
physical_plan_clickbench_q31                              1.04      3.8±0.07ms        ? ?/sec     1.00      3.6±0.09ms        ? ?/sec
physical_plan_clickbench_q32                              1.03      3.7±0.08ms        ? ?/sec     1.00      3.6±0.09ms        ? ?/sec
physical_plan_clickbench_q33                              1.08      2.5±0.08ms        ? ?/sec     1.00      2.3±0.09ms        ? ?/sec
physical_plan_clickbench_q34                              1.03      2.2±0.09ms        ? ?/sec     1.00      2.1±0.10ms        ? ?/sec
physical_plan_clickbench_q35                              1.00      2.1±0.07ms        ? ?/sec     1.08      2.3±0.10ms        ? ?/sec
physical_plan_clickbench_q36                              1.00      2.5±0.08ms        ? ?/sec     1.04      2.5±0.07ms        ? ?/sec
physical_plan_clickbench_q37                              1.00      3.6±0.13ms        ? ?/sec     1.03      3.8±0.09ms        ? ?/sec
physical_plan_clickbench_q38                              1.00      3.6±0.10ms        ? ?/sec     1.05      3.7±0.05ms        ? ?/sec
physical_plan_clickbench_q39                              1.00      3.5±0.10ms        ? ?/sec     1.07      3.7±0.05ms        ? ?/sec
physical_plan_clickbench_q4                               1.07  1741.5±79.38µs        ? ?/sec     1.00  1620.1±62.59µs        ? ?/sec
physical_plan_clickbench_q40                              1.00      3.9±0.11ms        ? ?/sec     1.05      4.1±0.06ms        ? ?/sec
physical_plan_clickbench_q41                              1.00      3.7±0.11ms        ? ?/sec     1.08      4.0±0.04ms        ? ?/sec
physical_plan_clickbench_q42                              1.00      3.7±0.20ms        ? ?/sec     1.06      4.0±0.04ms        ? ?/sec
physical_plan_clickbench_q43                              1.00      3.8±0.11ms        ? ?/sec     1.05      4.0±0.06ms        ? ?/sec
physical_plan_clickbench_q44                              1.00  1628.3±63.81µs        ? ?/sec     1.15  1870.1±91.14µs        ? ?/sec
physical_plan_clickbench_q45                              1.00  1684.0±90.77µs        ? ?/sec     1.11  1864.7±75.18µs        ? ?/sec
physical_plan_clickbench_q46                              1.00      2.1±0.10ms        ? ?/sec     1.09      2.2±0.07ms        ? ?/sec
physical_plan_clickbench_q47                              1.00      2.8±0.11ms        ? ?/sec     1.05      3.0±0.08ms        ? ?/sec
physical_plan_clickbench_q48                              1.03      3.9±0.08ms        ? ?/sec     1.00      3.8±0.11ms        ? ?/sec
physical_plan_clickbench_q49                              1.01      3.9±0.06ms        ? ?/sec     1.00      3.9±0.09ms        ? ?/sec
physical_plan_clickbench_q5                               1.08  1909.3±104.64µs        ? ?/sec    1.00  1773.1±103.03µs        ? ?/sec
physical_plan_clickbench_q50                              1.03      6.0±0.10ms        ? ?/sec     1.00      5.8±0.06ms        ? ?/sec
physical_plan_clickbench_q51                              1.07      2.5±0.05ms        ? ?/sec     1.00      2.4±0.09ms        ? ?/sec
physical_plan_clickbench_q52                              1.06      3.0±0.06ms        ? ?/sec     1.00      2.8±0.07ms        ? ?/sec
physical_plan_clickbench_q53                              1.07      2.3±0.06ms        ? ?/sec     1.00      2.1±0.08ms        ? ?/sec
physical_plan_clickbench_q54                              1.11      2.2±0.11ms        ? ?/sec     1.00  1986.9±96.82µs        ? ?/sec
physical_plan_clickbench_q55                              1.15      2.2±0.05ms        ? ?/sec     1.00  1887.4±118.45µs        ? ?/sec
physical_plan_clickbench_q56                              1.13      2.2±0.08ms        ? ?/sec     1.00  1904.6±61.75µs        ? ?/sec
physical_plan_clickbench_q57                              1.10      2.9±0.10ms        ? ?/sec     1.00      2.6±0.10ms        ? ?/sec
physical_plan_clickbench_q58                              1.05      3.6±0.09ms        ? ?/sec     1.00      3.4±0.12ms        ? ?/sec
physical_plan_clickbench_q59                              1.10      2.0±0.11ms        ? ?/sec     1.00  1849.3±85.30µs        ? ?/sec
physical_plan_clickbench_q6                               1.12  1970.9±73.85µs        ? ?/sec     1.00  1753.8±82.56µs        ? ?/sec
physical_plan_clickbench_q60                              1.09      2.1±0.09ms        ? ?/sec     1.00  1919.2±96.65µs        ? ?/sec
physical_plan_clickbench_q7                               1.09  1730.3±58.46µs        ? ?/sec     1.00  1583.0±61.61µs        ? ?/sec
physical_plan_clickbench_q8                               1.08      3.1±0.07ms        ? ?/sec     1.00      2.8±0.12ms        ? ?/sec
physical_plan_clickbench_q9                               1.11      2.4±0.10ms        ? ?/sec     1.00      2.1±0.11ms        ? ?/sec
physical_plan_struct_join_agg_sort                        1.02  1265.2±13.59µs        ? ?/sec     1.00  1244.4±16.82µs        ? ?/sec
physical_plan_tpcds_all                                   1.02    610.4±5.45ms        ? ?/sec     1.00    598.7±5.73ms        ? ?/sec
physical_plan_tpch_all                                    1.02     45.8±1.22ms        ? ?/sec     1.00     44.7±0.83ms        ? ?/sec
physical_plan_tpch_q1                                     1.02  1446.3±19.69µs        ? ?/sec     1.00  1417.9±10.49µs        ? ?/sec
physical_plan_tpch_q10                                    1.03      2.3±0.05ms        ? ?/sec     1.00      2.2±0.06ms        ? ?/sec
physical_plan_tpch_q11                                    1.02      2.3±0.08ms        ? ?/sec     1.00      2.3±0.04ms        ? ?/sec
physical_plan_tpch_q12                                    1.05  1341.5±69.38µs        ? ?/sec     1.00  1278.1±15.95µs        ? ?/sec
physical_plan_tpch_q13                                    1.09  1123.2±49.13µs        ? ?/sec     1.00   1032.9±8.05µs        ? ?/sec
physical_plan_tpch_q14                                    1.11  1344.8±44.45µs        ? ?/sec     1.00  1216.0±13.96µs        ? ?/sec
physical_plan_tpch_q16                                    1.12  1915.1±91.59µs        ? ?/sec     1.00  1710.8±45.72µs        ? ?/sec
physical_plan_tpch_q17                                    1.05  1701.4±89.59µs        ? ?/sec     1.00  1615.9±43.79µs        ? ?/sec
physical_plan_tpch_q18                                    1.16      2.2±0.05ms        ? ?/sec     1.00  1930.6±41.80µs        ? ?/sec
physical_plan_tpch_q19                                    1.08      2.2±0.08ms        ? ?/sec     1.00      2.1±0.04ms        ? ?/sec
physical_plan_tpch_q2                                     1.03      3.6±0.07ms        ? ?/sec     1.00      3.4±0.08ms        ? ?/sec
physical_plan_tpch_q20                                    1.15      2.5±0.07ms        ? ?/sec     1.00      2.2±0.07ms        ? ?/sec
physical_plan_tpch_q21                                    1.10      2.9±0.05ms        ? ?/sec     1.00      2.7±0.09ms        ? ?/sec
physical_plan_tpch_q22                                    1.18  1879.0±75.56µs        ? ?/sec     1.00  1598.5±47.83µs        ? ?/sec
physical_plan_tpch_q3                                     1.00  1674.5±22.61µs        ? ?/sec     1.01  1687.4±32.95µs        ? ?/sec
physical_plan_tpch_q4                                     1.01   1093.5±9.07µs        ? ?/sec     1.00   1087.7±8.28µs        ? ?/sec
physical_plan_tpch_q5                                     1.00      2.1±0.03ms        ? ?/sec     1.02      2.2±0.04ms        ? ?/sec
physical_plan_tpch_q6                                     1.00    593.7±2.93µs        ? ?/sec     1.01    598.9±2.34µs        ? ?/sec
physical_plan_tpch_q7                                     1.00      2.6±0.08ms        ? ?/sec     1.00      2.6±0.05ms        ? ?/sec
physical_plan_tpch_q8                                     1.03      3.4±0.07ms        ? ?/sec     1.00      3.3±0.08ms        ? ?/sec
physical_plan_tpch_q9                                     1.04      2.6±0.06ms        ? ?/sec     1.00      2.5±0.06ms        ? ?/sec
physical_select_aggregates_from_200                       1.00      6.1±0.07ms        ? ?/sec     1.00      6.1±0.04ms        ? ?/sec
physical_select_all_from_1000                             1.00      5.9±0.03ms        ? ?/sec     1.00      5.9±0.04ms        ? ?/sec
physical_select_one_from_700                              1.00    640.7±2.53µs        ? ?/sec     1.00    638.6±1.96µs        ? ?/sec
physical_sorted_union_order_by_10_int64                   1.00      3.6±0.06ms        ? ?/sec     1.01      3.7±0.10ms        ? ?/sec
physical_sorted_union_order_by_10_uint64                  1.00      7.7±0.04ms        ? ?/sec     1.01      7.8±0.05ms        ? ?/sec
physical_sorted_union_order_by_50_int64                   1.00     69.6±0.58ms        ? ?/sec     1.02     71.2±0.43ms        ? ?/sec
physical_sorted_union_order_by_50_uint64                  1.00    320.1±2.57ms        ? ?/sec     1.01    323.8±2.53ms        ? ?/sec
physical_theta_join_consider_sort                         1.00   1024.2±7.34µs        ? ?/sec     1.00   1019.2±5.56µs        ? ?/sec
physical_unnest_to_join                                   1.00    562.5±2.76µs        ? ?/sec     1.02    573.0±7.66µs        ? ?/sec
physical_window_function_partition_by_12_on_values        1.00    606.9±2.77µs        ? ?/sec     1.00    604.6±3.24µs        ? ?/sec
physical_window_function_partition_by_30_on_values        1.00   1041.6±5.74µs        ? ?/sec     1.00   1042.2±6.82µs        ? ?/sec
physical_window_function_partition_by_4_on_values         1.00    390.1±1.25µs        ? ?/sec     1.01    392.6±4.64µs        ? ?/sec
physical_window_function_partition_by_7_on_values         1.00    468.2±1.68µs        ? ?/sec     1.01    470.8±5.30µs        ? ?/sec
physical_window_function_partition_by_8_on_values         1.00    496.6±1.64µs        ? ?/sec     1.01    500.3±1.52µs        ? ?/sec
with_param_values_many_columns                            1.01    245.0±1.44µs        ? ?/sec     1.00    242.1±1.39µs        ? ?/sec

Resource Usage

sql_planner — base (merge-base)

Metric Value
Wall time 2245.5s
Peak memory 154.7 MiB
Avg memory 95.1 MiB
CPU user 2129.5s
CPU sys 2.4s
Peak spill 0 B

sql_planner — branch

Metric Value
Wall time 2220.5s
Peak memory 151.7 MiB
Avg memory 96.3 MiB
CPU user 2149.7s
CPU sys 2.5s
Peak spill 0 B

File an issue against this benchmark runner

@alamb
alamb added this pull request to the merge queue Nov 20, 2026
Merged via the queue into apache:main with commit dcaac3c Nov 20, 2026
42 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance Make DataFusion faster sql SQL Planner sqllogictest SQL Logic Tests (.slt) v57.0.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SQL planner calls LogicalPlan::using_columns() once per SELECT item, making wide nested SELECTs quadratic

4 participants