Repository navigation
Read only the used sorting key prefix in a read split into layers - #132720
Conversation
A read in order split into layers by a prefix of the sorting key read every column of the sorting key, although its streams are merged and its layers are filtered only by that prefix. This affects a single `uniqExact` counted in order (`optimize_aggregation_in_order`) and a merge join by ranges of the primary key (`query_plan_join_shard_by_pk_ranges`). Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Workflow [PR], commit [f2feee5] Summary: ✅
AI ReviewSummaryReviewed PR #132720 at Consumer coverage for the reduced expression output:
Final VerdictStatus: ✅ Approve |
Analyzing the sorting key again in the query context can name its expressions differently from the sort description, which uses the names of the stored key: with `transform_null_in`, `in` becomes `nullIn`, and the merge of a read in order threw `NOT_FOUND_COLUMN_IN_BLOCK`. Take the prefix from the stored expression instead. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units1408 translation units recompiled, 58 s compile time in total, 1408 of them have a recent master baseline. |
The self-join returned 200M rows and took up to 285 s under TSan. Use nearly unique keys, so that it returns 400k rows, and fewer, incompressible strings for the column that must not be read. Co-Authored-By: Claude Opus 5.5 <[email protected]>
`SHA256` is not available in the fast test build without OpenSSL. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…fix-columns # Conflicts: # src/Processors/QueryPlan/ReadFromMergeTree.cpp
|
📊 Cloud Performance Report ✅ AI verdict: no significant changes detected. K_source=4 K_base=25 flagged=0/65 clickbench🟢 No significant changes tpch_adapted_1_official🟢 No significant changes Debug info
|
The measured merge join loads the column statistics of the table on a statistics cache miss, and the compressed bytes of that load count in `ReadCompressedBytes`, which the test compares with a tenth of the compressed size of `s`. The `EXPLAIN PIPELINE` before the join normally warms the statistics cache. A concurrent test that drops a table in an `Ordinary` database empties the server-wide caches in between (`MergeTreeData::dropAllData` calls `Context::clearCaches` for a table without a UUID), so the join loads the statistics again. With the randomized `uniq` statistic (about 408 KB here) and the randomized server codec `ZSTD(1)` (threshold about 326 KB) the oracle prints 0. The read itself is unchanged. Create the table without statistics, so the measured queries count only their column reads. Related: ClickHouse#132720, ClickHouse#119664 Co-Authored-By: Claude Opus 5.5 <[email protected]>
A read in order that is split into layers by a prefix of the sorting key read every column of the sorting key, although its streams are merged and its layers are filtered only by that prefix. Two plans read this way: a single
uniqExactcounted in order (optimize_aggregation_in_order = 1) and a merge join by ranges of the primary key (query_plan_join_shard_by_pk_ranges). Now only the columns of the used prefix are read, besides those of the query.On ClickBench
hits(100M rows, sorting keyCounterID, EventDate, UserID, EventTime, WatchID), 16 threads:SELECT count(DISTINCT CounterID) FROM hits SETTINGS optimize_aggregation_in_order = 1reads 589 KB instead of 1.24 GB and takes 12 ms instead of 90 ms. Afull_sorting_mergejoin onkof two tables sorted by(k, s)reads 105 KB instead of 52 MB and takes 410 ms instead of 620 ms.Related: #129508
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
A read in order split into layers by a prefix of the sorting key (a single
uniqExactwithoptimize_aggregation_in_order, or a merge join by ranges of the primary key) reads only the columns of that prefix instead of the whole sorting key.Workflow [PR]
Sync PR [sync-upstream/pr/132720]
Version info
26.12.1.128-master(included in26.12and later)