Repository navigation
Read an Iceberg data file in order only when its position deletes need it - #131203
Conversation
…streamed `IcebergMetadata::modifyFormatSettings` forced `parquet.preserve_order` for every Iceberg read unless `use_roaring_bitmap_iceberg_positional_deletes = 1`, because `IcebergStreamingPositionDeleteTransform` needs increasing row numbers from the data file reader and from the readers of its delete files. With `preserve_order` the Parquet reader delivers only from the first unfinished row group, and the reordering of row groups by statistics for `ORDER BY ... LIMIT` is off, so tables and files without position deletes paid for nothing. The order is now forced per file in `StorageObjectStorageSource::createReader`, for the data file and its delete files, exactly when `getPositionDeleteTransformer` picks the streaming transform (the predicate is factored out as `IcebergDataObjectInfo::usesStreamingPositionDeletes`). The read in order and lazy materialization already pin the order themselves. `ALTER TABLE ... DELETE` and `UPDATE` write the positions of every data file in the order their read returns them, and the streaming transform requires them increasing. That read relied on the forced order, and with `use_roaring_bitmap_iceberg_positional_deletes = 1` it already ran without it, writing unsorted delete files that a later default read applies partially (deleted rows come back; reproduced on 26.8, 26.9 and 26.10). The read of the mutation now asks for the order explicitly through `input_format_parquet_preserve_order`, which `modifyFormatSettings` now honours: an engine table's format settings are built at CREATE time and do not see the query's. Measured (release builds, 25M rows of ClickBench hits in 4 data files, IcebergLocal, 16 cores, paired): 14 queries geomean 0.886 (`ORDER BY EventTime LIMIT 10` 0.686), 43 queries 0.942, 4 cores 0.915; the new perf test `iceberg_top_k_row_group_order` 0.37-0.41 on its top-K queries, neutral on the controls. Analysis and the original patch: ClickHouse#130931 (snelheidai). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Shorten the modifyFormatSettings and mutation-read comments to one line each and drop the createReader comment that repeated the usesStreamingPositionDeletes doc comment. 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; 0 findings; 1 full pass), plus a separate cold review of the same tree (3 nits, no change).
Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-11:20261113-053901 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-5:20261113-032800 |
|
Workflow [PR], commit [840028e] Summary: ✅
AI ReviewSummaryPR #131203, head Missing context / blind spots
Final VerdictStatus: ✅ Approve. No code changes requested; normal CI validation remains pending. |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Object file sizes8 object files changed (+19.00 KiB total), 0 added.
711 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only Slowest function optimization changes (ThinLTO)Median per-function time ratio to the master baseline:
Compile time of recompiled translation units57 translation units recompiled, 619 s compile time in total, 57 of them have a recent master baseline. |
06ad563
The check of the tests a PR adds or changes (ClickHouse#129330) failed a PR only when a query's time grows run over run on the tested server. A test whose runs are noisy without a trend passed its own PR, and in master_head PR mode the report's own unstable/changed verdict never fails a PR. That is how system_clusters_replicated_databases (ClickHouse#122223) got in: tested-server spread (stddevPop / median of its runs) 0.41-2.1 in its PR, now > 0.5 on both master servers in about 99% of runs and the noisiest test on master. The check now also fails on an unstable query of such a test: - PR changes only files under tests/ and the reference is the performance reference build of the tested master commit's sources (find_prev_build's new third value; a reference of an older commit, as in about a quarter of PR jobs, does not count): both servers run the same code built the same way, so the report's verdict judges the test; fail on changed_fail or unstable_fail of report/all-queries.tsv. A query that failed on the reference server and ran only on the tested one is not in that file; it is judged by the rule below. - Any other PR or reference (code changes, the official-build fallback, or an older reference): the report measures the PR's change, not the test (the floors flag 79% of the heads of the 214 code PRs that changed a perf test in 2026-11-12..21, their own speedups). Fail when stddevPop / median of the tested server's runs is above 0.5 (at least 5 runs). A spread the change causes also fails: after the merge both master servers run that code. The bar 0.5 flags 0.5% of those code-PR heads and 0.2% of quiet tests' master heads (CIDB backtest), and all 4 jobs of ClickHouse#122223. A query the trend check already reports gets only its trend row. The reading loop of find_run_trends moves to read_query_runs, shared by both checks; run_trend_gate becomes changed_tests_gate. Validated locally on downloaded job logs (no test of the test infrastructure): ClickHouse#122223's 4 jobs fail (the old check passes them); the new tests of ClickHouse#129328, ClickHouse#124553, ClickHouse#131203 (code PRs) and the tests-only ClickHouse#130763, ClickHouse#129627 pass; the run-trend output is unchanged on all 1754 tests of 14 jobs. Related: ClickHouse#100759 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Closes: #130931
Related: #113095
Related: #129380
Related: #120916
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Iceberg tables keep the row order of a Parquet data file only for files whose position deletes need it, so other files are read with full parallelism and
ORDER BY ... LIMITcan skip row groups by their statistics:ORDER BY ... LIMITqueries over an Iceberg table are up to 2.7 times faster, ClickBench queries 6% faster on average.ALTER TABLE ... DELETEandUPDATEwithuse_roaring_bitmap_iceberg_positional_deletes = 1no longer write position delete files that make a later read return deleted rows.Description
Problem. Since #87220
IcebergMetadata::modifyFormatSettingsforcesparquet.preserve_orderfor every Iceberg read, becauseIcebergStreamingPositionDeleteTransformneeds increasing row numbers from a data file and its delete files. The Parquet reader then delivers only from the first unfinished row group and never reorders row groups by statistics forORDER BY ... LIMIT, even for files without deletes.Change.
StorageObjectStorageSource::createReaderforces the order for a data file and its delete file readers exactly when the streaming transform is used (same predicate); reading in order (#113095) and lazy materialization pin it themselves. The read ofALTER TABLE ... DELETE/UPDATE, which writes each data file's positions in read order, asks for the order throughinput_format_parquet_preserve_order, whichmodifyFormatSettingsnow honours, as an engine table's format settings never see the query's. This also fixes a released bug: withuse_roaring_bitmap_iceberg_positional_deletes = 1that read was unordered and a later default read returned deleted rows (26.8 to 26.10). #129380 and #120916 would sort these positions in the writer instead. ASELECTwithoutORDER BYno longer returns a file's rows in file order (ass3());input_format_parquet_preserve_order = 1restores it.Measured (release builds,
IcebergLocal, 25M rows of ClickBenchhitsin 4 files, 16 cores, paired runs, ratio = PR / master): 14 queries geomean 0.886,ORDER BY EventTime LIMIT 100.686, all 43 queries 0.942, none slower beyond noise; newiceberg_top_k_row_group_order0.37-0.41 on top-K queries, controls 1.02. Peak memory: lower on 5 of the 14 queries, up to +21% on top-K queries. Results are identical.Tests.
05628checks that delete files are sorted and deletes apply; it fails on master and with any part of the change reverted.Analysis and the original patch by @ snelheidai in #130931.
Workflow [PR]
Sync PR [sync-upstream/pr/131203]
Version info
26.11.1.2193-master(included in26.11and later)