Skip to content

Build Iceberg min/max hyperrectangles only for columns the filter uses - #122681

Merged
scanhex12 merged 1 commit into
masterfrom
iceberg-prune-bounds-filter-columns
Sep 28, 2026
Merged

scanhex12 merged 1 commit into
masterfrom
iceberg-prune-bounds-filter-columns

Conversation

@scanhex12

@scanhex12 scanhex12 commented Sep 28, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Performance Improvement

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Build Iceberg min/max hyperrectangles only for columns the filter uses


Workflow [PR]
Sync PR [sync-upstream/pr/122681]

Version info

  • Merged into: 26.10.1.943-master (included in 26.10 and later)
  • Backported to: 26.9.6.4, 26.8.15.21, 26.7.19.9, 26.3.38.4

`ManifestFileIterator::processRow` decoded the lower/upper bounds of every
column of every manifest entry and looked up each column through
`IcebergSchemaProcessor::tryGetFieldCharacteristics`, although
`ManifestFilesPruner::canBePruned` only reads the ranges of the columns that
appear in the filter. Each lookup takes the shared lock of the table-wide
`SharedMutex`, walks a map holding the fields of every schema version and
copies a `NameAndTypePair`, so with many decode threads and concurrent queries
the lookups contend on the same cache lines and dominate the query.

The pruner now resolves the types of its min/max columns once, when it is
built, and `processRow` iterates over those columns only. `canBePruned` uses the
same cached types instead of a lookup per entry.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@scanhex12

Copy link
Copy Markdown
Member Author
Screenshot 2026-09-28 at 16 10 43

before:

@clickhouse-gh

clickhouse-gh Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [3ad7536]

Summary: ✅


AI Review

Summary

This PR narrows Iceberg min/max hyperrectangle decoding to the columns that the filter can actually use, by caching the relevant manifest-schema DataTypePtrs inside ManifestFilesPruner and reusing them during row processing. I did not find a correctness regression in the current code: the same schema ids feed both the cached key conditions and the narrowed hyperrectangle loop, row-lineage pruning still goes through addRowLineageHyperrectangles, and the non-filtered maintenance paths still call ManifestFileIterator without pruning enabled.

Missing context / blind spots
  • ⚠️ I did not reproduce the author’s performance profile locally, so the performance verdict relies on the PR discussion screenshots and on the fact that the semantic pruning path remains unchanged.
Final Verdict

✅ No actionable findings in the current diff.

LLVM Coverage Report

Measured on commit 3ad7536.

Metric Baseline Current Δ
Lines 87.90% 87.90% +0.00%
Functions 91.80% 91.70% -0.10%
Branches 79.30% 79.30% +0.00%

Changed lines: Changed C/C++ lines covered: 53/56 (94.64%) · Uncovered code

Full report · Diff report

@scanhex12

Copy link
Copy Markdown
Member Author
Screenshot 2026-09-28 at 16 11 21

after:

@clickhouse-gh clickhouse-gh Bot added the pr-performance Pull request with some performance improvements label Sep 28, 2026
@scanhex12

Copy link
Copy Markdown
Member Author
Screenshot 2026-09-28 at 16 12 19

@scanhex12

Copy link
Copy Markdown
Member Author

processRow is minimized

stack:   DB::Iceberg::deserializeFieldFromBinaryRepr(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, std::__1::shared_ptr<DB::IDataType const> const&, bool, bool)

and

tryGetFieldCharacteristics

too

@Avogar Avogar self-assigned this Sep 28, 2026
@scanhex12 scanhex12 added the pr-must-backport Pull request should be backported intentionally. Use this label with great care! label Sep 28, 2026
@clickhouse-gh clickhouse-gh Bot added the comp-datalake Data lake table formats (Iceberg/Delta/Hudi) integration. label Sep 28, 2026
@clickhouse-gh

clickhouse-gh Bot commented Sep 28, 2026

Copy link
Copy Markdown
Contributor

📊 Cloud Performance Report

✅ AI verdict: no_change — no significant changes across 36 queries analysed

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
  • StressHouse run: ec5439b2-6876-429b-a767-7dfa69caf4ef
  • MIRAI run: 1262f53a-6683-4726-a7cd-0aeec8909197
  • PR check IDs:
    • clickbench_2255474_1790612973
    • clickbench_2255480_1790612973
    • clickbench_2255486_1790612973
    • tpch_adapted_1_official_2255492_1790612973
    • tpch_adapted_1_official_2255696_1790612975
    • tpch_adapted_1_official_2256085_1790613046

@scanhex12
scanhex12 enabled auto-merge September 28, 2026 17:12
@scanhex12
scanhex12 added this pull request to the merge queue Sep 28, 2026
Merged via the queue into master with commit 8a4a94e Sep 28, 2026
149 checks passed
@scanhex12
scanhex12 deleted the iceberg-prune-bounds-filter-columns branch September 28, 2026 19:16
@robot-ch-test-poll robot-ch-test-poll added the pr-synced-to-cloud The PR is synced to the cloud repo label Sep 28, 2026
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Sep 28, 2026
clickhouse-gh Bot added a commit that referenced this pull request Sep 28, 2026
Backport #122681 to 26.9: Build Iceberg min/max hyperrectangles only for columns the filter uses
groeneai added a commit to groeneai/ClickHouse that referenced this pull request Sep 29, 2026
Two conflicts, both in the include blocks of files master also changed since
`caf26def`; no logic was touched to resolve them.

`ManifestFilesPruning.cpp`: master added `Common/DateLUT.h`,
`Core/DecimalFunctions.h` and `base/arithmeticOverflow.h` where this branch added
`DataTypes/DataTypeLowCardinality.h`. All four are kept.

`StorageObjectStorageSource.cpp`: master added `Interpreters/castColumn.h` where
this branch added `Interpreters/addMissingDefaults.h`. Both are kept.

Master's ClickHouse#122681 builds the min/max hyperrectangles and the new date partition
ranges only for the field ids in `used_columns_in_filter`, which is the list this
branch filters, so a column whose declared type the pruner must not compare stays
unpruned on those paths too.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
pull Bot pushed a commit to AnotherGenZ/ClickHouse that referenced this pull request Sep 29, 2026
`test_iceberg_narrow_manifest_bounds` fails on every master run since
ClickHouse#122679 restored its file:
https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?REF=master&sha=eb34e3144cb9f262e3b7dc8a6b49e0371dbac2d0&name_0=MasterCI&name_1=Integration%20tests%20%28amd_msan%2C%208%2F8%29

ClickHouse#122681 made `ManifestFileIterator::processRow` decode the bounds of only
the columns the filter uses (`getMinMaxColumnTypes`). The test narrows the
bound of `n` and then greps for the width guard's log line after a read
filtered on `s` alone, which no longer decodes `n`, so the grep returns
nothing. The CI of ClickHouse#122681 did not run this file, because ClickHouse#122485 had
removed it at the time.

The same change made the module's four other checks that a well-formed
column in the same manifest entry keeps pruning vacuous: each filtered on
the well-formed column alone, so the broken bound was never decoded and the
check passed whatever the per-column fallback did.

The five per-column checks now also filter on the broken column. The pruner
keeps one `KeyCondition` per filter column with only that column as key, so
the other column's atom is unknown and the conjunction prunes exactly as the
single-column filter did; the expected counts are unchanged.

Validated with two mutants that make the width guard or the inverted-pair
guard drop min/max pruning for the whole entry instead of one column: each
reddens the new file at exactly the checks of its own guard, while the old
file's checks at those sites stay green.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
PedroTadim added a commit that referenced this pull request Oct 1, 2026
Cherry pick #122681 to 26.8: Build Iceberg min/max hyperrectangles only for columns the filter uses
PedroTadim added a commit that referenced this pull request Oct 1, 2026
Cherry pick #122681 to 26.7: Build Iceberg min/max hyperrectangles only for columns the filter uses
PedroTadim added a commit that referenced this pull request Oct 1, 2026
Cherry pick #122681 to 26.3: Build Iceberg min/max hyperrectangles only for columns the filter uses
robot-clickhouse added a commit that referenced this pull request Oct 1, 2026
robot-clickhouse added a commit that referenced this pull request Oct 1, 2026
robot-clickhouse added a commit that referenced this pull request Oct 1, 2026
@robot-ch-test-poll robot-ch-test-poll added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Oct 1, 2026
clickhouse-gh Bot added a commit that referenced this pull request Oct 1, 2026
Backport #122681 to 26.8: Build Iceberg min/max hyperrectangles only for columns the filter uses
PedroTadim added a commit that referenced this pull request Oct 1, 2026
Backport #122681 to 26.3: Build Iceberg min/max hyperrectangles only for columns the filter uses
clickhouse-gh Bot added a commit that referenced this pull request Oct 1, 2026
Backport #122681 to 26.7: Build Iceberg min/max hyperrectangles only for columns the filter uses
kewin-robetti pushed a commit to viasoftkorp/ClickHouse that referenced this pull request Oct 2, 2026
@clickhouse-gh clickhouse-gh Bot added comp-iceberg Apache Iceberg tables: reading and writing Iceberg metadata (snapshots, manifests, schema evoluti... and removed comp-datalake Data lake table formats (Iceberg/Delta/Hudi) integration. labels Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-iceberg Apache Iceberg tables: reading and writing Iceberg metadata (snapshots, manifests, schema evoluti... pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-must-backport Pull request should be backported intentionally. Use this label with great care! pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR pr-performance Pull request with some performance improvements pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants