Uh oh!
There was an error while loading. Please reload this page.
perf: optimize scalar aggregate joins as semi joins - #21971
Conversation
Dandandan
commented
May 1, 2026
run benchmark tpch tpch10 tpcds |
adriangbot
commented
May 1, 2026
🤖 Benchmark running (GKE) | trigger CPU Details (lscpu)Comparing scalar-subquery-semi-join (c069c6f) to d59bc72 (merge-base) diff using: tpch File an issue against this benchmark runner |
adriangbot
commented
May 1, 2026
🤖 Benchmark running (GKE) | trigger CPU Details (lscpu)Comparing scalar-subquery-semi-join (c069c6f) to d59bc72 (merge-base) diff using: tpcds File an issue against this benchmark runner |
adriangbot
commented
May 1, 2026
🤖 Benchmark running (GKE) | trigger CPU Details (lscpu)Comparing scalar-subquery-semi-join (c069c6f) to d59bc72 (merge-base) diff using: tpch10 File an issue against this benchmark runner |
adriangbot
commented
May 1, 2026
🤖 Benchmark completed (GKE) | trigger Instance: CPU Details (lscpu)DetailsResource Usagetpch — base (merge-base)
tpch — branch
File an issue against this benchmark runner |
adriangbot
commented
May 1, 2026
🤖 Benchmark completed (GKE) | trigger Instance: CPU Details (lscpu)DetailsResource Usagetpch10 — base (merge-base)
tpch10 — branch
File an issue against this benchmark runner |
c069c6f to
da59e3aCompareadriangbot
commented
May 1, 2026
🤖 Benchmark completed (GKE) | trigger Instance: CPU Details (lscpu)DetailsResource Usagetpcds — base (merge-base)
tpcds — branch
File an issue against this benchmark runner |
Dandandan
commented
May 1, 2026
run benchmark tpcds |
adriangbot
commented
May 1, 2026
🤖 Benchmark running (GKE) | trigger CPU Details (lscpu)Comparing scalar-subquery-semi-join (da59e3a) to d59bc72 (merge-base) diff using: tpcds File an issue against this benchmark runner |
adriangbot
commented
May 1, 2026
🤖 Benchmark completed (GKE) | trigger Instance: CPU Details (lscpu)DetailsResource Usagetpcds — base (merge-base)
tpcds — branch
File an issue against this benchmark runner |
Which issue does this PR close?
N/A.
Rationale for this change
TPC-H Q2, Q17, and Q20 contain correlated scalar aggregate subqueries that are decorrelated into joins. In these cases the right side is unique on the correlated join keys, and no right-side columns are projected above the join. That means the inner join is only testing existence of a matching scalar aggregate row, so a left semi join expresses the plan more directly and avoids carrying inner-join output/cardinality machinery.
PR #21240 adds physical execution for uncorrelated scalar subqueries, but these cases are correlated and still need decorrelation into a set-at-a-time join plan.
What changes are included in this PR?
EliminateJointo rewrite projected inner joins to left semi joins when the right input is provably unique on the right join keys.Are these changes tested?
Yes.
CARGO_INCREMENTAL=0 cargo test -p datafusion-optimizer eliminate_join --libCARGO_INCREMENTAL=0 INCLUDE_TPCH=true cargo test -p datafusion-sqllogictest --test sqllogictests -- tpchcargo fmt --allCARGO_INCREMENTAL=0 ci/scripts/rust_clippy.sh./dev/rust_lint.shAre there any user-facing changes?
No API changes. Eligible logical and physical plans can now show
LeftSemiinstead ofInnerfor projected joins against unique scalar aggregate subquery results.