Skip to content

Avoid unnecessary cuts for ArrayJoin - #124727

Merged
yariks5s merged 8 commits into
masterfrom
yarik/array-join-lazy-passengers-without-cut
Oct 15, 2026
Merged

yariks5s merged 8 commits into
masterfrom
yarik/array-join-lazy-passengers-without-cut

Conversation

@yariks5s

@yariks5s yariks5s commented Oct 8, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Performance Improvement

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

Improves ARRAY JOIN performance for queries with wide passenger columns by avoiding unnecessary passenger cuts and preserving lazy replication through filtering and sorting.


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

Version info

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

@clickhouse-gh clickhouse-gh Bot added the comp-query-execution Runtime execution pipeline, processors, vectorized operators, resource management during execution. label Oct 8, 2026
…zy-passengers-without-cut

# Conflicts:
#	src/Interpreters/ArrayJoinAction.cpp
#	tests/performance/array_join.xml
@clickhouse-gh

clickhouse-gh Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [7b7701d]

Summary: ✅


AI Review

Summary

This PR changes ARRAY JOIN lazy-passenger handling to keep passenger columns pointing at the full input block, and it tightens the ColumnReplicated materialization heuristic so buffering/sorting can compact those passengers instead of eagerly expanding them. The current diff addresses the earlier compaction and perf-coverage gaps; I do not see remaining correctness or major performance blockers in the code that is being merged.

PR Metadata
  • Changelog category looks mismatched: this is a user-visible ARRAY JOIN performance optimization, so Performance Improvement fits better than Not for changelog.
  • Changelog entry is therefore required, and Later is not sufficient. Suggested replacement:
    • Changelog category: Performance Improvement
    • Changelog entry: Improves ARRAY JOIN performance for queries with wide passenger columns by avoiding unnecessary passenger cuts and preserving lazy replication through filtering and sorting.
Missing context / blind spots
  • ⚠️ I could not validate end-to-end before/after numbers from CI performance-comparison jobs because the performance shards are skipped without the pr-performance label. The added benchmark queries now cover the touched paths, but CI measurements would close the loop on the claimed speedup.
Final Verdict

✅ Looks good to merge from a correctness/code-review perspective once the changelog metadata is updated; I did not find any remaining inline code issues to post.

@clickhouse-gh clickhouse-gh Bot added the pr-not-for-changelog This PR should not be mentioned in the changelog label Oct 9, 2026
@nihalzp nihalzp self-assigned this Oct 9, 2026
Comment thread src/Interpreters/ArrayJoinAction.cpp Resolved
@clickhouse-gh

clickhouse-gh Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Commit 7b7701d42bb4ad4491f94f7cf99fd0cea6a06217 was not compared: the CI logs cluster did not answer (every POST attempt failed with an exception).

See the job log for details.

Comment thread src/Interpreters/ArrayJoinAction.cpp Resolved
@yariks5s
yariks5s added this pull request to the merge queue Oct 15, 2026
Merged via the queue into master with commit 06a0224 Oct 15, 2026
321 of 323 checks passed
@yariks5s
yariks5s deleted the yarik/array-join-lazy-passengers-without-cut branch October 15, 2026 16:21
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 15, 2026
@clickgapai

Copy link
Copy Markdown
Contributor

@yariks5s @nihalzp — ClickGap found the following in this PR:

Close anything that's wrong or already addressed.

nihalzp pushed a commit to nihalzp/ClickHouse that referenced this pull request Oct 16, 2026
Since ClickHouse#124727 every lazily replicated ARRAY JOIN passenger wrapped the
whole uncut input-block column, with indexes into the current window.
All output blocks of one input block then shared that column, and every
ColumnReplicated consumer treats the nested column as the block's own
data: byteSize (Chunk::bytes, Squashing thresholds, max_result_bytes,
RESULT_BYTES) counted the whole input block per output block, and
Squashing::squash copied it per output block. A materialized view
flattening an array wrote 51 parts instead of 9 for a 1M-row insert,
and a small filtered result failed max_result_bytes.

Cut the passenger to the window before wrapping it, with window-local
indexes, in both ArrayJoinResultIterator::next and nextWithElementFilter,
as before ClickHouse#124727. Keep the rest of ClickHouse#124727, including
getReferencedRowsBound, which still keeps sparse filtered windows lazy.
The first_index parameter of convertOffsetsToIndexes has no non-zero
caller left, so it is removed.

Fixing the consumers instead was rejected: exact referenced-byte
accounting needs an O(rows) index scan plus per-row byteSizeAt inside
byteSize, which runs on every port push and pull, and a row-count share
of the nested bytes undercharges variable-width rows.

Price on a Release build (median of 7): the 10M-row lazy
`SELECT x, str ... ARRAY JOIN arr AS x FORMAT Null` query that ClickHouse#124727
added goes from 0.200 s to 0.345 s; its other four lazy queries are
within noise.

Closes ClickHouse#126081

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-query-execution Runtime execution pipeline, processors, vectorized operators, resource management during execution. pr-not-for-changelog This PR should not be mentioned in the changelog 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.

4 participants