Repository navigation
Enable enable_join_runtime_filters_index_analysis by default - #117375
alexey-milovidov wants to merge 45 commits into
Conversation
The runtime filter collected from the right side of a JOIN was already used to
filter the probe side row by row (`enable_join_runtime_filters`, on by default
since 26.2), but only pruned granules of the probe side when
`enable_join_runtime_filters_index_analysis` was enabled explicitly. Enable it by
default and move the setting from the experimental to the beta tier, next to
`enable_join_runtime_filters` which it extends.
Measured on 30 million rows in a fact table ordered by the join key, joined
against a small dimension table (marks read, and rows read of the probe side):
dimension shape off on
100000 contiguous keys 3677 marks 25 marks 30.1M -> 206K rows
10 keys spread over table 3666 marks 12 marks 30.0M -> 90K rows
minmax skip index on key 3681 marks 224 marks 30.1M -> 1.8M rows
The pass is skipped when the join key is neither a primary key column nor covered
by a `minmax`, `set` or `bloom_filter` skip index, and when the filter is not
built yet, so it either prunes granules that cannot match or does nothing. On a
dimension table whose keys span the whole fact table, where nothing can be
pruned, the query time is the same within measurement noise (best of 7 runs:
0.081 s vs 0.079 s for the primary key case, 0.074 s vs 0.078 s for the skip
index case).
The existing `join_runtime_filter` performance test cannot cover this path: it
joins on `o_custkey` while `orders` is ordered by `o_orderkey`, so the join key
is neither in the primary key nor indexed and no filter is ever registered for
index analysis. Add `join_runtime_filter_index_analysis`, which measures pruning
by a key range, pruning by an exact `IN` set, and the overhead of the pass when
nothing can be pruned.
Correctness of the pruning is covered by the existing tests
`04490_join_runtime_filters_index_analysis`,
`04498_join_runtime_filters_multihop`,
`04611_join_runtime_filters_index_analysis_skip_index`,
`04612_join_runtime_filters_index_analysis_multi_key_anti` and
`04628_join_runtime_filter_reverse_key`, and the setting has been randomized by
`clickhouse-test` since it was introduced, so the whole stateless suite has been
running with it enabled about half of the time.
|
Workflow [PR], commit [979b737] Summary: ❌
AI ReviewSummaryThis PR enables Findings
Tests
Final VerdictStatus: Minimum required actions:
LLVM Coverage ReportMeasured on commit 979b737.
Changed lines: Changed C/C++ lines covered: 352/364 (96.70%) · Uncovered code |
| DECLARE(Bool, enable_join_runtime_filters_index_analysis, true, R"( | ||
| Prune granules on the left (probe) side of a JOIN with the runtime filter collected from the right side, see `enable_join_runtime_filters`. | ||
|
|
||
| The pruning predicate is an `IN` set of the key values recorded by the filter, or the recorded `[min, max]` key range when there are too many values to keep exactly, see `join_runtime_filter_exact_values_limit`. It is evaluated by the second index analysis pass that runs at data read time, see `use_skip_indexes_on_data_read`, and it applies when the join key is a primary key column or is covered by a `minmax`, `set` or `bloom_filter` skip index. When the filter is not built yet the pass is skipped, so a granule is never pruned by mistake. |
There was a problem hiding this comment.
-
This should mention that runtime filters as bloom filters (if their size is >
join_runtime_filter_exact_values_limit) cannot be used for pruning.\ -
"Second index analysis pass" is odd terminology. Let's please just mention dynamic skip index analysis during part read.
-
Sentence
When the filter is not built yet [...]provides no extra value for the reader and can be removed. I actually think that runtime filters are always build fully before they are used.
There was a problem hiding this comment.
🕵 Rewritten in 31bf81b, thanks. The description now reads:
Prune granules on the probe (left) side of a JOIN with the runtime filter collected from the build (right) side, see
enable_join_runtime_filters. The pruning happens as a dynamic skip index analysis while the probe side parts are read (seeuse_skip_indexes_on_data_read), so it can use a filter that is only known at runtime.Only a join key that is a primary key column of the probe side, or is covered by a
minmax,setorbloom_filterskip index there, can be pruned. If the runtime filter kept the exact key values, the pruning predicate is anINset of them; if the build side had more keys thanjoin_runtime_filter_exact_values_limitand the filter became a bloom filter, only the recorded key range is used, which prunes less.
On the three points:
- Agreed, "second index analysis pass" is gone — it now says dynamic skip index analysis during the part read, and names
use_skip_indexes_on_data_read. - Agreed, removed; you are right that the filter is always built before it is used, the fail-open branch is only a safety net.
- Here I had to phrase it differently, because a bloom filter can still prune.
convertRuntimeFilterToKeyConditionDAG(src/Processors/QueryPlan/RuntimeFilterLookup.cpp) uses the exact key values when the filter kept them, and otherwise falls back to the recorded[min, max]key range, which a bloom filter does record. So exceedingjoin_runtime_filter_exact_values_limitmakes the pruning coarser (a range instead of anINset) rather than impossible. Let me know if you would rather have it stated as a flat "no pruning" — then the code should be changed instead of the description.
There was a problem hiding this comment.
The current head still contradicts the fixed in 31bf81b67384 explanation here. src/Core/Settings.cpp:9438-9440 still says that once the filter overflows join_runtime_filter_exact_values_limit, "only the recorded key range is used", but RuntimeFilterIndexAnalysis::supportsDataType only records that range for integer/date-like keys. 05247_join_runtime_filter_string_key_no_range now proves the String case: after overflow, getRecordedKeyRanges stays empty and pruning becomes a no-op instead of a coarser range check.
So the original wording concern is still real for String join keys: the setting text, and the matching SettingsChangesHistory entry, should say that the range fallback is type-dependent rather than unconditional.
There was a problem hiding this comment.
🕵 Agreed, fixed in 148e11f. RuntimeFilterIndexAnalysis::supportsDataType records the range only for integer and date/date-time keys, so the setting text now says that for any other key type (String, floating-point, Decimal, UUID) the pruning stops once the filter loses the exact values, and the 26.10 SettingsChangesHistory record says the same. 05247_join_runtime_filter_string_key_no_range already pins the String behavior.
|
@rschu1ze — tagging you on this one as JOIN-related, as requested. Review request sent too. |
|
📊 Cloud Performance Report ✅ AI verdict: This PR defaults on probe-side JOIN granule pruning (enable_join_runtime_filters_index_analysis) and adds build-side key-range tracking that is dropped when no read can consume the filter; it touches only the join runtime-filter path. Both flagged ClickBench queries are single-table aggregations with no join (Q16: GROUP BY UserID; Q28: GROUP BY CounterID), so neither exercises the changed code. Both were already left non-directional by the deterministic gates: Q16 sits inside master's current variance band on an intrinsically noisy query, and Q28's two tests disagree on noisy measurements. No real regression or improvement is attributable to this change in the flagged set. clickbenchFlagged queries (2 of 43)
Change = percent below ×2; the ratio of medians (×N faster/slower) beyond, where percent understates the scale. q-value = BH-FDR adjusted p; smaller is stronger evidence. MIRAI flags a query when q < fdr_q (default 0.10) — the value the verdict is based on. tpch_adapted_1_official🟢 No significant changes Debug info
|
Build profile diff (arm_release)Commit See the job log for details. |
@alexey-milovidov I posted comments two days ago. Lgtm, overall, thanks. |
…time-filters-index-analysis
…time-filters-index-analysis
…-filters-index-analysis
…de can use it `enable_join_runtime_filters_index_analysis` was passed straight into every `BuildRuntimeFilterStep` as `track_key_range`, so turning it on by default made `BuildRuntimeFilterTransform` call `enableIndexAnalysis` and pay an extra `getExtremes` pass over every build chunk - even for joins whose probe side can never consume the result. The eligibility check (join key in the primary key, or covered by a `minmax`, `set` or `bloom_filter` skip index) happens later, in `ReadFromMergeTree::addJoinRuntimeFilterIndexAnalysisOnDataRead`, and the descriptors are also dropped for reads that are replaced afterwards, such as distributed and parallel-replica reads. Add a final optimization pass, `disableUnusedRuntimeFilterKeyRangeTracking`, which runs on the final plan: it collects the rendezvous keys of the runtime filters that some `ReadFromMergeTree` really registered for index analysis, and turns off key range tracking on every build step that is not among them. With that, the new default is a genuine no-op for non-prunable joins. `EXPLAIN actions = 1` now prints `Key range tracking` for `BuildRuntimeFilter`, so the decision is observable; test `05175_join_runtime_filter_key_range_tracking` pins it, including a query with two runtime filters where only the prunable one is tracked. `03716_anti_join_runtime_filters_2` pins the setting, which is randomized in CI and would otherwise change the printed plan. Also add the non-prunable join key to `tests/performance/join_runtime_filter_index_analysis.xml`, which is exactly the shape that had to be benchmarked, and reword the setting description: the pruning happens on the probe (left) side, not on the build side. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
🕵 The only red on the previous run was @groeneai, could you investigate the integration-test job timeouts and provide a fix in a separate PR? If a fix is already in progress, please link it here. Master is merged and the review findings are addressed in 31bf81b, so the job runs again from scratch on the new head. |
|
| arm | trees with a Timeout row |
|---|---|
db disk, N/4 (four batches) |
307 of 308 (933 rows) |
db disk, old analyzer, N/6 (six batches) |
3 of 308 |
That is the batch-count argument from #118933 measured in production, on the same branches over the same window. v26.6-must-backport, v26.7-must-backport and v26.8-must-backport on #116591 would clear the larger half of the count.
|
|
||
| if (auto * read_step = typeid_cast<ReadFromMergeTree *>(node->step.get())) | ||
| { | ||
| for (const auto & descriptor : read_step->getJoinRuntimeFiltersForIndexAnalysis()) |
There was a problem hiding this comment.
This still treats “a ReadFromMergeTree registered a descriptor” as the same thing as “some probe-side read can actually consume a positive pruning predicate”, but those are not equivalent.
A concrete counterexample is single-key LEFT ANTI JOIN: registerLeftSideIndexAnalysisSecondPass intentionally still registers the descriptor here, even though the comment right above says those filters stay fail-open. The built filter is ExactNotContainsRuntimeFilter, which sets range_positive = false in src/Processors/QueryPlan/RuntimeFilterLookup.h:255-269, and then convertRuntimeFilterToKeyConditionDAG returns nullptr because both getRecordedKeyValues and getRecordedKeyRanges are absent (src/Processors/QueryPlan/RuntimeFilterLookup.cpp:690-693). So consumed_filter_keys keeps the filter alive here, disableUnusedRuntimeFilterKeyRangeTracking leaves track_key_range on, and we still pay column.getExtremes() on every build chunk for a query shape that can never prune.
The same proxy also misses later read-side bail-outs in ReadFromMergeTree::initializePipeline (FINAL, pending mutations, disabled / ignored skip indexes, etc.), so the new default is still not “prune or do nothing” for every supported shape. Can we base this pass on “predicate actually buildable” rather than raw descriptor presence, or at least force track_key_range = false for check_left_does_not_contain and add an EXPLAIN test for that case?
There was a problem hiding this comment.
🕵 Adopted in 4e083a0, thank you — the counterexample is real.
You are right that registerLeftSideIndexAnalysisSecondPass registers a descriptor for the single-key LEFT ANTI shape, that the built filter is ExactNotContains with range_positive = false, and that convertRuntimeFilterToKeyConditionDAG therefore returns nullptr for it — so the old pass kept track_key_range on for a query shape that can never prune.
Two changes:
BuildRuntimeFilterStepis now constructed withtrack_key_range = falsewhenevercheck_left_does_not_containholds — both for the per-column filters of a single-key ANTI join and for the tuple filter of a multi-key one, which is always negating. This is decided at the source, where the semantics are known, rather than inferred later.disableUnusedRuntimeFilterKeyRangeTrackingnow matches reads against build steps in both directions. It first drops the read-side descriptors of any filter whose build step cannot produce a positive predicate, so the dynamic-predicate machinery is not installed for them at all, and only then disables tracking for the build steps that no remaining descriptor consumes.
05175_join_runtime_filter_key_range_tracking gets the EXPLAIN test you asked for, in three cases: a single-key ANTI join whose key is the primary key of the probe side (Key range tracking: 0), the multi-key tuple variant (0), and a query with a prunable INNER JOIN filter next to an ANTI filter, which prints 1 and 0 under one setting value — so it proves the decision is per filter and not per query. 44 of the 46 local *runtime_filter* tests pass; the two that do not need process_query_plan_packet in the server config (distributed plan serialization), which my local server does not have.
On the second half of your point — the later read-side bail-outs in ReadFromMergeTree::initializePipeline (FINAL, pending mutations, use_skip_indexes off, ignore_data_skipping_indices, parallel replicas): those are decided from the query context at pipeline-build time, after plan optimization has run, so the plan-level pass cannot see them. Making the new default literally "prune or do nothing" for those shapes needs the decision to move to (or be echoed back from) initializePipeline, which is a larger change than this PR should carry. The residual cost there is the getExtremes pass on the build side only; the read side already fails open. I am tracking that as a follow-up rather than widening this PR.
There was a problem hiding this comment.
🕵 Adopted in d25d7be071a5. You were right that I dismissed this too quickly — the late read-side guards are not actually "after plan optimization and therefore unfixable here", because every one of them is already knowable while the plan is being optimized.
ReadFromMergeTree::canUseJoinRuntimeFilterIndexAnalysis now holds those vetoes (FINAL, pending mutations, parallel replicas), and addJoinRuntimeFilterIndexAnalysisOnDataRead refuses to register a descriptor for a read that would reject it anyway. The registration also applies use_skip_indexes and ignore_data_skipping_indices to the skip-index half of the key test, which it previously ignored. initializePipeline calls the same method, so the plan-level pass and the pipeline cannot drift apart.
The second half of your finding — MergeTreeIndexReadResultPool::read materializing the predicate for every part when prune_primary_key == false and dynamic_skip_indexes is empty — is fixed at the source: dynamic_predicate_builder is now installed only when runtime_prune_primary_key || !runtime_skip_indexes.empty(), instead of whenever any descriptor exists.
One deliberate exception: use_skip_indexes_on_data_read is not part of the plan-level method. InterpreterExplainQuery forces it to false in its own context, so deciding the plan on it would make every EXPLAIN actions = 1 print a plan that differs from the one the same query really runs — a worse problem than the one being fixed. It stays checked in initializePipeline; with it off the dynamic predicate is not installed either, so only the build-side extremes pass remains.
Tests, in 05175_join_runtime_filter_key_range_tracking — including the exact case you asked for, each next to the positive control that pins the difference to that one reason:
ignore_data_skipping_indices = 'idx_v'on the join key withidx_wstill active on the read →0; the same query without it →1.use_skip_indexes = 0with a skip-index-covered join key →0; with a primary-key join key →1(the primary-key path is not gated by that setting).FINAL→0; the same table withoutFINAL→1.
46/46 *runtime_filter* stateless tests pass locally.
There was a problem hiding this comment.
🕵 Adopted in cceee73d698f, by narrowing the contract rather than the code, as the review offered as the second option.
You are right that the test comment listed use_skip_indexes_on_data_read among the read-side vetoes the plan acts on while canUseJoinRuntimeFilterIndexAnalysis deliberately leaves it out, so the text and the code disagreed. The code stays: EXPLAIN forces that setting to false in its own context (InterpreterExplainQuery, for #88467), so a plan gated on it would make every EXPLAIN actions = 1 print a plan that differs from the one the same query runs, which is a worse outcome than the residual min/max pass on the build side. With the setting off, the read installs no dynamic predicate at all (initializePipeline checks it before runtime_prune_primary_key / runtime_skip_indexes are computed), so the only remaining cost is that getExtremes pass over the build chunks.
What changed: the setting description and the SettingsChangesHistory entry now say explicitly that use_skip_indexes_on_data_read = 0 switches the pruning off but the build side still records the key range; the test comment no longer claims otherwise; and 05175_join_runtime_filter_key_range_tracking pins the exception with a read-time skip indexes disabled case that prints Key range tracking: 1, plus the corresponding result check, so a later change of this behavior has to be a deliberate one.
There was a problem hiding this comment.
The parallel-replicas half of this is still present on the current head.
registerLeftSideIndexAnalysisSecondPass still runs before applyParallelReplicas (optimizeTree.cpp:377-380 vs. 422), so the coordinated ReadFromMergeTree can already have join_runtime_filters_for_index_analysis populated when applyParallelReplicas later marks it as is_parallel_reading_from_replicas = true (applyParallelReplicas.cpp:630-636, ReadFromMergeTree.h:480-483). disableUnusedRuntimeFilterKeyRangeTracking then sees only those stale descriptors and keeps the build step alive, but the actual read will refuse to consume them because canUseJoinRuntimeFilterIndexAnalysis now returns false on that same step (ReadFromMergeTree.cpp:2916-2944).
So the plan/pipeline drift you said d25d7be071a5 removed is still there for plan-based parallel replicas: those queries can still pay the build-side getExtremes pass without any probe-side pruning. This needs either descriptor retraction/revalidation when applyParallelReplicas marks a read for replica coordination, or a rerun of disableUnusedRuntimeFilterKeyRangeTracking after that rewrite.
…-filters-index-analysis
…me filter Addresses the review finding that "a `ReadFromMergeTree` registered a descriptor" is not the same thing as "a pruning predicate can actually be built". A `LEFT ANTI` join builds its runtime filter as `ExactNotContains`, whose `range_positive` is false, so `RuntimeFilter::getRecordedKeyValues` and `RuntimeFilter::getRecordedKeyRanges` both return nothing and `convertRuntimeFilterToKeyConditionDAG` can never produce a predicate from it. `registerLeftSideIndexAnalysisSecondPass` still registers a descriptor for the single-key ANTI shape, so `disableUnusedRuntimeFilterKeyRangeTracking` used to keep `track_key_range` on there and the build side paid an extra `column.getExtremes` pass over every chunk for a query that can never prune. Two changes: - `BuildRuntimeFilterStep` is now constructed with `track_key_range = false` whenever `check_left_does_not_contain` holds - both for the per-column filters of a single-key ANTI join and for the tuple filter of a multi-key one, which is always negating. - `disableUnusedRuntimeFilterKeyRangeTracking` now matches reads against build steps in both directions: it first drops the read-side descriptors of filters whose build step cannot produce a positive predicate (so the dynamic-predicate machinery is not installed for them at all), and only then disables tracking for the build steps no remaining descriptor consumes. `05175_join_runtime_filter_key_range_tracking` gets three `EXPLAIN` cases: a single-key ANTI join on the primary key, a multi-key one, and a query that has a prunable `INNER JOIN` filter and an ANTI filter side by side - the last one prints `1` and `0` for one setting value, so it proves the decision is per filter. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
🕵 Pushed
The only other red, Local: 45/45 |
…ed fixed-hash-table filter is published `HashJoin::publishSharedRuntimeFilters` replaced the runtime filter registered by `BuildRuntimeFilterStep` with one that probes the join's own `FixedHashMap`, and copied `getRecordedKeyValues` / `getRecordedKeyRanges` once at that moment. The publication can run before the last stream-local filter has registered, and the metadata accessors expose nothing until every merge has happened, so the copy was empty for good: the later `IRuntimeFilterLookup::add` calls reached the no-op merge path of `SharedFixedHashTableRuntimeFilter` and could no longer contribute. With both `join_runtime_filter_from_fixed_hash_table` and `enable_join_runtime_filters_index_analysis` on by default, a multi-stream build could therefore lose granule pruning on the probe side nondeterministically and fall back to the row-wise `__applyFilter`. `IRuntimeFilterLookup::replace` now keeps the superseded filter as the index-analysis metadata source of the replacement, and `RuntimeFilter` forwards `merge`, `finishInsert`, `getRecordedKeyValues` and `getRecordedKeyRanges` to it. Probing still goes through the complete hash table from the moment of publication, while the exact key set and the `[min, max]` key range are finished by the late registrations exactly as they would have been without the publication. Nothing is snapshotted any more, so the ordering no longer matters. `RuntimeFilterLookup.LateAddAfterSharedFilterPublicationFailsOpenForIndexMetadata` pinned the old outcome and becomes `LateAddAfterSharedFilterPublicationCompletesIndexMetadata`; `SharedFilterPublicationKeepsCompleteIndexMetadata` is the control for the already-complete case. `05246_join_runtime_filter_shared_fixed_hash_table_index_analysis` pins the end-to-end contract: a multi-part build side that converts to a `FixedHashMap` still drops granules on the probe side, and drops none with index analysis off. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
🕵 Pushed The finding is real. Fix: remove the snapshot. Tests: the gtest that pinned the old outcome becomes The two red performance shards on
The same run shows what the PR is actually for: 8 faster, 2 slower over 6994 queries, with |
…read time `RuntimeFilterIndexAnalysis` records a `[min, max]` key range only for the types `supportsDataType` accepts (integers and date-like), but the build side collects a runtime filter for `String` keys as well. Once such a filter overflows `join_runtime_filter_exact_values_limit` it keeps no exact values either, so `convertRuntimeFilterToKeyConditionDAG` can only return `nullptr` and no pruning is possible any more - regardless of how index-capable the probe side is. `MergeTreeIndexReadResultPool` still acquired the data part before asking for the predicate, so a `String` primary key or a `set`-indexed `String` key paid that per-part work for nothing. Ask `dynamic_predicate_builder` first and enter the pruning path only when it produced a predicate. New test `05247_join_runtime_filter_string_key_no_range` pins the contract: `RuntimeFilterGranulesConsidered` is zero for both overflowed `String` shapes, while the exact-values controls and the integer key of the same size (which still records a range) do prune. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…-filters-index-analysis
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
🕵 Pushed The
|
| query | shards | runs | over threshold | max deviation |
|---|---|---|---|---|
read_in_reverse_order_final #0 |
12 | 3494 | 26.0 – 44.1% | 150% |
order_by_read_in_order #1 |
12 | 3495 | 31.3 – 50.0% | 61.5% |
and_compare_chain_derived #2 |
10 | 3514 | 36.9 – 47.2% | 68.8% |
The reported +20…+26% all sit comfortably inside that band. (and_compare_chain_derived #2 on this very shard was refuted the same way on #120808 yesterday.) Shard-wide the run is 9 faster / 6 slower over 6992 queries, which fetch_perf_report.py summarises as no significant performance changes.
Stress test (amd_debug) — Logical error: 'Cannot write to canceled buffer' in PostgreSQLProtocol::Messaging::ErrorOrNoticeResponse::serialize via PostgreSQLHandler::processQuery. That is the known open #118344, nothing to do with JOIN runtime filters; the fix is already in flight as #118369.
Build profile diff — RuntimeError: CI logs cluster query failed again, the CI logs cluster infrastructure. Open fix: #121048.
…ap of the JOIN runtime filter A probe key that only a `bloom_filter` skip index covers is pruned with the exact values of the runtime filter, but `ReadFromMergeTree` admits the index only while the filter keeps at most `join_runtime_filter_exact_values_limit / 100` values (100 with the default limit). The description of `enable_join_runtime_filters_index_analysis` claimed the pruning lasts until the filter overflows the limit, which is a stronger contract than the code implements. The cap is deliberate: the index tests the `IN` set one value at a time for every granule and its false positives add up over the set, so a few hundred values with the default 0.025 rate make every granule test positive. Describe the real contract in the setting text, explain the cap next to the code, and pin it with `05248_join_runtime_filter_bloom_filter_index_cap`: 500 exact keys below the limit but above the cap are not pruned (`RuntimeFilterGranulesConsidered` = 0, so the predicate is not even built), raising the limit so the cap covers them prunes again, and a `minmax` index takes the same set as is. Co-Authored-By: Claude Fable 5.1 <[email protected]>
|
🕵 Pass of 2026-09-22 on this PR.
|
…lters_index_analysis` describes only the default flip The `26.9` record already states that the JOIN runtime filters became a Production tier feature; repeating that sentence in the `26.10` record made `system.settings_changes` claim the tier change twice. The `26.10` record now describes only the `false` -> `true` default change and its contract. Co-Authored-By: Claude Fable 5.1 <[email protected]>
|
🕵 Pass of 2026-09-22 (second) on this PR.
|
…s_index_analysis` depends on the key type `RuntimeFilterIndexAnalysis::supportsDataType` records the key range only for integer and date/date-time keys, so after the filter overflows `join_runtime_filter_exact_values_limit` a `String` (or float, `Decimal`, `UUID`) key is not pruned at all, as `05247_join_runtime_filter_string_key_no_range` shows. State this in the setting description and the `26.10` history record. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
|
🕵 Pushed 148e11f: the The two stress reds on 3408012 are unrelated to this PR:
|
…-filters-index-analysis # Conflicts: # src/Core/SettingsChangesHistory.cpp
…analysis With `enable_join_runtime_filters_index_analysis` enabled by default, a join on a sorting key column still pruned the probe side by the primary key under `use_primary_key = 0`, because neither the plan-level registration in `addJoinRuntimeFilterIndexAnalysisOnDataRead` nor the read-time admission in `initializePipeline` looked at the setting. Both now apply the same gate as the ordinary primary key analysis: with `use_primary_key = 0` a key column is pruned only by a skip index covering it, and without one no descriptor is registered, so the build side does not track the key range either. `05249_join_runtime_filter_index_analysis_use_primary_key` pins the plan (`Key range tracking`) and `RuntimeFilterGranulesConsidered`/`Dropped` for the three shapes. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…lter The `join_runtime_filter_exact_values_limit / 100` cap for a `bloom_filter` skip index was only a yes/no gate for the whole index: as soon as one runtime filter on its column stayed within the cap, the index was applied with the shared predicate, which `buildRuntimeRangePredicate` builds from every descriptor - so a sibling exact set above the cap (`p.k = b1.k AND p.k = b2.k`) was still hashed and tested per granule. `MergeTreeSkipIndexReader::DynamicSkipIndexFilter` now returns a `DynamicSkipIndexUse` (`Skip`, `Shared` or `Own`), and `DynamicPredicateBuilder` takes the index an `Own` predicate is built for. `ReadFromMergeTree` gives a `bloom_filter` index its own predicate from the cap-admitted filters only; the primary key and the other skip indexes keep the shared predicate, built once per part as before. `05250_join_runtime_filter_bloom_filter_index_cap_per_filter` pins the same-key two-filter shapes (one filter on each side of the cap, and two admitted filters). Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
|
🕵 Pushed
Locally, on a fresh build of this branch, all |
…-filters-index-analysis Master moved the `BuildRuntimeFilterStep` / `BuildRuntimeFilterTransform` parameters into `RuntimeFilterBuildOptions` (`f6d52e79fada`). The PR's split of index analysis from key range tracking is carried over as a new `RuntimeFilterBuildOptions::index_analysis` field next to `track_key_range`; `disableIndexAnalysis` / `disableKeyRangeTracking` now update `build_options`.
…aveats in the `26.10` settings history record The `system.settings_changes` text for the `enable_join_runtime_filters_index_analysis` flip now says that a key covered only by a `bloom_filter` index is pruned only while the filter keeps at most `join_runtime_filter_exact_values_limit / 100` exact values (pinned by `05248_join_runtime_filter_bloom_filter_index_cap`), and that with `use_primary_key = 0` a primary key column is pruned only by a skip index that covers it (pinned by `05249_join_runtime_filter_index_analysis_use_primary_key`), same as the setting description. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
|
🕵 Pushed
Local: the merged |
… pruning The replacement `SharedFixedHashTable` filter is `isReady` at once, but only `__applyFilter` looks at that; granule pruning reads `getRecordedKeyValues` / `getRecordedKeyRanges`, which forward to the superseded filter and stay empty until its last registration, with or without the replacement. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
|
Obsoleted by #121859 |
…on computed `PartsSplitter::buildFilters` cloned the sorting key AST into the per-layer border predicate and `applyRangeFilterFromAST` resolved it again with the query's `ExpressionAnalyzer`. A key expression whose result type depends on a session setting - `CAST(json.b, 'String')` is `String` in a table created under `cast_keep_nullable = 0` and `Nullable(String)` in a session with `cast_keep_nullable = 1` - then became a different function with different values: the row whose `json.b` is missing is `''` for the table and `NULL` for the query, the layer filter `tuple(key) > tuple(border)` evaluated to `NULL` for it, and `FilterSortedStreamByRange` dropped the row from every layer. Visible as a wrong `FINAL` result, and in CI as `05187_read_in_order_key_type_setting_divergence` losing its `NULL` rows whenever the randomized settings paired `index_granularity = 1` with `merge_tree_read_split_ranges_into_intersecting_and_non_intersecting_injection_probability`. Every caller (`readByLayers`, the distributed `FINAL` lanes in `MergeTreeFinalMerge`) runs the table's own sorting expression on the pipe right before the filter, so the key columns are already in the stream under their `getColumnName` names. The filter now refers to them by name and is resolved against the stream header instead of the table columns, so it compares exactly the values the layers were split by. Test `05217_parts_splitter_layer_filter_key_type_divergence`: a `ReplacingMergeTree FINAL` and a forced split on an ordinary read under the diverged type, each losing the `NULL` row before the fix, plus a same-type control. Related: ClickHouse#119385 CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=117375&sha=9e46ee24a0a6d36d1f40aea2f3c12fbb65608268&name_0=PR&name_1=Stateless%20tests%20%28arm_binary%2C%20parallel%29 (PR ClickHouse#117375) Co-Authored-By: Claude Fable 5.1 <[email protected]>
Related: #109085
Related: #117322
The runtime filter collected from the right side of a JOIN was already used to filter the probe side row by row (
enable_join_runtime_filters, enabled by default since 26.2), but it pruned granules of the probe side only whenenable_join_runtime_filters_index_analysiswas enabled explicitly. This enables it by default.Measured on 30 million rows in a fact table ordered by the join key, joined against a small dimension table (marks read, and rows read on the probe side):
minmaxskip index on the join keyThe pass is skipped when the join key is neither a primary key column nor covered by a
minmax,setorbloom_filterskip index, and when the filter is not built yet, so it either prunes granules that cannot match or does nothing. The one exception isuse_skip_indexes_on_data_read = 0: it switches the pruning off, but the build side still records the key range of the filter, becauseEXPLAINforces that setting tofalsein its own context and a plan decided on it would differ from the plan the same query runs with. On a dimension table whose keys span the whole fact table, where nothing can be pruned, the query time is the same within measurement noise (best of 7 runs: 0.081 s vs 0.079 s for the primary key case, 0.074 s vs 0.078 s for the skip index case).Enabling the setting also used to switch on the build-side key range tracking (an extra
getExtremespass over every build chunk) for every runtime filter, including those whose probe side can never consume it. That is fixed here: the new final optimizer passdisableUnusedRuntimeFilterKeyRangeTrackingturns the tracking off for every build step whose filter noReadFromMergeTreeregistered for index analysis, so a non-prunable join pays nothing.EXPLAIN actions = 1prints the decision asKey range tracking, pinned by the new test05175_join_runtime_filter_key_range_tracking.The existing
join_runtime_filterperformance test cannot cover this path: it joins ono_custkeywhileordersis ordered byo_orderkey, so the join key is neither in the primary key nor indexed and no filter is ever registered for index analysis. This addsjoin_runtime_filter_index_analysis, which measures pruning by a key range, pruning by an exactINset, the overhead of the pass when nothing can be pruned, and a join key that is not prunable at all.Correctness of the pruning itself is covered by the existing tests
04490_join_runtime_filters_index_analysis,04498_join_runtime_filters_multihop,04611_join_runtime_filters_index_analysis_skip_index,04612_join_runtime_filters_index_analysis_multi_key_antiand04628_join_runtime_filter_reverse_key. In addition,clickhouse-testhas randomized this setting since it was introduced, so the whole stateless suite has already been running with it enabled about half of the time.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Enabled
enable_join_runtime_filters_index_analysisby default. The set of JOIN keys collected from the right side of a JOIN at runtime is now also used to skip granules of the left side, in addition to filtering its rows. It applies when the join key is a primary key column or is covered by aminmax,setorbloom_filterskip index.🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/117375]