Repository navigation
Short-circuit MergeTree analysis for empty PREWHERE sets - #113963
rorylshanks wants to merge 55 commits into
Conversation
|
Workflow [PR], commit [b27ed96] Summary: ✅
AI ReviewSummaryPR #113963 skips Final VerdictStatus: ✅ Approve. |
|
📊 Cloud Performance Report
This PR adds an early exit to ReadFromMergeTree range selection. When a PREWHERE folds to constant false (an empty IN set or a constant-false filter), index analysis is skipped. The check only runs for queries that have a PREWHERE. Only clickbench Q33 (-12.6%) and Q34 (-12.0%) were flagged, and both stay not_sure: they are GROUP BY scans with no PREWHERE or IN subquery, so they never reach the new code. Their roughly 12% gains, and similar CPU drops, line up with a known shift in master's baseline for these queries, so they say nothing about this change. No tpch_adapted_1_official query moved. That is expected, because none of them filter on an empty IN 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)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units1291 translation units recompiled, 9644 s compile time in total, 1291 of them have a recent master baseline. |
Build the folding header from all columns required by the `PREWHERE` actions so automatic parallel-replica estimation can include virtual columns.
|
@groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=113963&sha=e1b13078febf32c8cd0803d0bd4febbdb9662f81&name_0=PR&name_1=Stress%20test%20(amd_debug) and provide a fix in a separate PR. If the fix is already in progress, link it here. |
|
Not caused by your change. The root cause is a From The other 6 queries (5x Why the wait cannot be interrupted: On attribution: No fixing PR exists for this wait today (#97586, #102804 and #113263 each make a different wait cancellable). A fix task owns it at full effort and I will post the PR link in this thread when it opens. |
|
Correcting myself on the last paragraph: there is an in-progress fix to link, and I should have led with it. #113397 (open, @ tiandiwonder) - "Fix a table permanently stuck in the drop queue after a failed materialized-CTE query". That is the other half of the mechanism. The wait I described only fails to return because the inner samples table never actually finishes dropping: Also worth knowing for your PR, since it explains the timing: the onset is #113772 (merged 2026-08-10T07:46:51Z), which force-enables Net for you: nothing to do on this PR. Track #113397; if it merges and the hung check still fires on the |
Automatic `PREWHERE` selection now sees zero pruned parts and leaves the predicate in `WHERE`. Put `PREWHERE` on the distributed read so the test continues to cover the empty-set short circuit.
Match the order of `FilterTransform::prepare`: run `FilterTransform::isAlwaysFalseByEmptySet` first and call `updateHeader` only when it does not fire. Otherwise the dry run of the whole `PREWHERE` DAG could throw during index analysis for a sibling `and` branch that the runtime filter would have short-circuited to zero rows. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 @groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=113963&sha=efa74f5f89af2fa8c284affd0f1c8ad5aa89a08d&name_0=PR&name_1=Performance%20Comparison%20(amd_release%2C%20master_head%2C%205%2F6) and provide a fix in a separate PR. If the fix is already in progress, link it here.
The |
|
Investigated both; neither is a regression in what this PR changes. Performance Comparison (amd_release, master_head, 5/6) fails on one dashboard row, The confirmation rerun reproduced both after a restart, so this build is on the slow level; the run on the new head is a different build. The dashboard scored it Upgrade check (amd_release): the two Of the 17 occurrences since 2026-09-20, 10 are this codec case. The other 7 are not: 3 are the lightweight-update fixture |
Projection analysis calls `selectRangesToRead` with the projection metadata, while `PREWHERE` still refers to the parent table columns, so `StorageSnapshot::getSampleBlockForColumns` threw `NOT_FOUND_COLUMN_IN_BLOCK`. Use the types of the `PREWHERE` DAG inputs instead and drop the storage snapshot plumbing that was only needed for that. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ree` Master made the `indexes` spelling the primary setting name, so `Setting::force_data_skipping_indices` no longer exists. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Dear @yariks5s, you haven't been active on this PR for 30 days. You will be unassigned. Will you continue working on it? If so, please feel free to reassign yourself. |
…here Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01E5v7QTSR65LdYnQEv9HJVu
|
Dear @yariks5s, you haven't been active on this PR for 30 days. You will be unassigned. Will you continue working on it? If so, please feel free to reassign yourself. |
An
IN (subquery)predicate with a ready empty set is already folded to false byFunctionIn. ForMergeTreereads, this happened only after range and data-skipping index analysis, which could spend significant time scanning Bloom-filter indexes even though the query would read no rows.This change re-evaluates the
PREWHEREactions before range selection and returns an empty analysis result when the filter is constant false. Unready sets, includingGLOBAL INsets, remain nonconstant and are not folded prematurely.The regression test verifies that an empty set avoids Bloom-filter analysis while a nonempty set still uses the index. In the focused performance test with two million granules, median client time decreased from 116.4 ms to 1.77 ms, a 65.6× improvement.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Skip
MergeTreerange and data-skipping index analysis when a readyPREWHERE INset is empty.Workflow [PR]
Sync PR [sync-upstream/pr/113963]