Skip to content

Enable query_plan_lower_array_join_function by default - #117882

Merged
yariks5s merged 31 commits into
masterfrom
yarik/enable-lower-array-join-function
Sep 28, 2026
Merged

yariks5s merged 31 commits into
masterfrom
yarik/enable-lower-array-join-function

Conversation

@yariks5s

@yariks5s yariks5s commented Sep 3, 2026 •

Copy link
Copy Markdown
Member

Related: #112241

Changelog category (leave one):

  • Performance Improvement

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

The arrayJoin function is now planned as an ARRAY JOIN step by default (setting query_plan_lower_array_join_function). The expansion streams through the pipeline instead of being materialized inside the projection, filters on the joined elements are applied before the rows are multiplied, and queries with several arrayJoin calls no longer build the whole cross product in memory. Feature itself: #116910


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

Version info

  • Merged into: 26.10.1.919-master (included in 26.10 and later)

@clickhouse-gh

clickhouse-gh Bot commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [7cd8e0f]

Summary: ✅


AI Review

Summary

This PR flips query_plan_lower_array_join_function to default-on and adjusts stateless/performance tests to the new plan shape. The settings-history wiring in Settings.cpp looks correct, but the default flip still is not proven well enough to merge: there is no setting-specific regression test for the new compatibility boundary, and there is still no focused before/after performance run for the new default-on path.

Findings

⚠️ Majors

  • [src/Core/Settings.cpp:7376] [dismissed by author -- https://github.com/Enable query_plan_lower_array_join_function by default #117882#discussion_r3969515898] The PR is still missing focused performance evidence for a Performance Improvement default flip. The broad cloud benchmark comment only says there was no significant change on 38 generic queries, and the robot report exposes only the build-profile diff, so neither one proves the promised arrayJoin win nor exercises the new single-arrayJoin regression guard added in [tests/performance/array_join_function_lowering.xml:28-30]. Please attach one run of that benchmark, or equivalent before/after numbers for the lowered-vs-legacy path, before enabling the setting by default.
Tests
  • ⚠️ [src/Core/Settings.cpp:7384] The new 26.10 history row is what makes compatibility = '26.9' or compatibility = '26.8' keep the legacy default, but no current test exercises that setting-specific boundary. [tests/queries/0_stateless/05218_settings_changes_history_placement.sql:5-35] only proves the mechanism on other settings. Please add a small stateless check that query_plan_lower_array_join_function is 0 under compatibility = '26.9' (and ideally 26.8) and 1 with no compatibility pin or with compatibility = '26.10'.
Final Verdict

Status: ⚠️ Request changes

  • Add a focused compatibility regression test for query_plan_lower_array_join_function.
  • Attach a focused run of tests/performance/array_join_function_lowering.xml, or equivalent before/after measurements, for the default-on path.

LLVM Coverage Report

Measured on commit 7cd8e0f.

Metric Baseline Current Δ
Lines 88.20% 88.20% +0.00%
Functions 91.70% 91.70% +0.00%
Branches 79.50% 79.50% +0.00%

Changed lines: Changed C/C++ lines covered: 13/13 (100.00%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added the pr-not-for-changelog This PR should not be mentioned in the changelog label Sep 3, 2026
@yariks5s

yariks5s commented Sep 3, 2026 •

Copy link
Copy Markdown
Member Author

Required: #117918, #117756

@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 4, 2026
@yariks5s

yariks5s commented Sep 7, 2026

Copy link
Copy Markdown
Member Author

Required: #118582

Comment thread src/Core/Settings.cpp Resolved
@clickhouse-gh clickhouse-gh Bot added pr-performance Pull request with some performance improvements and removed pr-not-for-changelog This PR should not be mentioned in the changelog labels Sep 9, 2026
@clickhouse-gh

clickhouse-gh Bot commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

📊 Cloud Performance Report

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

This PR only changes the default of query_plan_lower_array_join_function to true, plus test and reference updates. That setting only changes queries that call the arrayJoin() function, and no ClickBench or TPC-H query does. Q23's -39.3% improvement is therefore downgraded to not sure. Its master baseline was very noisy, and the query was already trending on master. Q30's -11.8% stays suppressed because it falls inside master's normal variance, which fits this PR having no effect on it. To see this PR's real effect, look at the array_join_function_lowering perf test, not these benchmarks.

clickbench

⚠️ 1 inconclusive

Flagged queries (1 of 43)
Query Verdict Baseline median (ms) PR median (ms) Change q-value Hint
⚠️ 23 not_sure 84 51 -39.3% <0.0001 This ClickBench query has no arrayJoin, so turning on query_plan_lower_array_join_function by default does not change its plan. The base measurements were very noisy and this query already has a recent trend on master.

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: adf28995-8f41-40ae-934b-d30a01ca0723
  • MIRAI run: 74103eee-f447-42f8-9c13-80c656e00ae9
  • PR check IDs:
    • clickbench_2223308_1790601961
    • clickbench_2223314_1790601961
    • clickbench_2223320_1790601961
    • tpch_adapted_1_official_2223326_1790601961
    • tpch_adapted_1_official_2223339_1790601961
    • tpch_adapted_1_official_2223380_1790601961

@yariks5s yariks5s added the ci-non-blocking Do not block pipeline on too many failed tests label Sep 9, 2026
Comment thread src/Core/SettingsChangesHistory.cpp Outdated
{"enable_sharding_aggregator", false, false, "Obsolete setting, the sharded aggregator has been removed in favor of the adaptive aggregator (`enable_adaptive_aggregator`)."},
{"allow_preliminary_distinct_abandoning", false, true, "New setting that lets the preliminary `DISTINCT` give up deduplicating mostly-unique input, because the final `DISTINCT` deduplicates its output again."},
{"query_plan_fuse_filter_into_array_join", false, true, "New optimization to fuse a filter on ARRAY JOINed columns into the ARRAY JOIN step, enabled by default."},
{"query_plan_lower_array_join_function", false, true, "New optimization to lower an arrayJoin function into a real ARRAY JOIN step, enabled by 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.

This default flip relies on the SettingsChangesHistory row here as the only rollback path for older compatibility values, but the PR adds no focused test for that boundary. 03999_stateless_settings_history.sh only checks that the setting is documented and that the current default matches the latest recorded new_value; it will still pass if this entry is registered under the wrong version. Please add a small stateless test that compatibility = '26.8' keeps the legacy non-lowered plan while 26.9 (or empty compatibility) produces the lowered ArrayJoin step.

@clickhouse-gh

clickhouse-gh Bot commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 7cd8e0f22 with master 010807a35 (stripped binary size, per-symbol sizes and ThinLTO time; object sizes against the warmup build of e7aebccc7; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Object file sizes

36 object files changed (+174.63 KiB total), 0 added.

Object file Master PR Δ
src/CMakeFiles/dbms.dir/Storages/StorageMergeTree.cpp.o 1.42 MiB 1.53 MiB +111.67 KiB (+7.66%)
src/CMakeFiles/dbms.dir/Columns/MaskOperations.cpp.o 102.46 KiB 134.66 KiB +32.20 KiB (+31.42%)
src/CMakeFiles/dbms.dir/Storages/MergeTree/MergeTreeDataMergerMutator.cpp.o 476.16 KiB 493.05 KiB +16.89 KiB (+3.55%)

716 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only clickhouse-bundle) and not compared.

Compile time of recompiled translation units

7 translation units recompiled, 15 s compile time in total, 7 of them have a recent master baseline.

Job report

@yariks5s

Copy link
Copy Markdown
Member Author

Required: #119186

Comment thread src/Core/SettingsChangesHistory.cpp Resolved
Comment thread src/Core/Settings.cpp Resolved
@yariks5s
yariks5s added this pull request to the merge queue Sep 25, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Sep 25, 2026
…array-join-function

Resolve the conflict with the move of the settings changes history into the setting declarations
(ee6b44f): the history records this PR added to `SettingsChangesHistory.cpp` now live as
trailing arguments of the `DECLARE` of each setting.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@yariks5s
yariks5s added this pull request to the merge queue Sep 28, 2026
Merged via the queue into master with commit 13d0231 Sep 28, 2026
173 checks passed
@yariks5s
yariks5s deleted the yarik/enable-lower-array-join-function branch September 28, 2026 15:25
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Sep 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-non-blocking Do not block pipeline on too many failed tests 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.

5 participants