Repository navigation
Conversation
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]>
Internal second-model review: adjudication log (click to expand)Pre-publication review by an independent model (engine: codex; 1 finding; bounded: 1 full pass + 1 fix round + 1 delta recheck).
Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-9:20261015-234300 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-5:20261015-224100 |
|
Workflow [PR], commit [047d6d2] Summary: ✅
AI ReviewSummaryRestores window-local passenger data and indexes in both lazy Final VerdictStatus: ✅ Approve. No review changes requested. |
|
cc @yariks5s @Avogar, could you review this? Since #124727 each lazily replicated |
CI finish ledger - 047d6d2Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
Session id: cron:our-pr-ci-monitor:20261016-070011 |
|
@groeneai who is a "passenger"? |
07f37c5
|
The columns that are not in the It is informal wording, not a ClickHouse term; I will write "non-joined columns" instead. |
Backport #126160 to 26.10: Cut lazily replicated `ARRAY JOIN` passengers to their output block
Closes: #126081
Related: #124727
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Lazily replicated
ARRAY JOINpassenger columns hold only the rows of their output block again, so materialized views,max_result_bytesand squashing sizeARRAY JOINoutput correctly.Description
Since #124727, every lazily replicated passenger column of an
ARRAY JOINoutput block wrapped the whole uncut input block, so each of the W output blocks of an input block reported, and copied, the whole block. A 1M-row insert throughSELECT payload, x FROM src ARRAY JOIN arr AS xinto MergeTree wrote 51 parts in ~6 s at 956 MiB peak instead of 9 parts, and a ~2 MB filtered result failedmax_result_bytes = 10000000withTOO_MANY_ROWS_OR_BYTES. #124727 is also in the26.10branch, which has no stable release yet.ArrayJoinResultIterator::nextandnextWithElementFilternow cut the passenger to the window before wrapping it, with window-local indexes, as before #124727. The rest of #124727 stays, including the referenced-rows bound that keeps filtered and sorted passengers lazy. Thefirst_indexparameter ofconvertOffsetsToIndexeshas no caller left and is removed.I did not fix the consumers instead:
byteSizecannot count only the referenced rows without scanning the indexes and summing per-row sizes, and it runs on every port push and pull; a row-count share undercharges variable-width rows.The price, measured on a Release build (median of 7): #124727's
SELECT x, str ... FROM numbers(10000000) ARRAY JOIN arr AS x FORMAT Nullgoes from 0.200 s to 0.345 s, since the passenger is copied once per input block again; the other four lazy queries #124727 added are within noise. The issue's insert: 9 parts, ~0.95 s, 403 MiB (eager replication: 9 parts, 1.04 s, 505 MiB).Validation:
05405_array_join_lazy_replication_chunk_bytes(MV part count,max_result_byteswith the filter fused intoARRAY JOINand not) fails on master and passes 50/50 with randomized settings; reverting either hunk alone reddens it. New perf testarray_join_lazy_replication_insert.xml.Workflow [PR]
Sync PR [sync-upstream/pr/126160]
Version info
26.11.1.82-master(included in26.11and later)26.10.2.21