Skip to content

Do not create a second query condition cache entry when no skip index ran - #116259

Merged
alexey-milovidov merged 8 commits into
ClickHouse:masterfrom
groeneai:qcc-single-entry-when-no-skip-index
Oct 2, 2026
Merged

alexey-milovidov merged 8 commits into
ClickHouse:masterfrom
groeneai:qcc-single-entry-when-no-skip-index

Conversation

@groeneai

@groeneai groeneai commented Aug 25, 2026 •

Copy link
Copy Markdown
Collaborator

Changelog category (leave one):

  • Performance Improvement

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

On a table with no applicable data skipping index, a query no longer stores the same predicate under two query condition cache keys. This halves the number of O(marks per part) cache entries such a query allocates, and removes one cache lookup per part. Queries with distributed_index_analysis enabled keep both keys.

Description

Reported by @ Avogar on #116134, on the #115998 reproducer.

getSkipIndexProfiledConditionHash salts a condition hash with the effective skip-index profile, so skip-index-derived exclusions are only read back by a query that ran the same index set (#108519). It had no early return for an empty effective set, and a SipHash of the bare hash is never the bare hash, so on a table with no secondary index the profiled key was still distinct from the row-level one. Index analysis and the row-level filter then recorded one predicate twice: two zeroed O(marks per part) bitmaps, and two lookups, per part.

The fix returns the bare hash when the effective set is empty, and skips the now-duplicate lookup. This is not a weakening of #108519: with no effective index nothing profile-dependent can have been recorded. The collapse is exact because write only clears bits into an all-true entry while reads AND-merge, so one entry holds the same union of cleared bits as two. distributed_index_analysis is excluded: there a replica runs index analysis on its own metadata while the coordinator keys the result with its own index set, so a locally empty set does not prove no skip index contributed.

Measured on the #115998 shape (10M rows, index_granularity = 8, 5 parts x 250k marks, 1500 point lookups), with the cache sized above the working set so the gauge is not eviction-pinned: 14370 entries / 452.7 MB before, 7500 / 236.3 MB after, i.e. one entry per part and predicate. Wall clock is unchanged at this scale and is not claimed; @ Avogar's figures are his, on another shape.

For a table that does have an applicable skip index nothing changes: both keys are still written and looked up, which the new tests assert. Each fails without its half of the fix.


Workflow [PR]
Sync PR [sync-upstream/pr/116259]

Version info

  • Merged into: 26.10.1.1250-master (included in 26.10 and later)

… ran

getSkipIndexProfiledConditionHash salts a condition hash with the effective
skip-index profile so that skip-index-derived exclusions are only consulted by a
query that ran the same index set (issue ClickHouse#108519). It had no early return for an
empty effective set, and a SipHash of the bare hash is never the bare hash, so on
a table with no secondary index the profiled key was still distinct from the bare
row-level key. Index analysis (ReadFromMergeTree) and the row-level filter
(FilterTransform) then recorded the same predicate under two keys: two zeroed
O(marks per part) bitmaps per part, plus two lookups per part on the read side,
each returning a full bitmap copy.

Return the bare hash when the effective skip-index set is empty, and skip the
lookup that is then a duplicate.

This is not a weakening of issue ClickHouse#108519: with no effective index nothing
profile-dependent can have been recorded, and the exclusions written under that
key can only come from primary-key or partition pruning, for which the row-level
key is already sound. The collapse is exact because write only ever clears bits
into an all-true entry while reads AND-merge, so one key holds the same union of
cleared bits as two. That is a dependency worth stating: if a future change ever
sets a matching_marks bit back to true, the collapse stops being equivalent.

distributed_index_analysis is excluded, because there each replica runs index
analysis on its own metadata (StorageMergeTreeAnalyzeIndexes) while the
coordinator keys the ranges it gets back with its own index set, so a locally
empty set is no evidence that no skip index contributed. Its activation gate can
fire on a table with no secondary index because get_indexes_size also counts the
primary-key index.

The single helper serves all three call sites (one write, two reads), so write
and read keys move together and cannot diverge. UsefulSkipIndexes::empty() is
used rather than useful_indices.empty() because a TopK-filtering index also makes
the set non-empty. No use_skip_indexes conjunct is needed: buildIndexes returns
before populating skip_indexes when that setting is off.

Measured on the issue ClickHouse#115998 shape (10M rows, index_granularity = 8, five parts
of 250k marks, 1500 independent point lookups), with the cache sized above the
working set so the entry gauge is not eviction-pinned: 14370 entries / 452.7 MB
before, 7500 / 236.3 MB after, i.e. one entry per part and predicate. Wall clock
is unchanged at that fixture scale and is not claimed.

Reported by Avogar on pull request ClickHouse#116134.

Related: ClickHouse#115998
Review round 1: both new-test oracles could pass for the wrong reason.

The entry test asserted only that the collapsed entry kept at least one
matching granule. Recomputing the two pre-fix bitmaps shows the survivor
must keep exactly 2 granules, while the profiled-key-only state keeps 25
and the bare-key-only state 27, so the boolean form passed in all three
and could not detect loss of the row-level writer. It now asserts the
exact count. Demonstrated by dropping the max_block_size line, which
takes the count to 25 while the old form still passed.

Nothing pinned the read side at all. Reverting only the guard that skips
the duplicate lookup changes no ProfileEvent: the two keys are equal, so
the second lookup returns the same entry, merges idempotently, and the
one hit per consultation is counted by the caller rather than per key.
QueryConditionCache::read does emit one TEST-level line per key looked
up, and send_logs_level ships those to the client independently of the
server log level, so a second test counts them per part: one with no
effective skip index, two when one really ran. Verified against a build
with only that guard reverted, which reddens the new test alone and
leaves the entry test green. Counting hits and misses together makes the
number independent of cache state, so this test needs no cache drop and
no no-parallel tag.

Also scope the entry test's SYSTEM FLUSH LOGS to query_log, which the
style check requires, and record on the no-parallel tag that the last
check is what needs it, since every count is already table_uuid-scoped.

No source change in this round.
Review round 2. Both new tests assert cache entry and lookup counts, and
filterPartsByQueryConditionCache returns before any cache access unless
allow_experimental_analyzer is set, so with the old analyzer every count
is zero. The stateless job that carries the "old analyzer" option
installs allow_experimental_analyzer = 0 in the server's default profile,
which makes both tests fail there rather than merely lose coverage:
measured on an old-analyzer server, the lookup test reads 0 against a
reference of 1 then 2.

Tag both no-old-analyzer. That states what is true, namely that the
behaviour under test does not exist without the analyzer, whereas
setting allow_experimental_analyzer inside the tests would run the new
code path on a job whose purpose is to exercise the old one.

Verified on one binary against two servers: the tests pass unchanged
with the analyzer on, skip with reason old-analyzer with it off, and
fail with it off once the tag is removed.

Earlier rounds pinned every setting the test runner randomizes, which
does not cover a job flavour that installs a different default in the
server profile.

No source change in this round.
@groeneai groeneai added can be tested Allows running workflows for external contributors groeneai-origin-follow-up PR origin: groeneai's own out-of-scope finding during its PR work labels Aug 25, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author
Internal second-model review (3 rounds, 6 findings, all resolved)

I reviewed this cold myself and had an independent model review it, three times. Six
findings, all resolved. No correctness finding was raised against the source change by
either pass in any round: it has been byte-identical since round 1. Every fix went into
the tests, because in their first form they could not have caught a regression.

# Finding Verdict
❌ The entry-count arm could not detect loss of the row-level producer: countMatches(marks,'1') > 0 reads 1 whether one producer wrote or both, so the arm stopped testing the collapse silently. AGREE, fixed - strengthened to the exact count, which discriminates all three states (both producers 2, index analysis only 25, row-level only 27), with a negative control confirming it reddens when the row-level producer cannot fire
❌ Nothing pinned the read side: per-probe profile events are suppressed and one hit is reported per consultation, so restoring the redundant lookup left every observed value unchanged. AGREE, fixed - added ..._single_lookup.sh, counting the cache's own test-level lookup lines per part (1 unindexed, 2 indexed), verified against a mutant that forces the redundant probe back on. It reddens the new test only, which also shows the two halves are separate holes
❌ Neither test pinned the analyzer. filterPartsByQueryConditionCache returns before any lookup when the analyzer is off, so both tests would have FAILED the old analyzer stateless job, not merely lost coverage. AGREE, fixed - tagged no-old-analyzer on both, and demonstrated: skipped with reason old-analyzer on an old-analyzer server, failing there once the tag is removed
⚠️ The changelog described the collapse without noting that distributed_index_analysis deliberately keeps both keys. AGREE, fixed - qualified
💡 The no-parallel tag was justified by the entry counting, which is already scoped by table UUID; the load-bearing reason is the cross-query assertions a concurrent cache drop can flip. AGREE, fixed - reworded
💡 distributed_index_analysis is threaded as a trailing argument to the salt helper rather than carried in Indexes. DISAGREE - the desynchronization is unreachable: indexes is built once per query, the read function has a single caller passing the same context, and all three call sites read the same settings reference. Moving it widens the diff for no behaviour change

I also declined one requested remedy while agreeing with the finding behind it: adding a
ProfileEvent inside QueryConditionCache::read as the oracle for the second row. That
function is deliberately untouched here; counting the log lines proves the same thing
without changing cache code, and it works in release builds too.

Verified independently during the cold reviews: the collapse is exact because write only
ever clears bits into an all-true entry while reads AND-merge; the write site and both
read sites cannot salt differently; #108519's partition is preserved because every scenario
there leaves a non-empty effective index set; and the distributed_index_analysis
exclusion is necessary because a replica analyses its own metadata while the coordinator
keys the result with its own index set.

@clickhouse-gh clickhouse-gh Bot closed this Aug 25, 2026
@clickhouse-gh clickhouse-gh Bot reopened this Aug 25, 2026
@clickhouse-gh

clickhouse-gh Bot commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [08aa036]

Summary: ✅


AI Review

Summary

This PR collapses the skip-index-profiled query-condition-cache key onto the bare condition hash when no effective skip index ran, and skips the redundant read-side probe. I did not find a source-level correctness issue in that change, but one regression-test gap remains.

Findings

⚠️ Majors

  • [tests/queries/0_stateless/04652_query_condition_cache_no_skip_index_single_entry.sql:1] and [tests/queries/0_stateless/04652_query_condition_cache_no_skip_index_single_lookup.sh:2] The new tests still run in the old-analyzer stateless lane even though the query condition cache is analyzer-only. In that lane filterPartsByQueryConditionCache returns before any lookup/write, so the cache stays empty and these checks stop exercising the new behavior. Restore no-old-analyzer on both tests, or explicitly force enable_analyzer = 1 / --enable_analyzer=1.
Final Verdict

⚠️ Needs changes before merge: fix the analyzer guard on the two new regression tests.

LLVM Coverage Report

⚠️ No coverage measurement for commit 08aa036: incomplete coverage measurement: 1 of 21 shard profiles are missing: LLVM_COVERAGE_FILE_it_4.profdata.

@clickhouse-gh clickhouse-gh Bot added the pr-performance Pull request with some performance improvements label Aug 25, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. SELECT sum(b) FROM tab WHERE a > 1200 AND b = 7 on a 2-part unindexed table with index_granularity = 8, max_block_size = 8, PREWHERE off. 5/5 runs fail before the change, 50/50 randomized runs pass after it. Not a probabilistic repro.
b Root cause explained? getSkipIndexProfiledConditionHash had no early return for an empty effective skip-index set, and a SipHash of the bare hash is never the bare hash, so the profiled key stayed distinct from the row-level key on a table with no secondary index. Index analysis and the row-level filter then recorded one predicate under two keys: two zeroed O(marks per part) bitmaps and two lookups per part.
c Fix matches root cause? Yes. The early return sits where the redundant key is produced, not as a guard at the allocation site. QueryConditionCache::write / read / Entry / EntryWeight are untouched.
d Test intent preserved / new tests added? No existing test changed. Two new tests, one per half of the fix: 04652_query_condition_cache_no_skip_index_single_entry counts cache entries (write side) and 04652_query_condition_cache_no_skip_index_single_lookup counts cache lookups (read side). Both carry a contrast arm on an indexed table, and the entry test also carries a distributed_index_analysis arm, so the guard cannot be widened later without reddening. Both are tagged no-old-analyzer: the old analyzer returns before any cache lookup, so there is nothing to assert there, and without the tag both would fail the old-analyzer stateless job.
e Both directions demonstrated? Yes, and each test was separately shown to fail without its own half of the fix. Entries per part: 2 before, 1 after; matching granules in the surviving entry 27 before, 2 after, which is what pins that both writers contributed. Lookups per part: 2 before, 1 after, and reverting only the read-side guard reddens that test alone while the entry test stays green. The contrast arms read 2 on every binary. Results identical on every arm.
f Fix is general across code paths? All three call sites (1 write in ReadFromMergeTree, 2 reads in MergeTreeDataSelectExecutor) go through the one helper, so write and read keys cannot diverge. The other 5 write and 3 read callers already use the bare hash. Uses UsefulSkipIndexes::empty(), which tests both useful_indices and skip_index_for_top_k_filtering. No use_skip_indexes conjunct is needed: buildIndexes returns before populating skip_indexes when the setting is off.
g Fix generalizes across inputs (params/datatypes/wrappers)? No column or type code is touched, so type wrappers do not apply. Exercised matrix: use_skip_indexes 0/1, use_skip_indexes_for_disjunctions 0/1, distributed_index_analysis 0/1, PREWHERE on/off, indexed vs unindexed table, and the TopK key pair via the existing *_topk_* tests.
h Backward compatible? (maintainer-approved exception only) Yes. No new setting and no default change, so no SettingsChangesHistory entry; no serialization or on-disk format change. One user-visible effect, stated in the description: for unindexed tables system.query_condition_cache shows one row per (part, predicate) instead of two, and the survivor's matching_marks is the AND of the two it replaces (verified bit for bit).
i Invariants and contracts preserved? The invariant is that skip-index-derived exclusions are only read by a query that ran the same effective index set, and that a mark is reported skippable only if some completed write said so. The guard fires only on an empty effective set, where no index can have contributed; write only clears bits into an all-true entry while reads AND-merge, so one key holds the same union of cleared bits as two; distributed_index_analysis is excluded because there the coordinator can store a remote replica's index-derived ranges under its own index set. Hit and miss accounting is unchanged: one logical consultation is counted across all probes, the merge is idempotent, and the test asserts one hit per part with zero misses on the warm run.

Session id: cron:clickhouse-impl-slot-6:20260825-071100

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @tiandiwonder @CurtizJ, could you review this? getSkipIndexProfiledConditionHash had no early return for an empty effective skip-index set, and a SipHash of the bare hash is never the bare hash, so on a table with no secondary index index analysis and the row-level filter recorded the same predicate under two query condition cache keys, allocating two zeroed O(marks per part) bitmaps and probing twice per part where one suffices.

@clickhouse-gh

clickhouse-gh Bot commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 08aa0361e with master e2d4beb57 (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Compile time of recompiled translation units

70 translation units recompiled, 867 s compile time in total, 70 of them have a recent master baseline.

Median compile-time ratio to the baselines is ×1.06 (machine-speed difference or a change affecting every TU); per-TU deltas below are relative to that ratio.
The matched translation units cost +48.8 s (+6%) in total before that adjustment.

Job report

@clickhouse-gh

clickhouse-gh Bot commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

📊 Cloud Performance Report

⚠️ AI verdict: not_sure — 2 query(s) improved out of 37 analysed

Release-transition baseline: compared against the most recent available 26.9 masters at or before the trusted base-commit anchor because no 26.10 master baseline exists there.

This PR skips the second, redundant query condition cache lookup on tables with no effective skip index. That only changes filtered reads, and saving one lookup per part costs microseconds. Most flagged improvements are GROUP BY queries with no WHERE clause (Q16, Q18, Q32, Q33, Q34) that never touch the cache, so they and Q31 are downgraded to not sure. Q32 (-47.5%) cannot be overridden because its delta is so large, but it too is off-path and is most likely a baseline difference (the PR build reports 26.10, the baseline 26.9). Q23 (-41.9%) does run the changed lookup, but the gain is far larger than the change explains and master has been trending on that query recently, so treat it with caution.

clickbench

🟢 2 improved · ⚠️ 5 inconclusive

Flagged queries (7 of 43)
Query Verdict Baseline median (ms) PR median (ms) Change q-value Hint
🟢 23 improvement 86 50 -41.9% <0.0001 cache: Q23 filters on URL LIKE and uses ORDER BY LIMIT, so it does run the changed condition-cache lookup. Saving one lookup per part is far smaller than the -41.9% measured, and the recent master trend with noisy base timings makes the size unreliable.
🟢 32 improvement 1376 723 -47.5% <0.0001 aggregation: The delta is large and clear enough that this verdict is locked. Q32 has no WHERE clause and never runs the changed condition-cache code, so the -47.5% most likely comes from other code differences between the PR build and the baseline.
⚠️ 16 not_sure 628 547 -12.9% <0.0001 aggregation: Q16 is a GROUP BY UserID, SearchPhrase with no WHERE clause, so it never looks up the query condition cache this PR changes. The -12.9% belongs to a group of aggregation-heavy improvements that the diff does not explain.
⚠️ 18 not_sure 1101 874 -20.6% <0.0001 aggregation: Q18 is a large three-key GROUP BY with no filter, so the condition-cache lookup change never runs. The -20.6% cannot come from this diff.
⚠️ 31 not_sure 309 267 -13.6% <0.0001 aggregation: Q31 has a WHERE clause, but one fewer cache lookup per part cannot save 42 ms. It matches the Q32 GROUP BY WatchID, ClientIP gain, which happens without any filter.
⚠️ 33 not_sure 1256 1141 -9.1% <0.0001 aggregation: Q33 is a GROUP BY URL with no filter, so the query condition cache is never used. The -9.1% is off the path this PR changes.
⚠️ 34 not_sure 1259 1129 -10.3% <0.0001 aggregation: Q34 is a GROUP BY 1, URL with no filter, the twin of Q33. It shows the same -10.3% shift on a path the diff does not touch.

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
  • StressHouse run: fb3c6d4d-5219-4dd4-995e-a1c57544b7f9
  • MIRAI run: 8f1b2339-b426-4f8b-a94b-010ee2f644d1
  • PR check IDs:
    • clickbench_2246926_1790610361
    • clickbench_2246932_1790610361
    • clickbench_2246940_1790610361
    • tpch_adapted_1_official_2246949_1790610361
    • tpch_adapted_1_official_2246983_1790610361
    • tpch_adapted_1_official_2246997_1790610361

…A check overclaiming

The lookup counter piped the client's stderr straight into grep, so the pipeline's
status came from grep and a query that threw after emitting some lookup lines still
produced the expected number. Measured: with max_rows_to_read = 1 the query fails
with TOO_MANY_ROWS after both lookups are logged, and the arm still read 1. The
client's status is now checked before the lines are counted, and a failure prints the
exception instead of a count.

The distributed_index_analysis check ran on a two-part table with the default
activation thresholds, so remote analysis never started: DistributedIndexAnalysisMicroseconds
was 0 and no replica was scheduled. It does pin something real, and dropping the
setting from the guard makes it fail, but that is the key being salted from the raw
session setting, not the remote-analysis path its label claimed. Lowering the
thresholds and pointing the query at a reachable replica cluster does start remote
analysis, and the entry count is identical either way, so the heavier fixture would
add no coverage. The label and a comment now say what the check observes.
@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger c8932d6

Every failure below has an owner: a fixing PR (ours or external), or a full-effort fix task
whose fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
AST fuzzer (amd_debug, targeted) / GroupingAggregatedTransform pushed bucket 8 twice pre-existing trunk logical error in memory-efficient distributed aggregation, reached through a fuzzed clusterAllReplicas(view(...)) window query; survives both merged fixes for this family a fix task is created (investigating at full effort, fixing-PR link to follow here)
AST fuzzer (amd_debug, targeted, old_compatibility) / GroupingAggregatedTransform pushed bucket 0 twice (STID 3994-4c1d) same signature on the old-compatibility arm, cluster(view(...)) with GROUP BY GROUPING SETS; 30d breadth 4 distinct PRs, this PR's diff touches neither aggregation nor the distributed path a fix task is created (investigating at full effort, fixing-PR link to follow here)

Session id: cron:our-pr-ci-monitor:20260825-170000

groeneai added a commit to groeneai/ClickHouse that referenced this pull request Aug 26, 2026
…OUPING SETS

The memory-bound-only group only asserted that tokens are absent, so an
implementation that declined the aggregation rewrite for that setting combination
would have satisfied it: it has neither `by hash(` nor a memory-efficient merge.
Two rows now name the strategy positively, as the group above already does.
Measured on `distributed_aggregation_memory_efficient = 0,
enable_memory_bound_merging_of_aggregation_results = 1`: `Aggregating (partial)`
and `MergingAggregated (merge)` are 2 on this branch and 0 on a build with the
guard removed, where `by hash(` is 2 instead.

The comment on the `serialize_query_plan = 1` row now says that it pins the
outcome rather than the strategy. No explain observes a rewrite made on the shard
side: `EXPLAIN PLAN distributed = 1` prints the plan as it was shipped, and
`EXPLAIN PIPELINE distributed = 1` throws `NOT_IMPLEMENTED` with
`serialize_query_plan = 1` (`ReadFromRemote.cpp:990`). The row is still specific
to this defect: with the guard removed it fails with "pushed bucket N twice".

`GROUPING SETS` in the guard comment is now inline code, as `AGENTS.md` requires
for literal SQL names. An earlier round of this branch declined that same request
on the grounds that no such repository rule exists; that was wrong, the rule is at
`.claude/CLAUDE.md:7` and predates this branch. The same round declined the
request to put the supplied report URL in the commit message, and that was wrong
too, for the same reason: `.claude/CLAUDE.md:169`. Both links, per that rule:

Failing check this commit answers:
https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=116446&sha=c5ac60fd8dcd6e81e274126b140fb9828bbb54e5&name_0=PR&name_1=Stateless%20tests%20%28amd_asan_ubsan%2C%20distributed%20plan%2C%20parallel%2C%20selected%20tests%29
ClickHouse#116446

Report the fix was written for:
https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=116259&sha=2e55a2277e66c6762e444c2cb6dc18a585cbfc5b&name_0=PR&name_1=AST%20fuzzer%20%28amd_debug%2C%20targeted%29
ClickHouse#116259

Validation: 40/40 with the promise settings, `serialize_query_plan`,
`prefer_localhost_replica`, `optimize_aggregation_in_order` and `max_threads`
randomized; the guard-removed build reddens the file in both
`serialize_query_plan` modes, on a fresh server per arm.
groeneai added a commit to groeneai/ClickHouse that referenced this pull request Aug 26, 2026
`enable_memory_bound_merging_of_aggregation_results` is randomized by the runner
(`tests/clickhouse-test:1597`) and every arm that set only
`distributed_aggregation_memory_efficient = 1` left it open, so those arms did not
say which of the two settings they exercised, and a guard tied only to the
randomized one could pass. It is pinned in the session block now, and the two
promise sources have an arm each: `(1, 0)` and `(0, 1)`, each asserting the whole
demoted shape in one row (no shuffle, plus the partial aggregation and its merge)
so a plan left undistributed does not satisfy them.

Measured standalone on those two combinations: both rows are 1 on this branch and
0 on a build with the guard removed, where `by hash(` is 2 instead. The four rows
they replace are folded into them, so the truth table is now `(0,0)` keeps the
shuffle and `(1,0)`, `(0,1)`, `(1,1)` demote.

Report this branch is fixing, per `AGENTS.md`:
https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=116259&sha=2e55a2277e66c6762e444c2cb6dc18a585cbfc5b&name_0=PR&name_1=AST%20fuzzer%20%28amd_debug%2C%20targeted%29
ClickHouse#116259

Validation: 40/40 with both promise settings, `serialize_query_plan`,
`distributed_plan_force_shuffle_aggregation`, `prefer_localhost_replica`,
`optimize_aggregation_in_order` and `max_threads` randomized; the guard-removed
build reddens the file in both `serialize_query_plan` modes, one fresh server per
arm.
groeneai added a commit to groeneai/ClickHouse that referenced this pull request Aug 26, 2026
Measured against a build whose aggregation rewrite returns without transforming
the step: the row passes in both `serialize_query_plan` modes, so it does not
separate the demotion from an aggregation left unrewritten above the gather. The
rows above separate the two, and they can only do it when the plan is not shipped,
which the comment now says.

Report this branch is fixing, per `AGENTS.md`:
https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=116259&sha=2e55a2277e66c6762e444c2cb6dc18a585cbfc5b&name_0=PR&name_1=AST%20fuzzer%20%28amd_debug%2C%20targeted%29
ClickHouse#116259
@clickhouse-gh clickhouse-gh Bot added the comp-mergetree MergeTree* family: parts, merges, primary index, column statistics, background data transformation. label Sep 4, 2026
groeneai and others added 3 commits September 28, 2026 12:25
…en-no-skip-index

# Conflicts:
#	src/Storages/MergeTree/MergeTreeDataSelectExecutor.cpp
…yzer tag

The comment on the early return in getSkipIndexProfiledConditionHash now
states only the two invariants a reader needs there: with no effective skip
index no exclusion depends on the index profile, and that does not hold under
distributed_index_analysis. The note on why a second probe of an identical key
is skipped, and the sentence added to the filterPartsByQueryConditionCache
overview, described this change rather than the code, so they are removed.

master removed the old-analyzer test mode and the `no-old-analyzer` tag in
182a59e, so both tests stop carrying it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
`SET max_block_size = 8` is needed so the row-level writer sees whole
granules, but it stayed in effect for the final `system.query_log` scan,
which reads every other test's queries too. Measured on a 43k-row query_log:
~162 ms of user CPU per scan at 8-row blocks against ~16 ms at the default,
and the cost grows with the log. Reset it before the scan, as
05078_external_distinct_equality does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai
groeneai requested a review from Avogar September 28, 2026 13:29
@alexey-milovidov alexey-milovidov self-assigned this Oct 1, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Oct 1, 2026
Merged via the queue into ClickHouse:master with commit 35a35bc Oct 2, 2026
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors comp-mergetree MergeTree* family: parts, merges, primary index, column statistics, background data transformation. groeneai-origin-follow-up PR origin: groeneai's own out-of-scope finding during its PR work pr-performance Pull request with some performance improvements pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants