Files
ClickHouse/tests/performance/array_join_lazy_replication_insert.xml
Groene AIandClaude Opus 5.5 047d6d28ed Cut lazily replicated ARRAY JOIN passengers to their output block
Since #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 #124727. Keep the rest of #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 #124727
added goes from 0.200 s to 0.345 s; its other four lazy queries are
within noise.

Closes #126081

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-15 23:39:35 +00:00

13 lines
876 B
XML

<test>
<create_query>CREATE TABLE array_join_mv_src (payload String, arr Array(UInt8)) ENGINE = Null</create_query>
<create_query>CREATE TABLE array_join_mv_dst (payload String, x UInt8) ENGINE = Null</create_query>
<create_query>CREATE MATERIALIZED VIEW array_join_mv TO array_join_mv_dst AS SELECT payload, x FROM array_join_mv_src ARRAY JOIN arr AS x</create_query>
<!-- The view squashes the lazily replicated String passenger of every ARRAY JOIN output chunk. -->
<query>INSERT INTO array_join_mv_src SELECT concat(toString(number), repeat('a', 100)), range(10) FROM numbers(1000000) SETTINGS max_threads = 1, max_insert_threads = 1</query>
<drop_query>DROP TABLE IF EXISTS array_join_mv</drop_query>
<drop_query>DROP TABLE IF EXISTS array_join_mv_dst</drop_query>
<drop_query>DROP TABLE IF EXISTS array_join_mv_src</drop_query>
</test>