Skip to content

feat: DISTINCT handling for Aggregate UDFs - #25288

Open
mkleen wants to merge 22 commits into
apache:mainfrom
mkleen:eliminate-aggregate-distinct
Open

mkleen wants to merge 22 commits into
apache:mainfrom
mkleen:eliminate-aggregate-distinct

Conversation

@mkleen

@mkleen mkleen commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

SELECT g, min(DISTINCT x) FROM t GROUP BY g is planned as if DISTINCT mattered. SingleDistinctToGroupBy rewrites it into an inner group by at (g, x) grain just to deduplicate x, even though min returns the same value with or without duplicates. On a 4M-row table with ~1M distinct x values, that extra stage makes the query up to 10x slower and reserves ~190 MB where the plain min(x) needs less than 1 MB.

The same applies to every aggregate whose result cannot change when duplicates are removed: max, bool_and, bool_or, bit_and, bit_or, approx_distinct.

Nothing in DataFusion could say which aggregates those are. SingleDistinctToGroupBy identifies sum/min/max by lowercased function name, and a user-defined aggregate had no way to declare the property at all.

What changes are included in this PR?

A new AggregateUDFImpl::distinct_handling() method returning a new enum DistinctHandling:

Variant Meaning Built-ins
Insensitive Duplicates cannot change the result (the merge is idempotent), so the planner may drop DISTINCT. min, max, bool_and, bool_or, bit_and, bit_or, approx_distinct, grouping
Sensitive (default) DISTINCT is applied, either by the accumulator itself (count, sum, avg, var_samp, array_agg, bit_xor, ...) or by SingleDistinctToGroupBy deduplicating the input first (stddev, approx_median). everything not listed
Unsupported The result depends on duplicates, but nothing deduplicates the input, so f(DISTINCT ...) errors or silently returns the non-distinct answer. Declaration only for now; rejecting these at planning time is a follow-up. corr, covar_samp, covar_pop, regr_*, nth_value, approx_percentile_cont, approx_percentile_cont_with_weight

first_value, last_value and any_value stay at Honored with a TODO: whether DISTINCT is a no-op for them depends on ORDER BY.

A new logical optimizer rule, EliminateAggregateDistinct, placed before SingleDistinctToGroupBy. It clears the DISTINCT flag on Ignored aggregates and keeps the output column name with an alias:

Aggregate: groupBy=[[g]], aggr=[[min(DISTINCT x)]]
-- becomes
Aggregate: groupBy=[[g]], aggr=[[min(x) AS min(DISTINCT x)]]

What is the testing strategy for this PR?

  • Unit tests in datafusion/optimizer/src/eliminate_aggregate_distinct.rs: min, min+max, a non-distinct aggregate beside the distinct one, FILTER, the negative cases sum and bit_xor, a mixed node that must be left alone (on its own and followed by SingleDistinctToGroupBy), an Honored distinct aggregate in the group expressions, and a plan with no Aggregate.
  • sqllogictest:
    • aggregates_simplify.slt gets a new section. For each Ignored aggregate it checks the EXPLAIN plan and the query results, over data with duplicates and NULLs. It also covers the negative cases (bit_xor, count), a mixed node, and FILTER.
    • single_distinct_to_groupby.slt has an updated expectation for min(DISTINCT v).
    • explain.slt lists the new rule.
  • Documentation: a new "Declaring how an Aggregate UDF treats DISTINCT" section in adding-udfs.md, and the rule in optimizer_rule_reference.md.

Benchmark

Here are some results from a local benchmark. Every query has the shape SELECT g, <aggregate> FROM t GROUP BY g, over 4M rows where x has about 1M distinct values and b has two.

Speedup (main time / branch time):

query 2k groups, 1 part 2k groups, 10 parts 500k groups, 1 part 500k groups, 10 parts
min 10.10x 6.56x 3.44x 2.49x
max 10.37x 7.19x 3.35x 2.44x
bit_and 10.36x 7.73x 3.50x 2.53x
bit_or 10.25x 7.10x 3.33x 2.52x
bool_and 1.66x 1.53x 1.51x 2.36x
bool_or 1.50x 1.65x 1.50x 1.71x
approx_distinct 1.97x 1.77x 1.77x 1.77x

Peak memory-pool reservation in MB (main → branch):

query 2k groups, 1 part 2k groups, 10 parts 500k groups, 1 part 500k groups, 10 parts
min 191.4 → 0.2 167.9 → 1.5 191.4 → 24.0 167.9 → 42.7
max 191.4 → 0.2 167.9 → 1.5 191.4 → 24.0 167.8 → 42.9
bit_and 191.4 → 0.2 168.2 → 1.5 191.4 → 24.0 167.5 → 41.8
bit_or 191.4 → 0.2 167.6 → 1.5 191.4 → 24.0 167.5 → 42.0
bool_and 0.3 → 0.1 2.7 → 1.3 28.2 → 20.0 34.1 → 26.0
bool_or 0.3 → 0.1 2.7 → 1.3 28.2 → 20.0 35.4 → 26.9
approx_distinct 191.4 → 31.5 170.5 → 41.5 191.4 → 62.5 168.0 → 88.5

Are there any user-facing changes?

  • AggregateUDFImpl::distinct_handling() with default DistinctHandling::Honored, so existing implementations compile and behave as before.

LLM-generated code disclosure

This PR includes LLM-generated code and comments. All LLM-generated content has been manually reviewed.

mkleen and others added 5 commits September 12, 2026 09:26
…ag when it is a no-op

Nothing recorded whether an aggregate cares about duplicates in its input.
`min(DISTINCT x)` already built a plain `MinAccumulator`, so the flag was a
no-op at execution time, but `SingleDistinctToGroupBy` still saw it and
rewrote `SELECT g, min(DISTINCT x) FROM t GROUP BY g` into an inner group by
at `(g, x)` grain. Callers also had no way to ask the question: the rule
identified sum/min/max by lowercased string name.

Add `AggregateUDFImpl::distinct_handling`, returning a three-valued
`DistinctHandling`:

- `Ignored`   - the merge is idempotent, so `DISTINCT` cannot change the
                result and the planner may drop it
- `Honored`   - the accumulator reads `is_distinct` and deduplicates
- `Unsupported` - the accumulator does not implement `DISTINCT`

`Honored` is the default, so external UDFs are unaffected. The property is
forwarded from both the `AggregateUDF` wrapper and `AliasedAggregateUDFImpl`.

Tag the built-ins. `Ignored`: min, max, bool_and, bool_or, approx_distinct,
and the AND/OR arms of the bitwise operation (XOR cancels duplicate pairs and
stays `Honored`). `Unsupported`: the aggregates that either reject `DISTINCT`
already or silently return the non-distinct answer. first_value, last_value
and any_value keep the default with a TODO, because whether they ignore
duplicates depends on `ORDER BY`.

Add `EliminateAggregateDistinct`, inserted immediately before
`SingleDistinctToGroupBy`. It returns `Transformed::no` for every node that is
not an `Aggregate`, and uses `NamePreserver` to keep the output schema intact,
so the plan reads `min(t.v) AS min(DISTINCT t.v)`.

`Unsupported` is declared but not yet enforced. Rejecting `corr(DISTINCT x, y)`
fixes a silent wrong answer but turns queries that are accepted today into
planning errors, which belongs in its own change.

Over 4,000,000 rows in 2,000 groups, `min(DISTINCT x)` needed a 192M pool
before this change and completes under 1M after it.

Part of apache#24929, tracked as apache#11686.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015YwFpxheiiUNMadTNyeHiu
…gged functions

Review of the previous commit turned up two problems.

`EliminateAggregateDistinct` stripped a no-op `DISTINCT` from one aggregate
without regard for the others on the same node, which changed which plans
`SingleDistinctToGroupBy` rewrites. That rule keys off how many distinct
aggregates a node has and whether they share an argument, so removing one can
push a node either way: `sum(DISTINCT cast(x)), max(DISTINCT x)` newly
qualified once the max lost its flag, gaining an inner group by it never had,
and where a rewrite happened regardless a shared inner group key turned into a
separate accumulator at that finer grain. Gate the rule on every `DISTINCT` in
the node being `Ignored`. This is conservative - `min(DISTINCT x),
count(DISTINCT y)` now keeps the min flag though no rewrite is possible either
way - but it cannot regress a plan. `group_by.slt` returns to its original
expectations.

`stddev`, `stddev_pop`, `var_samp`, `var_pop` and `approx_median` were tagged
`Unsupported` on the grounds that their accumulators return `not_impl_err!`.
That path is only reached when `SingleDistinctToGroupBy` cannot fire. All five
take a single argument, so the rewrite deduplicates the input for them and
`f(DISTINCT x)` returns the right answer today, as `aggregate.slt:749` already
asserts for `approx_median`. Leave them at the default `Honored` with a comment,
since enforcing `Unsupported` later would have broken those queries. Verified
the remaining `Unsupported` tags: `approx_percentile_cont`, `nth_value` and
`covar_samp` take more than one argument, so no rewrite fires and they silently
return the non-distinct answer, while `approx_percentile_cont_with_weight`
errors.

Also widen the `Honored` and `Unsupported` doc comments, which described only
the accumulator and promised a planning-time rejection that does not exist yet.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015YwFpxheiiUNMadTNyeHiu
Clear the `DISTINCT` flag in place instead of matching the expression twice
and rebuilding `AggregateFunctionParams` field by field. Collect the
distinct aggregates' `DistinctHandling` and check them in one expression
rather than tracking two flags with an early stop, and restore the saved
name through `Transformed::update_data`.

The strip helper still checks `DistinctHandling::Ignored` itself rather than
relying on the node-level gate: the gate only inspects `aggr_expr`, while
`map_expressions` also visits `group_expr`. A plan built with
`groupBy=[sum(DISTINCT c)], aggr=[min(DISTINCT b)]` would otherwise lose the
`sum` flag; SQL cannot produce it, but `Aggregate::try_new` does not reject
it. `keep_honored_distinct_in_group_expr` covers this.

Drop `eliminate_distinct_from_max`, which duplicated the `min` test and is
covered by the min+max test.

No plan changes: all optimizer snapshots and the aggregates_simplify,
group_by, single_distinct_to_groupby and explain sqllogictests pass
unmodified.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01679fptc2vZkRV9hP4Eu5XB
The comments left on these functions in 957c8d6 said the accumulator
rejects `DISTINCT` but `SingleDistinctToGroupBy` always deduplicates the
input first, so `f(DISTINCT x)` returns the right answer today. Neither half
holds for all five.

`stddev`, `stddev_pop` and `approx_median` do reject `DISTINCT`, but they
only work when the rewrite applies. Beside an aggregate that blocks it, such
as `avg`, the query errors:

  SELECT g, stddev(DISTINCT x), avg(y) FROM t GROUP BY g
  Error: This feature is not implemented: STDDEV_POP(DISTINCT) aggregations
  are not available

`var_samp` and `var_pop` never needed the rewrite: `DistinctVarianceAccumulator`
deduplicates the input whenever `is_distinct` is set.

Reword those comments, and the `DistinctHandling::Honored` doc, which listed
`var_samp` among the planner-deduplicated functions and presented the rewrite
as unconditional. Comments only; no behaviour change.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01679fptc2vZkRV9hP4Eu5XB
…Handling non_exhaustive

`grouping` was tagged `Unsupported` on the grounds that its accumulator
silently returns the non-distinct answer. It does neither: the accumulator
is never built, because `ResolveGroupingFunction` replaces the call with a
value derived from the grouping id, and that value depends only on which
grouping set a row belongs to. `grouping(DISTINCT x)` already returns the
same result as `grouping(x)`, so enforcing `Unsupported` later would have
rejected a working query. Tag it `Ignored`.

The UDAF guide said to return `Unsupported` whenever the accumulator does not
implement deduplication, which would cover `stddev` and `approx_median`, both
left at `Honored` because `SingleDistinctToGroupBy` deduplicates for them when
it applies. State the full condition, matching the enum doc, and say where
those functions belong.

`DistinctHandling` is public and nothing outside the defining crate matches
on it exhaustively, so mark it `#[non_exhaustive]` now, before a release makes
adding a variant a breaking change.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01679fptc2vZkRV9hP4Eu5XB
@github-actions github-actions Bot added documentation Improvements or additions to documentation logical-expr Logical plan and expressions optimizer Optimizer rules core Core DataFusion crate sqllogictest SQL Logic Tests (.slt) functions Changes to functions implementation labels Sep 14, 2026
@mkleen mkleen changed the title Eliminate aggregate distinct feat: DISTINCT handling for Aggredate UDFs Sep 14, 2026
@codecov-commenter

codecov-commenter commented Sep 14, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 68.46154% with 82 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.91%. Comparing base (7b00b63) to head (67c323f).
⚠️ Report is 13 commits behind head on main.

Files with missing lines Patch % Lines
...sion/optimizer/src/eliminate_aggregate_distinct.rs 76.64% 9 Missing and 37 partials ⚠️
datafusion/functions-aggregate/src/covariance.rs 0.00% 6 Missing ⚠️
datafusion/functions-aggregate/src/stddev.rs 0.00% 6 Missing ⚠️
datafusion/expr/src/udaf.rs 66.66% 3 Missing ⚠️
...afusion/functions-aggregate/src/approx_distinct.rs 0.00% 3 Missing ⚠️
.../functions-aggregate/src/approx_percentile_cont.rs 0.00% 3 Missing ⚠️
...ggregate/src/approx_percentile_cont_with_weight.rs 0.00% 3 Missing ⚠️
datafusion/functions-aggregate/src/correlation.rs 0.00% 3 Missing ⚠️
datafusion/functions-aggregate/src/grouping.rs 0.00% 3 Missing ⚠️
datafusion/functions-aggregate/src/nth_value.rs 0.00% 3 Missing ⚠️
... and 1 more
Additional details and impacted files
@@           Coverage Diff            @@
##             main   #25288    +/-   ##
========================================
  Coverage   81.91%   81.91%            
========================================
  Files        1134     1135     +1     
  Lines      425637   426260   +623     
  Branches   425637   426260   +623     
========================================
+ Hits       348654   349174   +520     
- Misses      56302    56349    +47     
- Partials    20681    20737    +56     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mkleen
mkleen marked this pull request as ready for review September 14, 2026 09:04
@mkleen mkleen changed the title feat: DISTINCT handling for Aggredate UDFs feat: DISTINCT handling for Aggregate UDFs Sep 14, 2026
@mkleen

mkleen commented Sep 14, 2026

Copy link
Copy Markdown
Contributor Author

run benchmarks

@adriangbot

Copy link
Copy Markdown

🤖 Benchmark running (GKE) | trigger
Instance: c4a-highmem-16 (12 vCPU / 65 GiB) | Linux bench-c5663336603-2345-6cddn 6.12.94+ #1 SMP Tue Aug 4 08:44:15 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 eliminate-aggregate-distinct (ad518d5) to 7b00b63 (merge-base) diff

Run configuration
run benchmark clickbench_partitioned

Results will be posted here when complete


File an issue against this benchmark runner

@adriangbot

Copy link
Copy Markdown

🤖 Benchmark running (GKE) | trigger
Instance: c4a-highmem-16 (12 vCPU / 65 GiB) | Linux bench-c5663336603-2346-j54qn 6.12.94+ #1 SMP Tue Aug 4 08:44:15 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 eliminate-aggregate-distinct (ad518d5) to 7b00b63 (merge-base) diff

Run configuration
run benchmark tpcds

Results will be posted here when complete


File an issue against this benchmark runner

@adriangbot

Copy link
Copy Markdown

🤖 Benchmark running (GKE) | trigger
Instance: c4a-highmem-16 (12 vCPU / 65 GiB) | Linux bench-c5663336603-2347-79cbq 6.12.94+ #1 SMP Tue Aug 4 08:44:15 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 eliminate-aggregate-distinct (ad518d5) to 7b00b63 (merge-base) diff

Run configuration
run benchmark tpch

Results will be posted here when complete


File an issue against this benchmark runner

@adriangbot

Copy link
Copy Markdown

🤖 Benchmark completed (GKE) | trigger

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

Comparing eliminate-aggregate-distinct (ad518d5) to 7b00b63 (merge-base) diff

Run configuration
run benchmark tpch
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

Comparing HEAD and eliminate-aggregate-distinct
--------------------
Benchmark tpch_sf1.json
--------------------
┏━━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━┓
┃ Query     ┃     HEAD ┃ eliminate-aggregate-distinct ┃    Change ┃
┡━━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━┩
│ QQuery 1  │ 39.22 ms │                     38.04 ms │ no change │
│ QQuery 2  │ 19.10 ms │                     18.54 ms │ no change │
│ QQuery 3  │ 28.16 ms │                     28.04 ms │ no change │
│ QQuery 4  │ 17.27 ms │                     16.96 ms │ no change │
│ QQuery 5  │ 35.46 ms │                     34.83 ms │ no change │
│ QQuery 6  │ 16.07 ms │                     15.73 ms │ no change │
│ QQuery 7  │ 41.17 ms │                     39.95 ms │ no change │
│ QQuery 8  │ 40.68 ms │                     40.48 ms │ no change │
│ QQuery 9  │ 49.35 ms │                     48.72 ms │ no change │
│ QQuery 10 │ 42.58 ms │                     41.66 ms │ no change │
│ QQuery 11 │ 13.21 ms │                     13.05 ms │ no change │
│ QQuery 12 │ 23.95 ms │                     23.51 ms │ no change │
│ QQuery 13 │ 38.85 ms │                     38.71 ms │ no change │
│ QQuery 14 │ 24.39 ms │                     24.15 ms │ no change │
│ QQuery 15 │ 30.85 ms │                     30.29 ms │ no change │
│ QQuery 16 │ 13.79 ms │                     13.56 ms │ no change │
│ QQuery 17 │ 70.07 ms │                     69.82 ms │ no change │
│ QQuery 18 │ 59.05 ms │                     59.22 ms │ no change │
│ QQuery 19 │ 33.16 ms │                     32.60 ms │ no change │
│ QQuery 20 │ 31.90 ms │                     31.29 ms │ no change │
│ QQuery 21 │ 53.95 ms │                     54.31 ms │ no change │
│ QQuery 22 │ 13.44 ms │                     13.35 ms │ no change │
└───────────┴──────────┴──────────────────────────────┴───────────┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━┓
┃ Benchmark Summary                           ┃          ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━┩
│ Total Time (HEAD)                           │ 735.67ms │
│ Total Time (eliminate-aggregate-distinct)   │ 726.80ms │
│ Average Time (HEAD)                         │  33.44ms │
│ Average Time (eliminate-aggregate-distinct) │  33.04ms │
│ Queries Faster                              │        0 │
│ Queries Slower                              │        0 │
│ Queries with No Change                      │       22 │
│ Queries with Failure                        │        0 │
└─────────────────────────────────────────────┴──────────┘

Distribution per query (min / mean ±stddev / max):

Comparing HEAD and eliminate-aggregate-distinct
--------------------
Benchmark tpch_sf1.json
--------------------
┏━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━┓
┃ Query     ┃                           HEAD ┃   eliminate-aggregate-distinct ┃    Change ┃
┡━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━┩
│ QQuery 1  │ 39.22 / 40.53 ±1.47 / 42.74 ms │ 38.04 / 38.68 ±1.06 / 40.79 ms │ no change │
│ QQuery 2  │ 19.10 / 19.24 ±0.16 / 19.53 ms │ 18.54 / 19.27 ±1.03 / 21.25 ms │ no change │
│ QQuery 3  │ 28.16 / 29.28 ±1.19 / 31.55 ms │ 28.04 / 28.20 ±0.16 / 28.46 ms │ no change │
│ QQuery 4  │ 17.27 / 17.58 ±0.36 / 18.25 ms │ 16.96 / 17.07 ±0.12 / 17.29 ms │ no change │
│ QQuery 5  │ 35.46 / 35.88 ±0.56 / 36.93 ms │ 34.83 / 35.14 ±0.24 / 35.55 ms │ no change │
│ QQuery 6  │ 16.07 / 16.67 ±0.93 / 18.50 ms │ 15.73 / 16.32 ±0.89 / 18.09 ms │ no change │
│ QQuery 7  │ 41.17 / 42.26 ±0.62 / 42.87 ms │ 39.95 / 41.19 ±0.77 / 42.29 ms │ no change │
│ QQuery 8  │ 40.68 / 41.61 ±0.91 / 43.25 ms │ 40.48 / 42.23 ±1.40 / 43.67 ms │ no change │
│ QQuery 9  │ 49.35 / 51.45 ±1.40 / 53.04 ms │ 48.72 / 50.85 ±1.86 / 54.15 ms │ no change │
│ QQuery 10 │ 42.58 / 43.37 ±0.84 / 44.68 ms │ 41.66 / 41.86 ±0.17 / 42.12 ms │ no change │
│ QQuery 11 │ 13.21 / 13.36 ±0.14 / 13.61 ms │ 13.05 / 13.24 ±0.22 / 13.66 ms │ no change │
│ QQuery 12 │ 23.95 / 24.98 ±0.83 / 26.32 ms │ 23.51 / 24.24 ±0.69 / 25.47 ms │ no change │
│ QQuery 13 │ 38.85 / 40.06 ±1.25 / 42.17 ms │ 38.71 / 40.54 ±1.24 / 42.22 ms │ no change │
│ QQuery 14 │ 24.39 / 24.65 ±0.31 / 25.24 ms │ 24.15 / 24.43 ±0.37 / 25.14 ms │ no change │
│ QQuery 15 │ 30.85 / 31.52 ±1.30 / 34.13 ms │ 30.29 / 30.77 ±0.63 / 32.00 ms │ no change │
│ QQuery 16 │ 13.79 / 13.99 ±0.21 / 14.37 ms │ 13.56 / 13.78 ±0.14 / 14.00 ms │ no change │
│ QQuery 17 │ 70.07 / 71.08 ±0.52 / 71.52 ms │ 69.82 / 70.75 ±1.02 / 72.64 ms │ no change │
│ QQuery 18 │ 59.05 / 60.48 ±0.97 / 61.67 ms │ 59.22 / 60.94 ±1.50 / 62.83 ms │ no change │
│ QQuery 19 │ 33.16 / 33.45 ±0.51 / 34.46 ms │ 32.60 / 33.07 ±0.54 / 34.03 ms │ no change │
│ QQuery 20 │ 31.90 / 32.01 ±0.10 / 32.16 ms │ 31.29 / 31.66 ±0.31 / 32.00 ms │ no change │
│ QQuery 21 │ 53.95 / 56.08 ±1.92 / 59.23 ms │ 54.31 / 54.93 ±0.51 / 55.82 ms │ no change │
│ QQuery 22 │ 13.44 / 13.52 ±0.06 / 13.58 ms │ 13.35 / 14.12 ±1.16 / 16.42 ms │ no change │
└───────────┴────────────────────────────────┴────────────────────────────────┴───────────┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━┓
┃ Benchmark Summary                           ┃          ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━┩
│ Total Time (HEAD)                           │ 753.04ms │
│ Total Time (eliminate-aggregate-distinct)   │ 743.26ms │
│ Average Time (HEAD)                         │  34.23ms │
│ Average Time (eliminate-aggregate-distinct) │  33.78ms │
│ Queries Faster                              │        0 │
│ Queries Slower                              │        0 │
│ Queries with No Change                      │       22 │
│ Queries with Failure                        │        0 │
└─────────────────────────────────────────────┴──────────┘

Resource Usage

tpch — base (merge-base)

Metric Value
Wall time 5.0s
Peak memory 1.2 GiB
Avg memory 506.1 MiB
CPU user 21.0s
CPU sys 1.8s
Peak spill 0 B

tpch — branch

Metric Value
Wall time 5.0s
Peak memory 1.2 GiB
Avg memory 500.4 MiB
CPU user 20.6s
CPU sys 1.7s
Peak spill 0 B

File an issue against this benchmark runner

@adriangbot

Copy link
Copy Markdown

🤖 Benchmark completed (GKE) | trigger

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

Comparing eliminate-aggregate-distinct (ad518d5) to 7b00b63 (merge-base) diff

Run configuration
run benchmark tpcds
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

Comparing HEAD and eliminate-aggregate-distinct
--------------------
Benchmark tpcds_sf1.json
--------------------
┏━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━┓
┃ Query     ┃       HEAD ┃ eliminate-aggregate-distinct ┃        Change ┃
┡━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━┩
│ QQuery 1  │    5.60 ms │                      5.51 ms │     no change │
│ QQuery 2  │   80.96 ms │                     80.12 ms │     no change │
│ QQuery 3  │   28.83 ms │                     28.96 ms │     no change │
│ QQuery 4  │  474.20 ms │                    474.62 ms │     no change │
│ QQuery 5  │   52.26 ms │                     51.33 ms │     no change │
│ QQuery 6  │   35.43 ms │                     35.87 ms │     no change │
│ QQuery 7  │   75.23 ms │                     73.95 ms │     no change │
│ QQuery 8  │   36.23 ms │                     36.16 ms │     no change │
│ QQuery 9  │   52.74 ms │                     51.46 ms │     no change │
│ QQuery 10 │   62.13 ms │                     61.31 ms │     no change │
│ QQuery 11 │  295.83 ms │                    297.60 ms │     no change │
│ QQuery 12 │   28.71 ms │                     28.38 ms │     no change │
│ QQuery 13 │  117.99 ms │                    117.34 ms │     no change │
│ QQuery 14 │  420.50 ms │                    415.11 ms │     no change │
│ QQuery 15 │   56.16 ms │                     54.69 ms │     no change │
│ QQuery 16 │    6.71 ms │                      6.60 ms │     no change │
│ QQuery 17 │   79.93 ms │                     79.56 ms │     no change │
│ QQuery 18 │  102.67 ms │                    102.61 ms │     no change │
│ QQuery 19 │   41.00 ms │                     40.90 ms │     no change │
│ QQuery 20 │   35.31 ms │                     36.01 ms │     no change │
│ QQuery 21 │   17.16 ms │                     17.33 ms │     no change │
│ QQuery 22 │   62.86 ms │                     63.02 ms │     no change │
│ QQuery 23 │  312.00 ms │                    312.28 ms │     no change │
│ QQuery 24 │  198.99 ms │                    194.08 ms │     no change │
│ QQuery 25 │  111.85 ms │                    109.45 ms │     no change │
│ QQuery 26 │   49.63 ms │                     49.20 ms │     no change │
│ QQuery 27 │    6.21 ms │                      6.10 ms │     no change │
│ QQuery 28 │   60.13 ms │                     56.09 ms │ +1.07x faster │
│ QQuery 29 │   98.10 ms │                     96.76 ms │     no change │
│ QQuery 30 │   32.26 ms │                     32.24 ms │     no change │
│ QQuery 31 │  109.65 ms │                    111.13 ms │     no change │
│ QQuery 32 │   20.20 ms │                     20.03 ms │     no change │
│ QQuery 33 │   37.64 ms │                     37.51 ms │     no change │
│ QQuery 34 │    9.93 ms │                      9.87 ms │     no change │
│ QQuery 35 │   72.63 ms │                     71.86 ms │     no change │
│ QQuery 36 │    5.79 ms │                      5.79 ms │     no change │
│ QQuery 37 │    6.79 ms │                      6.72 ms │     no change │
│ QQuery 38 │   61.92 ms │                     62.10 ms │     no change │
│ QQuery 39 │   88.80 ms │                     89.83 ms │     no change │
│ QQuery 40 │   23.60 ms │                     23.37 ms │     no change │
│ QQuery 41 │   11.31 ms │                     11.28 ms │     no change │
│ QQuery 42 │   24.00 ms │                     23.70 ms │     no change │
│ QQuery 43 │    5.14 ms │                      5.17 ms │     no change │
│ QQuery 44 │    9.41 ms │                      9.30 ms │     no change │
│ QQuery 45 │   38.04 ms │                     38.40 ms │     no change │
│ QQuery 46 │   11.84 ms │                     11.86 ms │     no change │
│ QQuery 47 │  225.91 ms │                    228.24 ms │     no change │
│ QQuery 48 │   95.31 ms │                     95.53 ms │     no change │
│ QQuery 49 │   70.75 ms │                     71.75 ms │     no change │
│ QQuery 50 │   58.53 ms │                     59.39 ms │     no change │
│ QQuery 51 │   90.93 ms │                     90.87 ms │     no change │
│ QQuery 52 │   23.82 ms │                     23.25 ms │     no change │
│ QQuery 53 │   28.69 ms │                     28.90 ms │     no change │
│ QQuery 54 │   53.96 ms │                     53.97 ms │     no change │
│ QQuery 55 │   23.04 ms │                     23.08 ms │     no change │
│ QQuery 56 │   38.72 ms │                     38.41 ms │     no change │
│ QQuery 57 │  175.63 ms │                    175.60 ms │     no change │
│ QQuery 58 │  112.84 ms │                    111.69 ms │     no change │
│ QQuery 59 │  117.68 ms │                    117.86 ms │     no change │
│ QQuery 60 │   39.76 ms │                     39.50 ms │     no change │
│ QQuery 61 │   12.43 ms │                     12.24 ms │     no change │
│ QQuery 62 │   46.33 ms │                     46.78 ms │     no change │
│ QQuery 63 │   29.68 ms │                     29.41 ms │     no change │
│ QQuery 64 │  363.62 ms │                    365.38 ms │     no change │
│ QQuery 65 │  121.31 ms │                    123.03 ms │     no change │
│ QQuery 66 │   80.11 ms │                     79.54 ms │     no change │
│ QQuery 67 │  241.68 ms │                    239.37 ms │     no change │
│ QQuery 68 │   11.77 ms │                     11.83 ms │     no change │
│ QQuery 69 │   56.26 ms │                     55.16 ms │     no change │
│ QQuery 70 │  103.61 ms │                    104.12 ms │     no change │
│ QQuery 71 │   35.26 ms │                     34.95 ms │     no change │
│ QQuery 72 │ 1782.68 ms │                   1845.85 ms │     no change │
│ QQuery 73 │    9.70 ms │                      9.54 ms │     no change │
│ QQuery 74 │  167.68 ms │                    168.45 ms │     no change │
│ QQuery 75 │  147.24 ms │                    144.51 ms │     no change │
│ QQuery 76 │   35.01 ms │                     34.73 ms │     no change │
│ QQuery 77 │   61.71 ms │                     60.20 ms │     no change │
│ QQuery 78 │  219.20 ms │                    223.33 ms │     no change │
│ QQuery 79 │   66.58 ms │                     66.24 ms │     no change │
│ QQuery 80 │   97.86 ms │                     98.82 ms │     no change │
│ QQuery 81 │   25.71 ms │                     25.53 ms │     no change │
│ QQuery 82 │   16.51 ms │                     15.83 ms │     no change │
│ QQuery 83 │   33.63 ms │                     33.46 ms │     no change │
│ QQuery 84 │   29.07 ms │                     29.09 ms │     no change │
│ QQuery 85 │  102.87 ms │                    101.78 ms │     no change │
│ QQuery 86 │   25.18 ms │                     24.77 ms │     no change │
│ QQuery 87 │   61.56 ms │                     60.73 ms │     no change │
│ QQuery 88 │   63.26 ms │                     62.64 ms │     no change │
│ QQuery 89 │   35.61 ms │                     35.31 ms │     no change │
│ QQuery 90 │   16.93 ms │                     16.76 ms │     no change │
│ QQuery 91 │   45.16 ms │                     44.44 ms │     no change │
│ QQuery 92 │   28.86 ms │                     28.94 ms │     no change │
│ QQuery 93 │   50.09 ms │                     49.34 ms │     no change │
│ QQuery 94 │   37.72 ms │                     37.23 ms │     no change │
│ QQuery 95 │   80.05 ms │                     80.58 ms │     no change │
│ QQuery 96 │   23.75 ms │                     23.56 ms │     no change │
│ QQuery 97 │   51.30 ms │                     51.28 ms │     no change │
│ QQuery 98 │   42.53 ms │                     42.48 ms │     no change │
│ QQuery 99 │   69.91 ms │                     69.94 ms │     no change │
└───────────┴────────────┴──────────────────────────────┴───────────────┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━┓
┃ Benchmark Summary                           ┃           ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━┩
│ Total Time (HEAD)                           │ 9259.31ms │
│ Total Time (eliminate-aggregate-distinct)   │ 9297.84ms │
│ Average Time (HEAD)                         │   93.53ms │
│ Average Time (eliminate-aggregate-distinct) │   93.92ms │
│ Queries Faster                              │         1 │
│ Queries Slower                              │         0 │
│ Queries with No Change                      │        98 │
│ Queries with Failure                        │         0 │
└─────────────────────────────────────────────┴───────────┘

Distribution per query (min / mean ±stddev / max):

Comparing HEAD and eliminate-aggregate-distinct
--------------------
Benchmark tpcds_sf1.json
--------------------
┏━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━┓
┃ Query     ┃                                  HEAD ┃          eliminate-aggregate-distinct ┃        Change ┃
┡━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━┩
│ QQuery 1  │           5.60 / 6.18 ±1.01 / 8.21 ms │           5.51 / 6.06 ±1.00 / 8.05 ms │     no change │
│ QQuery 2  │        80.96 / 81.27 ±0.28 / 81.74 ms │        80.12 / 80.60 ±0.40 / 81.19 ms │     no change │
│ QQuery 3  │        28.83 / 29.11 ±0.31 / 29.63 ms │        28.96 / 29.10 ±0.17 / 29.42 ms │     no change │
│ QQuery 4  │     474.20 / 478.57 ±2.98 / 483.28 ms │     474.62 / 477.53 ±2.11 / 480.71 ms │     no change │
│ QQuery 5  │        52.26 / 52.54 ±0.16 / 52.73 ms │        51.33 / 53.76 ±2.81 / 59.19 ms │     no change │
│ QQuery 6  │        35.43 / 36.28 ±0.55 / 37.12 ms │        35.87 / 36.03 ±0.19 / 36.40 ms │     no change │
│ QQuery 7  │        75.23 / 75.64 ±0.33 / 76.16 ms │        73.95 / 74.50 ±0.38 / 74.96 ms │     no change │
│ QQuery 8  │        36.23 / 36.49 ±0.30 / 37.07 ms │        36.16 / 36.41 ±0.18 / 36.73 ms │     no change │
│ QQuery 9  │        52.74 / 54.18 ±1.15 / 55.99 ms │        51.46 / 52.57 ±0.88 / 53.79 ms │     no change │
│ QQuery 10 │        62.13 / 62.57 ±0.24 / 62.77 ms │        61.31 / 61.60 ±0.29 / 61.99 ms │     no change │
│ QQuery 11 │     295.83 / 298.33 ±2.17 / 302.14 ms │     297.60 / 302.48 ±3.62 / 306.84 ms │     no change │
│ QQuery 12 │        28.71 / 29.11 ±0.36 / 29.65 ms │        28.38 / 28.80 ±0.46 / 29.66 ms │     no change │
│ QQuery 13 │     117.99 / 118.47 ±0.39 / 118.98 ms │     117.34 / 117.69 ±0.28 / 118.02 ms │     no change │
│ QQuery 14 │     420.50 / 424.56 ±3.64 / 430.05 ms │     415.11 / 421.15 ±5.44 / 427.71 ms │     no change │
│ QQuery 15 │        56.16 / 58.56 ±3.10 / 64.60 ms │        54.69 / 57.19 ±3.19 / 63.46 ms │     no change │
│ QQuery 16 │           6.71 / 6.83 ±0.18 / 7.19 ms │           6.60 / 6.73 ±0.19 / 7.10 ms │     no change │
│ QQuery 17 │        79.93 / 80.83 ±0.99 / 82.60 ms │        79.56 / 81.08 ±1.36 / 83.17 ms │     no change │
│ QQuery 18 │     102.67 / 104.76 ±1.97 / 108.03 ms │     102.61 / 103.95 ±1.14 / 105.68 ms │     no change │
│ QQuery 19 │        41.00 / 41.55 ±0.41 / 41.98 ms │        40.90 / 41.42 ±0.41 / 42.00 ms │     no change │
│ QQuery 20 │        35.31 / 36.06 ±0.53 / 36.56 ms │        36.01 / 36.20 ±0.16 / 36.49 ms │     no change │
│ QQuery 21 │        17.16 / 17.29 ±0.13 / 17.51 ms │        17.33 / 17.52 ±0.14 / 17.71 ms │     no change │
│ QQuery 22 │        62.86 / 63.45 ±0.50 / 64.00 ms │        63.02 / 64.34 ±0.78 / 65.10 ms │     no change │
│ QQuery 23 │     312.00 / 314.72 ±2.09 / 318.06 ms │     312.28 / 315.99 ±2.97 / 320.60 ms │     no change │
│ QQuery 24 │     198.99 / 203.23 ±2.65 / 205.63 ms │     194.08 / 199.58 ±3.86 / 205.98 ms │     no change │
│ QQuery 25 │     111.85 / 112.97 ±1.71 / 116.31 ms │     109.45 / 112.92 ±3.32 / 118.99 ms │     no change │
│ QQuery 26 │        49.63 / 49.83 ±0.21 / 50.23 ms │        49.20 / 50.51 ±2.07 / 54.61 ms │     no change │
│ QQuery 27 │           6.21 / 6.42 ±0.24 / 6.89 ms │           6.10 / 6.25 ±0.19 / 6.61 ms │     no change │
│ QQuery 28 │        60.13 / 61.32 ±0.71 / 62.06 ms │        56.09 / 61.38 ±3.32 / 66.52 ms │     no change │
│ QQuery 29 │      98.10 / 100.09 ±2.65 / 105.25 ms │       96.76 / 98.72 ±1.39 / 100.39 ms │     no change │
│ QQuery 30 │        32.26 / 32.48 ±0.17 / 32.75 ms │        32.24 / 32.52 ±0.24 / 32.95 ms │     no change │
│ QQuery 31 │     109.65 / 112.06 ±2.65 / 116.88 ms │     111.13 / 113.17 ±1.76 / 115.55 ms │     no change │
│ QQuery 32 │        20.20 / 20.83 ±0.45 / 21.51 ms │        20.03 / 20.33 ±0.23 / 20.70 ms │     no change │
│ QQuery 33 │        37.64 / 38.39 ±0.54 / 39.30 ms │        37.51 / 38.37 ±0.65 / 39.20 ms │     no change │
│ QQuery 34 │         9.93 / 10.31 ±0.44 / 11.15 ms │         9.87 / 10.26 ±0.43 / 11.08 ms │     no change │
│ QQuery 35 │        72.63 / 73.23 ±0.46 / 73.71 ms │        71.86 / 72.15 ±0.27 / 72.60 ms │     no change │
│ QQuery 36 │           5.79 / 5.91 ±0.17 / 6.25 ms │           5.79 / 5.89 ±0.14 / 6.15 ms │     no change │
│ QQuery 37 │           6.79 / 6.88 ±0.10 / 7.06 ms │           6.72 / 6.87 ±0.09 / 6.99 ms │     no change │
│ QQuery 38 │        61.92 / 63.13 ±0.78 / 64.28 ms │        62.10 / 62.98 ±0.67 / 64.03 ms │     no change │
│ QQuery 39 │        88.80 / 91.10 ±2.06 / 94.43 ms │        89.83 / 90.59 ±0.69 / 91.80 ms │     no change │
│ QQuery 40 │        23.60 / 23.94 ±0.24 / 24.31 ms │        23.37 / 23.83 ±0.35 / 24.23 ms │     no change │
│ QQuery 41 │        11.31 / 11.41 ±0.09 / 11.52 ms │        11.28 / 11.46 ±0.18 / 11.77 ms │     no change │
│ QQuery 42 │        24.00 / 24.96 ±1.15 / 27.19 ms │        23.70 / 24.20 ±0.46 / 24.94 ms │     no change │
│ QQuery 43 │           5.14 / 5.26 ±0.15 / 5.54 ms │           5.17 / 5.30 ±0.20 / 5.68 ms │     no change │
│ QQuery 44 │           9.41 / 9.48 ±0.06 / 9.57 ms │           9.30 / 9.47 ±0.15 / 9.73 ms │     no change │
│ QQuery 45 │        38.04 / 38.69 ±0.51 / 39.60 ms │        38.40 / 39.51 ±0.59 / 40.13 ms │     no change │
│ QQuery 46 │        11.84 / 12.99 ±1.67 / 16.30 ms │        11.86 / 12.18 ±0.28 / 12.52 ms │ +1.07x faster │
│ QQuery 47 │     225.91 / 227.57 ±1.92 / 231.18 ms │     228.24 / 231.29 ±3.17 / 236.55 ms │     no change │
│ QQuery 48 │        95.31 / 95.79 ±0.27 / 96.15 ms │        95.53 / 96.52 ±0.54 / 96.99 ms │     no change │
│ QQuery 49 │        70.75 / 71.47 ±0.42 / 71.84 ms │        71.75 / 72.05 ±0.16 / 72.22 ms │     no change │
│ QQuery 50 │        58.53 / 59.57 ±1.12 / 61.71 ms │        59.39 / 60.65 ±1.38 / 63.24 ms │     no change │
│ QQuery 51 │        90.93 / 93.18 ±2.37 / 96.45 ms │        90.87 / 93.34 ±1.30 / 94.40 ms │     no change │
│ QQuery 52 │        23.82 / 24.10 ±0.26 / 24.56 ms │        23.25 / 23.97 ±0.37 / 24.23 ms │     no change │
│ QQuery 53 │        28.69 / 29.15 ±0.24 / 29.38 ms │        28.90 / 29.79 ±1.54 / 32.87 ms │     no change │
│ QQuery 54 │        53.96 / 54.68 ±0.59 / 55.70 ms │        53.97 / 54.52 ±0.48 / 55.14 ms │     no change │
│ QQuery 55 │        23.04 / 23.19 ±0.17 / 23.51 ms │        23.08 / 23.15 ±0.06 / 23.25 ms │     no change │
│ QQuery 56 │        38.72 / 39.32 ±0.38 / 39.78 ms │        38.41 / 38.61 ±0.16 / 38.83 ms │     no change │
│ QQuery 57 │     175.63 / 178.06 ±2.39 / 182.53 ms │     175.60 / 178.02 ±3.05 / 183.40 ms │     no change │
│ QQuery 58 │     112.84 / 114.13 ±1.12 / 116.01 ms │     111.69 / 114.15 ±1.86 / 116.05 ms │     no change │
│ QQuery 59 │     117.68 / 118.13 ±0.34 / 118.70 ms │     117.86 / 119.10 ±1.89 / 122.79 ms │     no change │
│ QQuery 60 │        39.76 / 40.06 ±0.25 / 40.46 ms │        39.50 / 40.53 ±1.18 / 42.49 ms │     no change │
│ QQuery 61 │        12.43 / 12.55 ±0.16 / 12.86 ms │        12.24 / 12.32 ±0.11 / 12.52 ms │     no change │
│ QQuery 62 │        46.33 / 47.35 ±1.31 / 49.93 ms │        46.78 / 47.85 ±1.70 / 51.22 ms │     no change │
│ QQuery 63 │        29.68 / 29.96 ±0.30 / 30.53 ms │        29.41 / 29.78 ±0.27 / 30.25 ms │     no change │
│ QQuery 64 │     363.62 / 369.60 ±4.82 / 377.97 ms │     365.38 / 370.80 ±4.42 / 376.63 ms │     no change │
│ QQuery 65 │     121.31 / 123.39 ±1.91 / 126.29 ms │     123.03 / 125.10 ±1.71 / 128.22 ms │     no change │
│ QQuery 66 │        80.11 / 82.84 ±3.26 / 88.97 ms │        79.54 / 81.66 ±3.14 / 87.88 ms │     no change │
│ QQuery 67 │     241.68 / 246.85 ±3.99 / 253.10 ms │     239.37 / 248.42 ±6.99 / 259.59 ms │     no change │
│ QQuery 68 │        11.77 / 11.91 ±0.16 / 12.21 ms │        11.83 / 11.98 ±0.20 / 12.37 ms │     no change │
│ QQuery 69 │        56.26 / 58.78 ±4.33 / 67.42 ms │        55.16 / 58.85 ±6.02 / 70.86 ms │     no change │
│ QQuery 70 │     103.61 / 105.83 ±2.11 / 108.50 ms │     104.12 / 105.60 ±1.02 / 107.15 ms │     no change │
│ QQuery 71 │        35.26 / 35.41 ±0.16 / 35.68 ms │        34.95 / 35.27 ±0.28 / 35.78 ms │     no change │
│ QQuery 72 │ 1782.68 / 1887.29 ±70.91 / 2003.63 ms │ 1845.85 / 1904.35 ±48.37 / 1982.83 ms │     no change │
│ QQuery 73 │         9.70 / 10.10 ±0.37 / 10.80 ms │         9.54 / 10.17 ±0.35 / 10.50 ms │     no change │
│ QQuery 74 │     167.68 / 169.99 ±1.95 / 172.77 ms │     168.45 / 170.27 ±2.11 / 174.25 ms │     no change │
│ QQuery 75 │     147.24 / 150.52 ±4.24 / 158.38 ms │     144.51 / 147.41 ±3.31 / 153.67 ms │     no change │
│ QQuery 76 │        35.01 / 35.34 ±0.22 / 35.60 ms │        34.73 / 36.74 ±3.18 / 43.07 ms │     no change │
│ QQuery 77 │        61.71 / 65.54 ±4.00 / 71.85 ms │        60.20 / 62.70 ±3.35 / 69.33 ms │     no change │
│ QQuery 78 │     219.20 / 229.61 ±8.01 / 238.75 ms │     223.33 / 231.52 ±6.55 / 238.03 ms │     no change │
│ QQuery 79 │        66.58 / 67.17 ±0.35 / 67.54 ms │        66.24 / 66.63 ±0.36 / 67.31 ms │     no change │
│ QQuery 80 │      97.86 / 102.26 ±5.56 / 113.20 ms │      98.82 / 102.34 ±4.28 / 110.33 ms │     no change │
│ QQuery 81 │        25.71 / 26.78 ±1.79 / 30.35 ms │        25.53 / 25.82 ±0.24 / 26.26 ms │     no change │
│ QQuery 82 │        16.51 / 16.94 ±0.34 / 17.56 ms │        15.83 / 16.63 ±1.00 / 18.59 ms │     no change │
│ QQuery 83 │        33.63 / 33.98 ±0.32 / 34.48 ms │        33.46 / 33.62 ±0.12 / 33.81 ms │     no change │
│ QQuery 84 │        29.07 / 29.46 ±0.22 / 29.75 ms │        29.09 / 29.28 ±0.19 / 29.55 ms │     no change │
│ QQuery 85 │     102.87 / 105.79 ±3.54 / 112.16 ms │     101.78 / 105.92 ±3.24 / 111.42 ms │     no change │
│ QQuery 86 │        25.18 / 25.84 ±0.52 / 26.54 ms │        24.77 / 25.11 ±0.33 / 25.51 ms │     no change │
│ QQuery 87 │        61.56 / 62.26 ±0.41 / 62.69 ms │        60.73 / 61.55 ±0.68 / 62.77 ms │     no change │
│ QQuery 88 │        63.26 / 65.33 ±3.08 / 71.37 ms │        62.64 / 63.18 ±0.59 / 64.33 ms │     no change │
│ QQuery 89 │        35.61 / 36.26 ±0.52 / 37.14 ms │        35.31 / 36.51 ±1.77 / 39.98 ms │     no change │
│ QQuery 90 │        16.93 / 18.00 ±1.67 / 21.32 ms │        16.76 / 17.07 ±0.21 / 17.41 ms │ +1.05x faster │
│ QQuery 91 │        45.16 / 45.60 ±0.55 / 46.60 ms │        44.44 / 44.62 ±0.15 / 44.82 ms │     no change │
│ QQuery 92 │        28.86 / 29.66 ±0.67 / 30.49 ms │        28.94 / 29.68 ±0.69 / 30.98 ms │     no change │
│ QQuery 93 │        50.09 / 50.84 ±0.66 / 51.64 ms │        49.34 / 50.29 ±1.10 / 52.43 ms │     no change │
│ QQuery 94 │        37.72 / 39.51 ±2.00 / 43.23 ms │        37.23 / 37.87 ±0.42 / 38.37 ms │     no change │
│ QQuery 95 │        80.05 / 81.50 ±1.75 / 84.96 ms │        80.58 / 81.39 ±0.73 / 82.47 ms │     no change │
│ QQuery 96 │        23.75 / 24.03 ±0.19 / 24.32 ms │        23.56 / 23.75 ±0.23 / 24.20 ms │     no change │
│ QQuery 97 │        51.30 / 52.14 ±1.00 / 53.53 ms │        51.28 / 52.03 ±0.61 / 52.90 ms │     no change │
│ QQuery 98 │        42.53 / 43.96 ±1.37 / 46.28 ms │        42.48 / 43.23 ±0.83 / 44.83 ms │     no change │
│ QQuery 99 │        69.91 / 70.93 ±0.98 / 72.80 ms │        69.94 / 71.05 ±1.74 / 74.48 ms │     no change │
└───────────┴───────────────────────────────────────┴───────────────────────────────────────┴───────────────┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━┓
┃ Benchmark Summary                           ┃           ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━┩
│ Total Time (HEAD)                           │ 9491.75ms │
│ Total Time (eliminate-aggregate-distinct)   │ 9495.20ms │
│ Average Time (HEAD)                         │   95.88ms │
│ Average Time (eliminate-aggregate-distinct) │   95.91ms │
│ Queries Faster                              │         2 │
│ Queries Slower                              │         0 │
│ Queries with No Change                      │        97 │
│ Queries with Failure                        │         0 │
└─────────────────────────────────────────────┴───────────┘

Resource Usage

tpcds — base (merge-base)

Metric Value
Wall time 50.0s
Peak memory 1.8 GiB
Avg memory 1.3 GiB
CPU user 204.0s
CPU sys 5.7s
Peak spill 0 B

tpcds — branch

Metric Value
Wall time 50.0s
Peak memory 1.8 GiB
Avg memory 1.2 GiB
CPU user 206.8s
CPU sys 5.8s
Peak spill 0 B

File an issue against this benchmark runner

@adriangbot

Copy link
Copy Markdown

🤖 Benchmark completed (GKE) | trigger

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

Comparing eliminate-aggregate-distinct (ad518d5) to 7b00b63 (merge-base) diff

Run configuration
run benchmark clickbench_partitioned
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

Comparing HEAD and eliminate-aggregate-distinct
--------------------
Benchmark clickbench_partitioned.json
--------------------
┏━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━┓
┃ Query     ┃       HEAD ┃ eliminate-aggregate-distinct ┃        Change ┃
┡━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━┩
│ QQuery 0  │    1.23 ms │                      1.22 ms │     no change │
│ QQuery 1  │   11.82 ms │                     12.10 ms │     no change │
│ QQuery 2  │   36.34 ms │                     36.29 ms │     no change │
│ QQuery 3  │   31.02 ms │                     30.88 ms │     no change │
│ QQuery 4  │  223.45 ms │                    222.17 ms │     no change │
│ QQuery 5  │  276.07 ms │                    272.84 ms │     no change │
│ QQuery 6  │    1.28 ms │                      1.27 ms │     no change │
│ QQuery 7  │   13.09 ms │                     12.95 ms │     no change │
│ QQuery 8  │  327.11 ms │                    325.34 ms │     no change │
│ QQuery 9  │  459.20 ms │                    461.45 ms │     no change │
│ QQuery 10 │   70.67 ms │                     69.54 ms │     no change │
│ QQuery 11 │   82.08 ms │                     80.51 ms │     no change │
│ QQuery 12 │  269.71 ms │                    261.91 ms │     no change │
│ QQuery 13 │  364.43 ms │                    379.06 ms │     no change │
│ QQuery 14 │  285.45 ms │                    282.50 ms │     no change │
│ QQuery 15 │  270.84 ms │                    272.69 ms │     no change │
│ QQuery 16 │  613.92 ms │                    608.73 ms │     no change │
│ QQuery 17 │  617.80 ms │                    618.41 ms │     no change │
│ QQuery 18 │ 1267.31 ms │                   1260.89 ms │     no change │
│ QQuery 19 │   27.31 ms │                     27.39 ms │     no change │
│ QQuery 20 │  514.14 ms │                    514.92 ms │     no change │
│ QQuery 21 │  515.72 ms │                    514.33 ms │     no change │
│ QQuery 22 │  979.41 ms │                    984.65 ms │     no change │
│ QQuery 23 │ 3035.49 ms │                   3013.65 ms │     no change │
│ QQuery 24 │   41.20 ms │                     41.13 ms │     no change │
│ QQuery 25 │  110.40 ms │                    109.19 ms │     no change │
│ QQuery 26 │   41.51 ms │                     41.21 ms │     no change │
│ QQuery 27 │  518.24 ms │                    509.81 ms │     no change │
│ QQuery 28 │ 2911.53 ms │                   2923.03 ms │     no change │
│ QQuery 29 │   41.16 ms │                     41.09 ms │     no change │
│ QQuery 30 │  316.39 ms │                    311.92 ms │     no change │
│ QQuery 31 │  281.72 ms │                    278.75 ms │     no change │
│ QQuery 32 │  916.11 ms │                    932.91 ms │     no change │
│ QQuery 33 │ 1452.35 ms │                   1447.73 ms │     no change │
│ QQuery 34 │ 1464.06 ms │                   1460.55 ms │     no change │
│ QQuery 35 │  291.56 ms │                    281.59 ms │     no change │
│ QQuery 36 │   67.76 ms │                     69.18 ms │     no change │
│ QQuery 37 │   35.98 ms │                     35.42 ms │     no change │
│ QQuery 38 │   41.63 ms │                     40.45 ms │     no change │
│ QQuery 39 │  156.36 ms │                    144.69 ms │ +1.08x faster │
│ QQuery 40 │   14.68 ms │                     14.05 ms │     no change │
│ QQuery 41 │   14.31 ms │                     13.75 ms │     no change │
│ QQuery 42 │   13.91 ms │                     13.13 ms │ +1.06x faster │
└───────────┴────────────┴──────────────────────────────┴───────────────┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┓
┃ Benchmark Summary                           ┃            ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━┩
│ Total Time (HEAD)                           │ 19025.77ms │
│ Total Time (eliminate-aggregate-distinct)   │ 18975.27ms │
│ Average Time (HEAD)                         │   442.46ms │
│ Average Time (eliminate-aggregate-distinct) │   441.29ms │
│ Queries Faster                              │          2 │
│ Queries Slower                              │          0 │
│ Queries with No Change                      │         41 │
│ Queries with Failure                        │          0 │
└─────────────────────────────────────────────┴────────────┘

Distribution per query (min / mean ±stddev / max):

Comparing HEAD and eliminate-aggregate-distinct
--------------------
Benchmark clickbench_partitioned.json
--------------------
┏━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━┓
┃ Query     ┃                                  HEAD ┃          eliminate-aggregate-distinct ┃        Change ┃
┡━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━┩
│ QQuery 0  │          1.23 / 3.98 ±5.45 / 14.88 ms │          1.22 / 4.00 ±5.50 / 15.01 ms │     no change │
│ QQuery 1  │        11.82 / 12.08 ±0.20 / 12.34 ms │        12.10 / 12.24 ±0.10 / 12.41 ms │     no change │
│ QQuery 2  │        36.34 / 36.65 ±0.23 / 37.03 ms │        36.29 / 36.65 ±0.31 / 37.19 ms │     no change │
│ QQuery 3  │        31.02 / 31.65 ±0.69 / 32.98 ms │        30.88 / 31.08 ±0.12 / 31.21 ms │     no change │
│ QQuery 4  │     223.45 / 225.65 ±1.49 / 227.33 ms │     222.17 / 226.42 ±3.23 / 232.10 ms │     no change │
│ QQuery 5  │     276.07 / 277.73 ±0.95 / 278.65 ms │     272.84 / 275.80 ±2.30 / 279.74 ms │     no change │
│ QQuery 6  │           1.28 / 1.42 ±0.22 / 1.87 ms │           1.27 / 1.41 ±0.21 / 1.83 ms │     no change │
│ QQuery 7  │        13.09 / 13.28 ±0.14 / 13.49 ms │        12.95 / 13.25 ±0.18 / 13.49 ms │     no change │
│ QQuery 8  │     327.11 / 328.86 ±1.18 / 330.44 ms │     325.34 / 328.29 ±1.76 / 330.24 ms │     no change │
│ QQuery 9  │     459.20 / 466.37 ±3.71 / 469.28 ms │     461.45 / 473.56 ±6.33 / 479.08 ms │     no change │
│ QQuery 10 │        70.67 / 73.86 ±5.61 / 85.08 ms │        69.54 / 70.50 ±0.55 / 71.05 ms │     no change │
│ QQuery 11 │        82.08 / 82.45 ±0.29 / 82.76 ms │        80.51 / 81.78 ±1.06 / 83.30 ms │     no change │
│ QQuery 12 │     269.71 / 273.75 ±2.96 / 277.43 ms │     261.91 / 268.52 ±4.18 / 274.86 ms │     no change │
│ QQuery 13 │    364.43 / 375.12 ±11.42 / 397.22 ms │     379.06 / 386.66 ±7.93 / 398.73 ms │     no change │
│ QQuery 14 │     285.45 / 291.15 ±5.49 / 300.34 ms │     282.50 / 286.85 ±3.36 / 291.67 ms │     no change │
│ QQuery 15 │     270.84 / 276.71 ±3.61 / 281.38 ms │     272.69 / 278.91 ±5.86 / 288.83 ms │     no change │
│ QQuery 16 │     613.92 / 622.82 ±4.70 / 627.10 ms │    608.73 / 626.23 ±11.41 / 640.66 ms │     no change │
│ QQuery 17 │     617.80 / 631.42 ±7.39 / 639.68 ms │    618.41 / 634.96 ±10.72 / 647.82 ms │     no change │
│ QQuery 18 │ 1267.31 / 1281.31 ±15.94 / 1312.48 ms │  1260.89 / 1275.19 ±7.77 / 1283.77 ms │     no change │
│ QQuery 19 │       27.31 / 33.13 ±10.39 / 53.87 ms │       27.39 / 37.50 ±19.98 / 77.46 ms │  1.13x slower │
│ QQuery 20 │    514.14 / 527.19 ±12.55 / 546.49 ms │     514.92 / 520.45 ±5.38 / 527.24 ms │     no change │
│ QQuery 21 │     515.72 / 519.53 ±2.58 / 522.91 ms │     514.33 / 520.49 ±6.01 / 531.64 ms │     no change │
│ QQuery 22 │    979.41 / 988.12 ±9.39 / 1006.25 ms │   984.65 / 995.18 ±11.68 / 1016.90 ms │     no change │
│ QQuery 23 │ 3035.49 / 3084.96 ±33.61 / 3123.52 ms │ 3013.65 / 3058.92 ±38.18 / 3108.61 ms │     no change │
│ QQuery 24 │        41.20 / 48.95 ±5.14 / 53.67 ms │        41.13 / 47.47 ±7.68 / 59.66 ms │     no change │
│ QQuery 25 │     110.40 / 113.93 ±4.81 / 123.47 ms │     109.19 / 111.21 ±1.71 / 113.64 ms │     no change │
│ QQuery 26 │        41.51 / 45.35 ±4.77 / 53.67 ms │        41.21 / 42.54 ±1.45 / 45.30 ms │ +1.07x faster │
│ QQuery 27 │     518.24 / 519.91 ±2.34 / 524.40 ms │     509.81 / 523.19 ±6.84 / 528.80 ms │     no change │
│ QQuery 28 │  2911.53 / 2922.43 ±8.88 / 2933.30 ms │ 2923.03 / 2957.53 ±40.46 / 3015.65 ms │     no change │
│ QQuery 29 │        41.16 / 46.53 ±6.50 / 58.05 ms │       41.09 / 57.22 ±20.20 / 89.19 ms │  1.23x slower │
│ QQuery 30 │     316.39 / 319.04 ±2.72 / 323.68 ms │     311.92 / 318.43 ±4.94 / 326.60 ms │     no change │
│ QQuery 31 │     281.72 / 291.98 ±5.77 / 297.56 ms │     278.75 / 290.68 ±8.26 / 299.89 ms │     no change │
│ QQuery 32 │   916.11 / 978.83 ±50.25 / 1063.72 ms │   932.91 / 957.97 ±39.74 / 1037.23 ms │     no change │
│ QQuery 33 │ 1452.35 / 1464.08 ±11.20 / 1482.73 ms │ 1447.73 / 1470.57 ±15.14 / 1494.13 ms │     no change │
│ QQuery 34 │ 1464.06 / 1488.96 ±16.21 / 1508.45 ms │ 1460.55 / 1487.01 ±20.43 / 1509.81 ms │     no change │
│ QQuery 35 │    291.56 / 306.22 ±13.72 / 323.47 ms │    281.59 / 315.46 ±56.26 / 427.27 ms │     no change │
│ QQuery 36 │        67.76 / 69.96 ±3.95 / 77.86 ms │        69.18 / 75.66 ±6.64 / 87.18 ms │  1.08x slower │
│ QQuery 37 │        35.98 / 40.61 ±3.50 / 44.12 ms │        35.42 / 36.77 ±0.71 / 37.51 ms │ +1.10x faster │
│ QQuery 38 │        41.63 / 45.98 ±3.15 / 51.44 ms │        40.45 / 42.75 ±2.00 / 45.66 ms │ +1.08x faster │
│ QQuery 39 │     156.36 / 161.88 ±4.48 / 165.90 ms │     144.69 / 150.83 ±4.55 / 157.01 ms │ +1.07x faster │
│ QQuery 40 │        14.68 / 15.14 ±0.74 / 16.61 ms │        14.05 / 14.97 ±1.20 / 17.35 ms │     no change │
│ QQuery 41 │        14.31 / 18.39 ±7.51 / 33.39 ms │        13.75 / 16.32 ±4.70 / 25.71 ms │ +1.13x faster │
│ QQuery 42 │        13.91 / 16.48 ±4.56 / 25.59 ms │        13.13 / 14.64 ±2.57 / 19.74 ms │ +1.13x faster │
└───────────┴───────────────────────────────────────┴───────────────────────────────────────┴───────────────┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┓
┃ Benchmark Summary                           ┃            ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━┩
│ Total Time (HEAD)                           │ 19373.80ms │
│ Total Time (eliminate-aggregate-distinct)   │ 19376.08ms │
│ Average Time (HEAD)                         │   450.55ms │
│ Average Time (eliminate-aggregate-distinct) │   450.61ms │
│ Queries Faster                              │          6 │
│ Queries Slower                              │          3 │
│ Queries with No Change                      │         34 │
│ Queries with Failure                        │          0 │
└─────────────────────────────────────────────┴────────────┘

Resource Usage

clickbench_partitioned — base (merge-base)

Metric Value
Wall time 100.0s
Peak memory 10.5 GiB
Avg memory 4.2 GiB
CPU user 996.0s
CPU sys 69.2s
Peak spill 0 B

clickbench_partitioned — branch

Metric Value
Wall time 100.0s
Peak memory 11.4 GiB
Avg memory 4.5 GiB
CPU user 993.2s
CPU sys 70.3s
Peak spill 0 B

File an issue against this benchmark runner

@jayzhan211 jayzhan211 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 @mkleen , overall LGTM, suggestion on the naming

pub enum DistinctHandling {
/// The result is the same with or without `DISTINCT`, so the planner
/// is free to drop it. `min`, `max`, `bool_and`, `bit_or`, ...
Ignored,

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.

What do you think

Ignored -> Insensitive
Honored -> Sensitive

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.

Yes, this is a good idea.

@adriangb adriangb 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.

Thank you for the new PR!

One request that is not in the inline comments:

Add unit tests with custom UDAFs for the public API. No test overrides distinct_handling. The unit tests use only the built-in min, max, sum and bit_xor, and no test references DistinctHandling::Unsupported. Please add tests in datafusion/core/tests/user_defined/user_defined_aggregates.rs (or in the rule's own tests with a test UDAF) that cover: a UDAF that returns Ignored loses the flag and keeps its output name, with FILTER and ORDER BY carried over; a UDAF that returns Honored keeps the flag; a UDAF that returns Unsupported keeps the flag; an Ignored UDAF beside an Honored distinct on the same node keeps both flags; an input that is already aliased (.alias("m")) gets no second alias; and a UDAF registered through AggregateUDF::with_aliases delegates the tag. Please also add a sqllogictest case for approx_distinct(DISTINCT v). It is the largest plan change in the PR and the one Ignored tag with no test.

The inline comments cover the rest: two test cases, the doc comments in the rule, and the definitions of the DistinctHandling variants.

Follow-up tracking issues, not for this PR:

  • datafusion/spark: collect_set always uses DistinctArrayAggAccumulator, so it meets the Ignored definition, and collect_list and try_sum never read is_distinct. None of them is tagged.
  • datafusion/ffi: ForeignAggregateUDF does not forward distinct_handling, so every UDAF that crosses the FFI boundary stays Honored. Safe, but the optimization cannot reach datafusion-python users.

Comment thread datafusion/sqllogictest/test_files/aggregates_simplify.slt Outdated
Comment thread datafusion/sqllogictest/test_files/aggregates_simplify.slt
Comment thread datafusion/optimizer/src/eliminate_aggregate_distinct.rs Outdated
Comment thread datafusion/optimizer/src/eliminate_aggregate_distinct.rs Outdated
Comment thread datafusion/optimizer/src/eliminate_aggregate_distinct.rs
Comment thread datafusion/expr/src/udaf.rs Outdated
Comment thread datafusion/functions-aggregate/src/stddev.rs Outdated
Comment thread datafusion/functions-aggregate/src/stddev.rs Outdated
Comment thread datafusion/functions-aggregate/src/approx_median.rs Outdated
Comment thread docs/source/library-user-guide/functions/adding-udfs.md Outdated
@mkleen

mkleen commented Sep 14, 2026

Copy link
Copy Markdown
Contributor Author

@adriangb @jayzhan211 Thanks a lot for the review! I am on it with the follow-ups.

mkleen and others added 2 commits September 15, 2026 09:51
Co-authored-by: Adrian Garcia Badaracco <1755071+adriangb@users.noreply.github.com>
Co-authored-by: Adrian Garcia Badaracco <1755071+adriangb@users.noreply.github.com>
mkleen and others added 13 commits September 15, 2026 09:51
Co-authored-by: Adrian Garcia Badaracco <1755071+adriangb@users.noreply.github.com>
Co-authored-by: Adrian Garcia Badaracco <1755071+adriangb@users.noreply.github.com>
Co-authored-by: Adrian Garcia Badaracco <1755071+adriangb@users.noreply.github.com>
Co-authored-by: Adrian Garcia Badaracco <1755071+adriangb@users.noreply.github.com>
Co-authored-by: Adrian Garcia Badaracco <1755071+adriangb@users.noreply.github.com>
Co-authored-by: Adrian Garcia Badaracco <1755071+adriangb@users.noreply.github.com>
Co-authored-by: Adrian Garcia Badaracco <1755071+adriangb@users.noreply.github.com>
Co-authored-by: Adrian Garcia Badaracco <1755071+adriangb@users.noreply.github.com>
Co-authored-by: Adrian Garcia Badaracco <1755071+adriangb@users.noreply.github.com>
Co-authored-by: Adrian Garcia Badaracco <1755071+adriangb@users.noreply.github.com>
Co-authored-by: Adrian Garcia Badaracco <1755071+adriangb@users.noreply.github.com>
Co-authored-by: Adrian Garcia Badaracco <1755071+adriangb@users.noreply.github.com>
Co-authored-by: Adrian Garcia Badaracco <1755071+adriangb@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Core DataFusion crate documentation Improvements or additions to documentation functions Changes to functions implementation logical-expr Logical plan and expressions optimizer Optimizer rules sqllogictest SQL Logic Tests (.slt)

Projects

None yet

5 participants