Repository navigation
Conversation
…lumns With `optimize_count_from_files` and `use_cache_for_count_from_files`, a repeated `count()` over `file()`, `url()` or `s3()` takes the row count of each file from the schema cache, but `ConstChunkGenerator` emitted it in `max_block_size` chunks (1529 chunks for 100M rows), each going through the pipeline and the aggregation. The slicing exists because a consumer may materialize the placeholder column. That cannot happen when the only aggregate is `count()` without arguments and the read requests no virtual or hive partition columns, so such a read now gets one chunk per file. The planner records the no-argument property in `SelectQueryInfo::trivial_count_without_arguments`; `Merge` clears it because `convertAndFilterSourceStream` materializes every column of its child reads; object storage skips its const-to-full conversion for that one chunk. Issue: ClickHouse#124144 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) plus my own cold review (2 nits).
Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-8:20261006-073808 |
|
Workflow [PR], commit [0186dd2] Summary: ❌
AI ReviewSummaryThe PR emits cached file row counts in one chunk for a no-argument Consumer tracing covered Findings❌ Blockers
Tests
Final VerdictStatus: ❌ Block Preserve bounded cached chunks when aggregation has not run before a materializing boundary, and add a regression test for partial-stage native output. |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units622 translation units recompiled, 4503 s compile time in total, 622 of them have a recent master baseline. |
`Stateless tests (amd_llvm_coverage, ParallelReplicas, s3 storage, parallel)` enables parallel replicas in the server profile, so with `parallel_replicas_for_cluster_engines` the `url()` and `s3()` arms run as `urlCluster`/`s3Cluster`. The count then happens on the replicas, and the initiator's `query_log` row has `SchemaInferenceCacheNumRowsHits = 0`, which failed the cache-hit check 3 out of 3 reruns. The arms test the local read, so the test pins `parallel_replicas_for_cluster_engines = 0`; `file()` and `merge()` are not affected by the setting. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
📊 Cloud Performance Report ✅ AI verdict: no significant changes detected. K_source=6 K_base=30 flagged=0/65 clickbench🟢 No significant changes tpch_adapted_1_official🟢 No significant changes Debug info
|
CI finish ledger - 7b466d3Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
All 146 check runs completed and Session id: cron:our-pr-ci-monitor:20261006-193218 |
…che-one-chunk # Conflicts: # src/Processors/QueryPlan/ReadFromObjectStorageStep.cpp # src/Storages/ObjectStorage/StorageObjectStorageSource.cpp # src/Storages/ObjectStorage/StorageObjectStorageSource.h
CI finish ledger - 93e564dEvery failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
CIDB has no other Session id: cron:our-pr-ci-monitor:20261022-170010 |
…che-one-chunk
Conflicts in StorageObjectStorageSource.{cpp,h} (createReader parameter
list: master added prefetch_input_format, this branch count_in_one_chunk;
both kept) and StorageFile.cpp (ReadFromFile::initializePipeline: master's
query_condition_cache_table_id block and this branch's count_in_one_chunk
line; both kept).
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Since ClickBench bbc2118 (2026-11-08), Release builds (clang-21, no LTO), r6i.8xlarge (Xeon 8375C) with the server pinned to 16 cores, ClickBench
|
…che-one-chunk Conflicts: StorageFile.cpp (ReadFromFile::initializePipeline, master's single-file split block next to count_in_one_chunk; trySplitSingleFile returns nullptr when need_only_count, so the two never meet) and prepareReadingFromFormat.h (both forward declarations kept). Also pass count_in_one_chunk_ = false from the new ReadFromObjectStorageStep::buildInOrderPipe: it calls the source constructor positionally, and the read-in-order merge materializes the sorting key of the columns it reads. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
📊 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 randomized Parquet writer settings (ClickHouse#132712) made the four 10M-row fixtures of the test take up to 460 s in the tsan and msan flaky checks. Write 1M rows and lower the memory limits from 40 MiB to 3 MiB. With `max_block_size = 8192` and `max_untracked_memory = 0` a read in `max_block_size` chunks peaks below 0.5 MiB, while one chunk of 1M UInt64 rows needs 7.63 MiB, so every case still fails when its exclusion is removed. Since ClickHouse#131185 an aggregation without GROUP BY copies at most 1 MiB of a constant argument, so `count(x)` no longer materializes a one-chunk read. The case counts `materialize(x)` instead, which still does. Co-Authored-By: Claude Opus 5.5 <[email protected]>
AI review of a later commit does not approve the PR, see the AI Review comment.
CI finish ledger - 0186dd2Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
CIDB has no other Session id: cron:our-pr-ci-monitor:20261121-193028 |
|
The
As ruled in #132892 (comment), a row like this stays for the reviewer to judge, so I am not changing the test or the perf job for it. |
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
A repeated
count()overfile(),url(),s3()and the other file-like table functions and engines, which takes the row count of each file from the cache, now returns it as one block per file instead of one block permax_block_sizerows. ClickBench Q1 (SELECT count(*) FROM hits) on a 100M-row Parquet file is more than 6 times faster. Closes #124144.Description
With
optimize_count_from_filesanduse_cache_for_count_from_files(both on by default), a repeatedcount()overfile(),url()ors3()reads no data: the row count of each file comes from the schema cache. The three cached-count shortcuts (StorageFileSource,StorageURLSource,StorageObjectStorageSource) still emit it throughConstChunkGeneratorinmax_block_sizechunks: 1529 chunks for 100M rows, each going through the pipeline.The slicing exists because something may materialize the placeholder column of these chunks. That cannot happen when the only aggregate is
count()without arguments and the read requests no virtual or hive partition columns, so such a read now gets one chunk per file:optimize_trivial_count(SelectQueryInfo::trivial_count_without_arguments);Mergeclears it, becauseconvertAndFilterSourceStreammaterializes every column of its child reads;count(x), filtered counts, virtual and hive columns,merge()and first executions are unchanged.Release builds (x86_64), 99,997,497-row Parquet file, row count cached, 8 paired fresh-server runs, median:
SELECT count(*) FROM hits(File(Parquet))SELECT count() FROM url(...)SELECT count() FROM s3(...)merge(),count(b), MergeTree controlsThe stateless test checks, with a memory limit, that every read which does materialize its columns (
count(materialize(x)),s3(),merge(), hive columns) still getsmax_block_sizechunks; each of those cases fails when its exclusion is removed. A performance test covers the cachedcount().The analysis and original patch are from #124144; this version moves the "no arguments" decision into the planner and adds the
Mergeexclusion. I can switch to a storage-local check instead of the newSelectQueryInfofield if preferred.Workflow [PR]
Sync PR [sync-upstream/pr/124174]