Skip to content

Push down current mark ranges to text index analyzer - #108114

Merged
CurtizJ merged 13 commits into
ClickHouse:masterfrom
CurtizJ:text-index-analyzer-ranges
Jun 25, 2026
Merged

CurtizJ merged 13 commits into
ClickHouse:masterfrom
CurtizJ:text-index-analyzer-ranges

Conversation

@CurtizJ

@CurtizJ CurtizJ commented Jun 22, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Performance Improvement

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

Improved performance of text-search queries combined with a primary key filter.

Version info

  • Merged into: 26.7.1.76

@clickhouse-gh

clickhouse-gh Bot commented Jun 22, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [131bca3]

Summary: ❌

job_name test_name status info comment
Stateless tests (amd_tsan, s3 storage, parallel, 2/2) DROPPED IGNORED

AI Review

Summary

This PR pushes primary-key and prior skip-index readable ranges into the text-index analyzer so token and posting analysis can skip impossible rows. The pure token paths are covered, but a dismissed LIKE/ILIKE pattern-query gap remains in the changed analyzer path, so I'm requesting changes.

Findings

⚠️ Majors

  • [src/Storages/MergeTree/TextIndexAnalyzer.cpp:97] [dismissed by author -- https://github.com/Push down current mark ranges to text index analyzer #108114#discussion_r3470738275] Pattern-only Any queries still have no final "no contributing token" state. When a LIKE/ILIKE token overlaps the PK-readable rows at the coarse TokenPostingsInfo::ranges span, addTokenInfo sets rows_range; if addPostings later clips exact postings to empty, this branch erases the token but skips the failure path because query->patterns is non-empty. hasAnyTokensImpl then sees the stale rows_range and keeps the selected marks even though no discovered token has a readable row, so the PR's readable-range pushdown remains ineffective for that pattern path.
    Suggested fix: clear or rebuild the removed token's range contribution, or finalize pattern queries after dictionary/posting analysis and call markFailed when no discovered token remains.
Tests
  • ⚠️ Add a focused LIKE/ILIKE regression selecting a primary-key gap between token occurrences where the coarse token span overlaps but clipped postings are empty; assert the text index prunes the gap, for example through read_rows = 0 or TextIndexReadPostings.
Final Verdict

Status: ⚠️ Request changes

Minimum required action: handle pattern-only Any queries with no remaining contributing dynamic tokens, or make the pattern-query path explicitly conservative without leaving stale range state behind.

@clickhouse-gh clickhouse-gh Bot added the pr-performance Pull request with some performance improvements label Jun 22, 2026
@ahmadov ahmadov self-assigned this Jun 22, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jun 22, 2026 •

Copy link
Copy Markdown
Contributor

📊 Cloud Performance Report

✅ AI verdict: no_change — no significant changes across 38 queries analysed

This PR scopes entirely to the full-text (text) skip-index path: it pushes still-readable row ranges into the TextIndexAnalyzer so 'All'/'Any' token queries can prune posting-list reads and short-circuit the dictionary scan. ClickBench Q4 is COUNT(DISTINCT UserID), which uses no text index and never enters the modified code, so the flagged -16.09% improvement (219ms vs 261ms) cannot be attributed to this change and is treated as run-to-run variance. Downgraded to not-sure; no other queries regressed or improved.

clickbench

⚠️ 1 inconclusive

Flagged queries (1 of 43)
Query Verdict Baseline median (ms) PR median (ms) Change q-value Hint
⚠️ 4 not_sure 261 219 -16.1% <0.0001 aggregation: Q4 is COUNT(DISTINCT); PR only touches text/full-text index posting reads. Off-path, so -16% is run-to-run variance.

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: 20af4bcd-4792-464d-859b-99219d985741
  • MIRAI run: a1585cf0-0644-4d58-903a-b39500ec9757
  • PR check IDs:
    • clickbench_36186_1782390092
    • clickbench_36200_1782390093
    • clickbench_36206_1782390093
    • tpch_adapted_1_official_36213_1782390093
    • tpch_adapted_1_official_36224_1782390093
    • tpch_adapted_1_official_36234_1782390093

@ahmadov ahmadov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@CurtizJ
CurtizJ force-pushed the text-index-analyzer-ranges branch from f04dc9c to 8e9083e Compare June 23, 2026 22:24
@clickhouse-gh

clickhouse-gh Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 85.30% 85.40% +0.10%
Functions 92.60% 92.60% +0.00%
Branches 77.50% 77.50% +0.00%

Changed lines: Changed C/C++ lines covered by tests: 134/143 (93.71%) | Lost baseline coverage (was covered on master, now uncovered in this PR): 1 line(s) · Uncovered code

Full report · Diff report

@CurtizJ
CurtizJ added this pull request to the merge queue Jun 25, 2026
Merged via the queue into ClickHouse:master with commit ffc0fe9 Jun 25, 2026
165 of 167 checks passed
@CurtizJ
CurtizJ deleted the text-index-analyzer-ranges branch June 25, 2026 16:55
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label Jun 25, 2026
CurtizJ added a commit that referenced this pull request Jul 21, 2026
Resolve cherry-pick conflicts for #109886 (Optimize text index analysis).
The release branch does not contain #108114 (`num_live_tokens` / better
discarding of `Any` text queries), so the conflicts are resolved by keeping
26.6's logic and applying only #109886's changes: the field->getter refactor
of `TextSearchQuery`, the precomputed hash, and the result-column memory
reservation in `MergeTreeReaderTextIndex`.

The `02346_text_index_bug90778` reference is updated for the fixed virtual
column name hash (the old name was a double-finalized `SipHash` accident);
the `equals` query uses `direct_read_mode = Exact` on 26.6, giving the hash
`55ee63b12fbf5cb6a7510c6b2df99282`.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…-ranges

Push down current mark ranges to text index analyzer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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