Repository navigation
Document and pin the no-op modes of enable_join_runtime_filters_index_analysis - #119041
alexey-milovidov merged 6 commits into
Conversation
…_analysis `enable_join_runtime_filters_index_analysis` became a Production tier setting in #117383, but its second-pass granule pruning only happens for a left side that is read locally. The descriptors that drive it are attached to `ReadFromMergeTree` during query plan optimization and are carried by neither `clone` nor `serialize`/`deserialize`, and `initializePipeline` skips the pruning outright under parallel replicas. So with `make_distributed_plan = 1` or with parallel replicas the setting silently does nothing. Making those modes throw is not an option: the setting is an optimization hint, and rejecting a JOIN because its left side is read remotely would break working queries for no benefit. Instead the supported surface is now stated where a user looks for it, following the convention of the other production-tier settings that only apply to a subset of execution modes: the setting description says that the pruning does not happen with `enable_parallel_replicas = 1` or `make_distributed_plan = 1`, that the results are unchanged there, and that the JOIN runtime filter itself is unaffected. The new test `05153_join_runtime_filters_index_analysis_distributed_noop` pins that contract in all four modes: a local read prunes granules (`RuntimeFilterGranulesConsidered`/`Dropped` are nonzero), a distributed query plan, coordinator-driven parallel replicas and plan-based parallel replicas prune none, and all four return the same rows. Follows up on the review of #117383: https://github.com/ClickHouse/ClickHouse/pull/117383/changes#r3959601132 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
Workflow [PR], commit [b67f50c] Summary: ✅
AI ReviewSummaryThis PR documents the unsupported surfaces of Findings
Final VerdictStatus: Minimum required action: make the setting a real no-op in the unsupported modes that still build a runtime filter locally, or adjust the documentation/tests so they no longer claim that only probe-side granule pruning changes there. LLVM Coverage ReportMeasured on commit b67f50c.
Changed lines: Changed C/C++ lines covered: 40/40 (100.00%) · Uncovered code |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units120 translation units recompiled, 1364 s compile time in total, 120 of them have a recent master baseline. |
…-index-analysis-distributed-noop
…rmal projection read `registerLeftSideIndexAnalysisSecondPass` runs before the projection optimizations, so the descriptors that drive the second-pass granule pruning of `enable_join_runtime_filters_index_analysis` are attached to the base-table `ReadFromMergeTree`. `optimizeUseNormalProjections` then replaced that step with a fresh read from the projection and copied only the TopK state, so a JOIN whose left side is served from a normal projection silently lost the pruning even though the read stayed local. That contradicted the setting description this PR adds, which promises the pruning for every local read. The projection read now gets the descriptors through `copyJoinRuntimeFilterIndexAnalysisDescriptors`, which registers each of them anew via `addJoinRuntimeFilterIndexAnalysisOnDataRead`, so a descriptor survives only if the key column is in the projection's own primary key or has an applicable skip index there. A projection read also arrives with its analysis result precomputed, so `selectRangesToRead` never built `indexes` for it; `initializePipeline` now builds them on demand when descriptors are present, otherwise the `indexes.has_value()` gate skipped the pruning. The new test `05223_join_runtime_filters_index_analysis_normal_projection` pins it: a projection sorted by the join key prunes granules, a projection sorted by an unrelated column drops the descriptor and prunes none, and both return the same rows as the base table. Addresses the review thread on `Settings.cpp`: #119041 (comment) Co-Authored-By: Claude Fable 5.1 <[email protected]>
|
Confirmed both, and nothing fresher exists for either. AST fuzzer (amd_debug), STID 3293-4e7f. #111993 is the right one. The failed query is a matcher inside a lambda body under Worth separating: two distinct signatures share this message. 3293-4e7f (yours, lambda plus Stateless tests (arm_asan_ubsan, targeted), Both fixes are approved and unmerged (#111993 by @ vdimir on 2026-07-29, then auto-unassigned by the 30-day inactivity bot on 2026-08-28; #117764 by @ davenger on 2026-09-02), which is why both signatures keep landing on unrelated heads. |
…-index-analysis-distributed-noop
…untime_filters_index_analysis` The second-pass granule pruning is skipped in `ReadFromMergeTree::initializePipeline` for `FINAL` reads, and `optimizeLazyFinal` rebuilds such reads without the join runtime filter descriptors, so the setting description overstated the supported local surface. Document `FINAL` (and pending mutations / patch parts, which are skipped by the same guard) as no-op cases, and add `05243_join_runtime_filters_index_analysis_final_noop`, which checks that a `ReplacingMergeTree ... FINAL` probe side returns the deduplicated result without considering granules, while the same query without `FINAL` does prune. Review thread: #119041 (comment) Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…-index-analysis-distributed-noop # Conflicts: # src/Core/Settings.cpp
| Only a join key that is a primary key column of the probe side, or is covered by a `minmax`, `set` or `bloom_filter` skip index, can be pruned. | ||
| If the runtime filter kept the exact key values, the pruning predicate is an `IN` set of them, otherwise the minimum/maximum key range is used (this has a lower pruning power). | ||
|
|
||
| Takes effect only when the probe side of the join is read locally. The descriptors that drive the pruning are attached to the read step while the query plan is optimized, and they are not carried over when that step is rebuilt for remote execution, so the granule pruning does not happen with parallel replicas (`enable_parallel_replicas = 1`) or with a distributed query plan (`make_distributed_plan = 1`). In those modes the setting is a no-op: the query returns the same result and the JOIN runtime filter itself behaves exactly as it does with this setting disabled, only the granule pruning is lost. |
There was a problem hiding this comment.
This overstates the new contract. joinRuntimeFilter.cpp:174-182 still enables track_key_range directly from enable_join_runtime_filters_index_analysis, and BuildRuntimeFilterTransform / RuntimeFilter::insert still pay the extra build-side range-tracking scan when that flag is on (BuildRuntimeFilterTransform.cpp:79-81, RuntimeFilterLookup.cpp:735-746).
ReadFromMergeTree::initializePipeline() only decides later that probe-side pruning is unsupported (FINAL, pending mutations / patch parts, and parallel-replica reads at ReadFromMergeTree.cpp:5238-5251). So in those modes the setting is not actually a no-op: results stay the same, but the build side still does extra work for key-range tracking that can never be consumed. Could we either gate track_key_range on the probe read being able to use index analysis, or weaken this description/tests so they stop promising a true no-op?
Related: #117383
enable_join_runtime_filters_index_analysisbecame a Production tier setting in #117383, but the second-pass granule pruning it asks for only happens for a left side that is read locally. The descriptors driving it are attached toReadFromMergeTreewhile the query plan is optimized, and they are carried by neitherclonenorserialize/deserialize; on top of thatinitializePipelineskips the pruning outright under parallel replicas. So withmake_distributed_plan = 1, or with parallel replicas (coordinator-driven or plan-based), the setting silently does nothing — which overstates the supported surface for a production-tier setting. Since #121859 the setting is also enabled by default, so these modes now apply to every query rather than only to users who opted in.Making those modes throw is not an option: the setting is an optimization hint, and rejecting a JOIN because its left side is read remotely would break working queries for no benefit. So the supported surface is now stated where a user looks for it, following the convention of the other production-tier settings that only apply to a subset of execution modes. The setting description now says that the pruning does not happen with
enable_parallel_replicas = 1ormake_distributed_plan = 1, that the results are unchanged there, and that the JOIN runtime filter itself is unaffected.The new test
05153_join_runtime_filters_index_analysis_distributed_nooppins that contract in all four modes: a local read prunes granules (RuntimeFilterGranulesConsideredandRuntimeFilterGranulesDroppedare nonzero), while a distributed query plan, coordinator-driven parallel replicas and plan-based parallel replicas prune none — and all four return the same rows.Measured on a local build, summing the profile events of every query sharing the initiator's
initial_query_id:RuntimeFiltersCreatedRuntimeFilterRowsCheckedRuntimeFilterGranulesConsideredRuntimeFilterGranulesDroppedmake_distributed_plan = 1A local read served from a normal projection is not one of the no-op modes:
optimizeUseNormalProjectionsused to rebuild the left side's read step and copy only the TopK state, which dropped the descriptors silently. The projection read now gets them throughcopyJoinRuntimeFilterIndexAnalysisDescriptors(each one re-checked against the projection's own primary key and skip indexes) and builds its index templates on demand, since its analysis result is precomputed. The new test05223_join_runtime_filters_index_analysis_normal_projectionpins that a projection sorted by the join key prunes granules and a projection sorted by an unrelated column stays a correct plain read.The pruning is also not implemented for a left side read with
FINAL:initializePipelineskips it there (as it does for tables with pending mutations or patch parts), andoptimizeLazyFinalrebuilds such reads without the descriptors. The setting description now lists those cases too, and05243_join_runtime_filters_index_analysis_final_nooppins that aReplacingMergeTree ... FINALprobe side returns the deduplicated result without considering any granules, while the same query withoutFINALprunes.Propagating the descriptors to worker plans, so that the optimization also applies there, stays a follow-up; the code comments at the three sites that drop them now point at the documented contract and this test.
Follows up on this review comment: https://github.com/ClickHouse/ClickHouse/pull/117383/changes#r3959601132
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
The granule pruning of
enable_join_runtime_filters_index_analysisnow also applies when the left side of a JOIN is read from a normal projection. The setting description states that the pruning does not happen with parallel replicas, a distributed query plan, orFINAL.Workflow [PR]
Sync PR [sync-upstream/pr/119041]
Version info
26.10.1.691-master(included in26.10and later)