Repository navigation
Conversation
The text skip-index condition builder recognized a supported atom (hasToken, equals, LIKE, ...) only as a bare conjunct, not when wrapped in a semantically-equivalent positive boolean comparison, so `hasToken(s, 'x') = true` full-scanned while bare `hasToken(s, 'x')` pruned. traverseAtomNode now looks through `atom = true`, `atom != false`, `isNotDistinctFrom(atom, true)` (both argument orders, including the `IS TRUE` desugaring) and `atom IN (only-truthy-consts)` by recursing into the atom. Only positive wrappers are handled: a positive wrapper selects a row exactly when the atom is true, so the atom's granule mask stays a necessary condition and pruning is sound. Negative wrappers (= false, != true) map to the negated atom, whose NOT-of-a-mask is always can-be-true (no pruning benefit), and are declined. The recursed atom's direct-read mode is forced to None because the wrapper node is not shaped [haystack, needles]; granule pruning is mode-independent, so pruning is fully restored while the bare atom node is still optimized for direct read independently. Closes: ClickHouse#110012 Co-Authored-By: Claude Opus 4.8 <[email protected]>
Pre-PR validation gate (click to expand)
Covered SHA: |
|
@groeneai look at other skip indexes, primary key and partition pruning on these cases. |
|
Workflow [PR], commit [bbd2133] Summary: ❌
|
|
@PedroTadim checked all of them with
Two distinct mechanisms:
Net: this PR (#110024) stays scoped to the text index (separate condition builder). PK/minmax/bloom_filter/partition are covered at the |
index_granularity_bytes = 0 disables adaptive granularity; when CI randomizes min_rows/min_bytes_for_wide_part the server logs a Warning about it, and Fast test (send_logs_level=warning) fails on any stderr. index_granularity = 1 alone already gives one row per granule, so a large non-zero index_granularity_bytes keeps the granule counts stable without the warning. Co-Authored-By: Claude Opus 4.8 <[email protected]>
The negative "no prune" assertions checked that every Granules line reads 128/128. In the merged-with-master Fast test build, primary-key / constant folding prunes hasToken(s,'rare')=false, !=true and =5 independently of the text index, so a Granules line was not 128/128 and the assertions flipped to 0. Assert on the text skip index by name (Name: idx) instead: positive wrappers apply it and prune to one granule, negative and non-boolean wrappers do not apply it. This isolates text-index behavior from unrelated pruning and is stable across randomized settings. Reference unchanged. Co-Authored-By: Claude Opus 4.8 <[email protected]>
…upport nullIn Two review-comment fixes for the positive-boolean-wrapper handling: 1. The wrapper query is stored in None mode (so the wrapper node is not direct-read-rewritten), but TextSearchQuery::getHash includes direct_read_mode, so the bare inner atom -- optimized independently by the direct-read pass in its original mode -- missed the all_search_queries lookup and lost its direct read / hint. Keep the original-mode child query in a new RPNElement::extra_search_queries (registered in all_search_queries, ignored by pruning) so both representations exist. 2. Recognize nullIn / globalNullIn, the forms the analyzer rewrites IN / globalIn to under transform_null_in = 1. The truthy-only set check already rejects NULL members, so the soundness argument is unchanged. Regression cases added: nullIn pruning, IN (true,false) declines under null_in, and the bare/=true/IN(true) direct-read virtual column is present. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Both addressed in ddb3d72. 1. 2. Repro was confirmed both directions on a local build: baseline (4971790) missed the child direct-read column on |
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 100/119 (84.03%) · Uncovered code |
CI finish ledger — ddb3d72CI fully finished (Finish Workflow complete). The earlier Fast-test failure was PR-caused and is fixed on this head (Fast test passes now). The sole remaining failure is a pre-existing flaky test with an owner.
Session id: cron:our-pr-ci-monitor:20260711-030000 |
CI finish ledger — ddb3d72Every 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
Session id: cron:our-pr-ci-monitor:20260711-033000 |
|
Understood, holding this PR. I will not push more code here until the direction on #110012 is settled. Agreed the interesting questions are best answered on the issue: which index types besides text and bloom lack positive-boolean-wrapper look-through today, which functions besides |
CI finish ledger for ea7b0baEvery failure below has an owner. All three are one root cause: this branch no longer compiles against current master.
Root cause: a semantic conflict with master, not a bad mergeThe head commit is a plain At this branch's merge base, PR #109886 ( So:
Why I am not pushing the fixThis PR carries the I have not written the fix yet, only diagnosed it, precisely because the shape of the Session id: cron:clickhouse-maint-slot-13:20260728-234502 |
CI finish ledger - bbd2133Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
147 further jobs dropped behind the build, so this head carries no stateless, integration or fuzzer coverage. Head Session id: cron:our-pr-ci-monitor:20260908-053039 |
|
Dear @ahmadov, 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. |
Closes: #110012
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
The text (full-text) skip index now prunes granules for a supported search predicate even when it is wrapped in a positive boolean comparison, so
hasToken(s, 'x') = true,hasToken(s, 'x') != false,hasToken(s, 'x') IN (true)andhasToken(s, 'x') IS TRUEuse the index like the barehasToken(s, 'x')instead of scanning every granule. Such wrappers are common in SQL generated by BI tools and ORMs.Description
The text skip-index condition builder recognized a supported atom (
hasToken,equals,LIKE, ...) as prunable only as a bare conjunct. When the same atom was wrapped in a semantically-equivalent positive boolean comparison the inner atom node was treated as the index column,header.has()failed, no index condition was built, and the query read every granule. Results were always correct; only pruning was lost.traverseAtomNodenow looks through positive boolean wrappers by recursing into the atom:atom = true/true = atomatom != falseisNotDistinctFrom(atom, true)(this is also the desugaring ofatom IS TRUE)atom IN (only-truthy-consts)Only positive wrappers are handled. A positive wrapper selects a row exactly when the atom is true (under WHERE three-valued logic NULL and false rows are excluded in every case, so this holds for Nullable atoms too), hence the atom's granule mask remains a necessary condition and pruning stays sound. Negative wrappers (
= false,!= true) map to the negated atom, whose NOT-of-a-granule-mask is always can-be-true and gives no pruning benefit, so they are declined. Non-boolean right-hand sides such as= 5are left to row-level evaluation.The recursed atom's direct-read mode is forced to
None: the wrapper node is not shaped[haystack, needles], so the direct-read / preprocessor rewrite (which assumes that shape) must not run on it. Granule pruning is mode-independent (driven by the RPN function type), so pruning is fully restored, and the bare inner atom node is still optimized for direct read independently.Regression test
04365_text_index_positive_boolean_wrapperasserts viaEXPLAIN indexes = 1that every positive wrapper prunes to the same single granule as the bare atom, that negative and non-boolean wrappers do not prune, and that results are unchanged.Repro from the issue: https://fiddle.clickhouse.com/33bc89bf-a740-450a-a1c8-26e7c3c59ba5
Workflow [PR]
Sync PR [sync-upstream/pr/110024]