Skip to content

Parquet: binary-search and cache ordered row-group fences - #115878

Closed
adonm wants to merge 9 commits into
ClickHouse:masterfrom
adonm:adonm/parquet-row-group-fence-cache
Closed

adonm wants to merge 9 commits into
ClickHouse:masterfrom
adonm:adonm/parquet-row-group-fence-cache

Conversation

@adonm

@adonm adonm commented Aug 21, 2026 •

Copy link
Copy Markdown

Related: #116235

For conjunctive point lookups, use a cached fence index only after footer statistics establish strictly ordered, non-overlapping row-group ranges. The selected candidate still passes through ordinary residual filtering; unsupported files use ordinary pruning.

Added cold/warm result comparisons against filtering without pushdown for ascending, descending, overlapping, nullable, decimal, timestamp and NaN-containing fixtures. The fixtures pass on a baseline binary. The fence-enabled build, counter regression, and differential tests are queued: https://github.com/adonm/ClickHouse/actions/runs/33951075622. Counter-test filenames and query IDs are isolated across retries.

Kept draft behind the shared-footer change. Cache configuration/memory accounting and broader boundary coverage remain to be reviewed; combined-branch timing results are not isolated evidence for this head.

Changelog category (leave one):

  • Performance Improvement

Changelog entry:

Use validated ordered Parquet row-group fences to narrow supported point lookups before applying ordinary row-group filtering.


Original implementation assisted by DeepSeek V4 Pro; follow-up revisions also used AI assistance.

@CLAassistant

CLAassistant commented Aug 21, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@rienath

rienath commented Aug 24, 2026

Copy link
Copy Markdown
Member

Looks like AI one-shot. You also filed many PRs simultaneously. Consider creating an issue instead

@adonm

adonm commented Aug 25, 2026

Copy link
Copy Markdown
Author

@rienath thanks for the feedback. I've moved the full context into #116235 (measurements, repro, landing order).

This PR is the ordered row-group fence search, last in that order and the largest of the six. One thing to note: it only activates when footer statistics prove the ranges are strictly ordered and non-overlapping, and it still runs the full condition on the candidate as a residual check.

I'll rebase all six onto master and update here once fork validation is green.

adonm added 2 commits August 25, 2026 05:47
Keep the row-group fence search current with master.
The stateless test was committed with mode 100644, so clickhouse-test
fails to run it with Permission denied.
@adonm
adonm marked this pull request as draft August 25, 2026 18:20
adonm added a commit to adonm/ClickHouse that referenced this pull request Sep 3, 2026
Replace debug-only `chassert` guards in `ManifestFilesPruner::partitionFilterHash` with real `LOGICAL_ERROR` checks on the `KeyCondition` `RPN` (`AND`/`OR`/`NOT`), so a malformed stack throws an exception in release builds instead of causing undefined behavior.

Document only, no behavior change: stateless `ManifestFileIterator::create` `table_snapshot_id` placeholder, `ParquetV3BlockInputFormat` row-group key unambiguity via `path.size()`, partition-only candidate sharing between data and delete iterators, derived `StorageInMemoryMetadata` `TableStateSnapshot` equality safety under `SYSTEM CLEAR ICEBERG METADATA CACHE`, and `DatabaseDataLake::tryGetTableImpl` global-context credentials, TTL race, and `ALTER DATABASE` over-invalidation.

Related: ClickHouse#116235
Related: ClickHouse#115873
Related: ClickHouse#115874
Related: ClickHouse#115876
Related: ClickHouse#115877
Related: ClickHouse#115878
adonm added a commit to adonm/ClickHouse that referenced this pull request Sep 3, 2026
…into files cache

Replace the hand-rolled `OrderedRowGroupIndexCache` (`mutex` + `unordered_map` + `list`) with `CacheBase` in the new `ParquetOrderedRowGroupIndexCache.h`: bounded eviction, `ParquetOrderedRowGroupIndexCacheBytes/Files` gauges and `ParquetOrderedRowGroupIndexCacheWeightLost` events. `SYSTEM CLEAR PARQUET METADATA CACHE` now resets the fence index too (same file-identity keying), covered by a clear-and-miss round-trip in `05024_parquet_sorted_row_group_point_lookup`.

Move the single-entry derived `StorageInMemoryMetadata` cache out of `IcebergMetadata` into `IcebergMetadataFilesCache` as `DerivedStorageMetadata`, keyed by the exact `TableStateSnapshot::operator==` fields. This bounds its memory, shares entries across storages of one table, and couples its lifetime to `SYSTEM CLEAR ICEBERG METADATA CACHE`. Time-travel queries still bypass it, and with `use_iceberg_metadata_files_cache=0` the metadata is built directly with no caching.

Related: ClickHouse#116235
Related: ClickHouse#115874
Related: ClickHouse#115878
Replace the hand-rolled `OrderedRowGroupIndexCache` (`mutex` + `unordered_map` + `list`) with `CacheBase` in the new `ParquetOrderedRowGroupIndexCache.h`: bounded eviction, `ParquetOrderedRowGroupIndexCacheBytes/Files` gauges and `ParquetOrderedRowGroupIndexCacheWeightLost` events. `SYSTEM CLEAR PARQUET METADATA CACHE` now resets the fence index too (same file-identity keying), covered by a clear-and-miss round-trip in `05024_parquet_sorted_row_group_point_lookup`.

Related: ClickHouse#115878
The `CacheBase` port dropped the anonymous namespace but kept its closing brace, ending `DB::Parquet` early and breaking unqualified lookup for the rest of `Reader.cpp`.

Related: ClickHouse#115878
adonm added a commit to adonm/ClickHouse that referenced this pull request Sep 3, 2026
The `CacheBase` port dropped the anonymous namespace but kept its closing brace, ending `DB::Parquet` early and breaking unqualified lookup for the rest of `Reader.cpp`.

Related: ClickHouse#115878
@clickhouse-gh clickhouse-gh Bot added the comp-parquet-reader-v3 Issues related to the native Parquet reader. label Sep 4, 2026
Add cold/warm differential fixtures for ascending, descending, overlapping, nullable, decimal, timestamp and NaN-containing row groups. Isolate the existing counter test filenames and query IDs across retries. The new fixture passed on the baseline binary; the fence-enabled build and counter tests remain pending.
@maxknv maxknv added the external Author is not a member of the ClickHouse organization label Nov 2, 2026
@adonm

adonm commented Nov 9, 2026

Copy link
Copy Markdown
Author

Closing this draft to keep the review queue clear, per @rienath's request in #116235 to not have the whole series open at once.

The fence-index idea and its ordering/precondition caveats stay in #116235. Nothing here is being pursued right now; happy to reopen as a fresh, focused PR if the team wants this piece.

@adonm adonm closed this Nov 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

close in a month if not active This will be closed in case of no information comp-parquet-reader-v3 Issues related to the native Parquet reader. external Author is not a member of the ClickHouse organization

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants