Skip to content

Lower arrayJoin when its result is unused and drop the name-based bail-outs - #120390

Merged
yariks5s merged 5 commits into
masterfrom
yarik/lower-array-join-by-identity
Sep 17, 2026
Merged

yariks5s merged 5 commits into
masterfrom
yarik/lower-array-join-by-identity

Conversation

@yariks5s

@yariks5s yariks5s commented Sep 16, 2026 •

Copy link
Copy Markdown
Member

Related: #112241
Related: #116910
Related: #117882

Changelog category (leave one):

  • Performance Improvement

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

With query_plan_lower_array_join_function enabled, arrayJoin is now lowered even when its result is unused or when the lowered join would otherwise collide with another column name, so these queries still benefit from ARRAY JOIN lazy replication and filter fusion.


Workflow [PR]
Sync PR [sync-upstream/pr/120390]

Version info

  • Merged into: 26.10.1.20 (included in 26.10 and later)

@yariks5s
yariks5s requested a review from nihalzp September 16, 2026 13:01
@clickhouse-gh

clickhouse-gh Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [6202583]

Summary: ❌

job_name test_name status info comment
Build profile diff ERROR

AI Review

Summary

This PR extends query_plan_lower_array_join_function so it can still lower an arrayJoin when the join result is unused and when the lowered carrier would otherwise collide with another column name. I did not find a remaining correctness, test-coverage, or PR-metadata issue in the current patch; the earlier rand() mismatch has already been fixed, and the GitHub CI report for 6202583a8b16d1cf33adaf318c70434d50c1d523 is fully green.

Final Verdict

✅ No actionable findings.

LLVM Coverage Report

Measured on commit 6202583.

Metric Baseline Current Δ
Lines 88.40% 88.40% +0.00%
Functions 91.80% 91.80% +0.00%
Branches 80.60% 80.60% +0.00%

Changed lines: Changed C/C++ lines covered: 51/54 (94.44%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added the pr-performance Pull request with some performance improvements label Sep 16, 2026
@nihalzp nihalzp self-assigned this Sep 16, 2026
Comment thread src/Interpreters/ActionsDAG.cpp Resolved
@clickhouse-gh clickhouse-gh Bot added the comp-query-optimizer Query plan optimization: physical plan steps, plan-level rewrites and optimizations (QueryPlan pa... label Sep 16, 2026
@yariks5s yariks5s changed the title Lower arrayJoin next to rand() and drop name-based bail-outs Lower arrayJoin when its result is unused and drop the name-based bail-outs Sep 16, 2026
@clickhouse-gh

clickhouse-gh Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

📊 Cloud Performance Report

✅ AI verdict: no_change — no significant changes across 39 queries analysed

Release-transition baseline: compared against the most recent available 26.9 masters at or before the trusted base-commit anchor because no 26.10 master baseline exists there.

This PR only rewrites how the query optimizer lowers arrayJoin into an ARRAY JOIN step (dropping the name-shadowing and unused-result bail-outs in lowerArrayJoinFunction/ActionsDAG), which affects only queries containing arrayJoin. Neither flagged ClickBench query uses arrayJoin: Q16 is a GROUP BY UserID count and Q32 is the wide SUM(ResolutionWidth + N) aggregate, so the changed code path cannot plausibly move either one. Both were left as not_sure by the deterministic gates — Q16 falls inside master's current variance band on a query already marked noisy, and Q32's +12.9% is borderline with disagreeing tests and ~26% run-to-run spread. Read both deltas as measurement variance rather than a PR effect.

clickbench

⚠️ 2 inconclusive

Flagged queries (2 of 43)
Query Verdict Baseline median (ms) PR median (ms) Change q-value Hint
⚠️ 16 not_sure 532 600 +12.9% <0.0001 plan_change: This PR only changes arrayJoin lowering in the query optimizer, and Q16 (GROUP BY UserID) runs no arrayJoin, so this +12.9% sits within master's current variance band and reads as noise on a query flagged noisy.
⚠️ 32 not_sure 721 814 +12.9% <0.0001 plan_change: Q32 (the wide SUM(ResolutionWidth+N) aggregate) has no arrayJoin, so this arrayJoin-lowering change cannot touch its path; the +12.9% is borderline with mixed test signals and noisy measurements (~26% spread), so treat it as variance.

Change = percent below ×2; the ratio of medians (×N faster/slower) beyond, where percent understates the scale. q-value = BH-FDR adjusted p; smaller is stronger evidence. MIRAI flags a query when q < fdr_q (default 0.10) — the value the verdict is based on.

tpch_adapted_1_official

🟢 No significant changes

Debug info
  • StressHouse run: 006b90a2-df77-4577-aff7-a0e9b3ae8d0f
  • MIRAI run: 9b0d3424-9f46-4a49-999b-4429879ab3a2
  • PR check IDs:
    • clickbench_484826_1789590298
    • clickbench_484832_1789590298
    • clickbench_484838_1789590298
    • tpch_adapted_1_official_484849_1789590298
    • tpch_adapted_1_official_484859_1789590298
    • tpch_adapted_1_official_484896_1789590298

@yariks5s
yariks5s added this pull request to the merge queue Sep 17, 2026
Merged via the queue into master with commit 398661c Sep 17, 2026
178 of 179 checks passed
@yariks5s
yariks5s deleted the yarik/lower-array-join-by-identity branch September 17, 2026 10:44
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label Sep 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-query-optimizer Query plan optimization: physical plan steps, plan-level rewrites and optimizations (QueryPlan pa... pr-performance Pull request with some performance improvements pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants