Repository navigation
Support for granule pruning by (_part_starting_offset + _part_offset) in join runtime filter - #129677
Conversation
A JOIN runtime filter on `_part_starting_offset + _part_offset` now prunes granules of the probe side, so a self-join that fetches the rows found by a subquery reads only the granules of those rows. Also, a join key under a cast that can change values (e.g. narrowing) is no longer used for pruning: it dropped matching rows, also for primary key columns. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Workflow [PR], commit [937804e] Summary: ✅
AI ReviewSummaryReviewed PR head Consumers of the new descriptor form were traced through:
Both added stateless tests, Final VerdictStatus: ✅ Approve. No new inline comments or thread changes are needed. |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Object file sizes13 object files changed (+60.63 KiB total), 0 added.
719 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 units153 translation units recompiled, 1793 s compile time in total, 153 of them have a recent master baseline. |
…test `canBeSafelyCast` rejects an unsigned integer widened into a larger signed one (e.g. `UInt32` to `Int64`), which keeps every value and is the common type of an unsigned and a signed join key, so such joins lost their pruning. Accept it in the check for value-changing casts. `05493` no longer checks exact granule counts: a part can be analyzed more than once by a query, which adds its granules to the counters again. Related: ClickHouse#129677 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…structor Accept `Date` to `Date32` and `Date`, `DateTime` (and `Date32` up to scale 8) to `DateTime64` in the check for value-changing casts: they keep every value and are the common type of mixed date join keys, which lost their pruning. Set the global row index pruning of `MergeTreeSkipIndexReader` with a setter instead of a constructor argument, so the constructor stays unchanged for its other callers. Related: ClickHouse#129677 Related: ClickHouse/clickhouse-private#85905 Co-Authored-By: Claude Opus 5.5 <[email protected]>
The reader recognizes the `_part_offset + _part_starting_offset` node of the pruning predicate by its name, so a column with that name (which `CREATE TABLE ... AS SELECT` creates without an alias) was taken for it by the primary key and skip indexes, and matching rows were dropped. Such a table is no longer pruned by the global row index. The name is now one constant, checked where the node is built. Related: ClickHouse#129677 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
This relies on the table's snapshot taken at start of the query is used in all sub-queries reading from that table ( |
diegomestre2
left a comment
There was a problem hiding this comment.
Really cool feature @shankar-iyer , I left a few comments to clarify and suggest some changes. Could you add one query with enable_parallel_replicas = 1 that checks only that the result is correct? That would make sure it also works there. Let me know when it is ready for a second round.
The primary key and skip indexes get a predicate on their own keys only, and the global row index a predicate on it only. The conditions recognize their keys by name, so with one predicate a column named like the global row index expression, also cast to the join key type, was taken for it and matching rows were dropped. This replaces the guard on the column name. The key expression of the global row index is built once per read instead of per part, and the check of its name is no longer debug-only. Add a test with parallel replicas and tests for cast-wrapped column names. Related: ClickHouse#129677 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Added the parallel replicas check in 8e3e5a8: two queries in The other comments are addressed in the threads. Ready for another look. |
…ed reading `markSealGatedReading` matched descriptors to primary key columns by `key_column_name`, which is only a display name for the global row index. A primary key column with that name let the seal-gated reader prune by the global row index expression against the physical key, dropping matching rows. Related: ClickHouse#129677 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Fixing conflicts after #128128 got merged. |
…_offset_pruning # Conflicts: # src/Processors/QueryPlan/Optimizations/actionsDAGUtils.cpp
|
Clean CI run at commit 937804e |
diegomestre2
left a comment
There was a problem hiding this comment.
Great work! No more remarks form my side! It was a fun review!
Thanks, appreciate it! |
…e-filter-file-pruning Resolve the conflict in `collectAppliedJoinRuntimeFilters` with ClickHouse#129677, which added `is_global_row_index` to the MergeTree registration: MergeTree gets the new argument, object storage reads skip global row index descriptors (`_part_starting_offset + _part_offset` is a MergeTree key, not a column of the data files). Co-Authored-By: Claude Opus 5.5 <[email protected]>
A JOIN runtime filter on the global row index :
_part_starting_offset + _part_offsetnow prunes granules of the probe side (enable_join_runtime_filters_index_analysis). A self-join that fetches the full rows found by a subquery, for example the best row per group fromargMax(_part_starting_offset + _part_offset, ...), or rows picked byLIMIT BYor a window function, reads only the granules of those rows instead of the whole table.The key is recognized in either operand order, and it is not used when a physical column shadows
_part_offsetor_part_starting_offset, or for projection parts. Exact pruning is limited tojoin_runtime_filter_exact_values_limitkeys; above that, the filter falls back to the range of the keys. A key under aCASTthat can change values is not used for pruning.Changelog category :
Changelog entry
JOIN runtime filters now skip granules when the join key is the global row index
_part_starting_offset + _part_offset, so a self-join that fetches the rows found by a subquery reads only the granules of those rowsWorkflow [PR]
Sync PR [sync-upstream/pr/129677]
Version info
26.11.1.1863-master(included in26.11and later)