Repository navigation
Separate text index analysis from MergeTreeReaderTextIndex - #102255
Conversation
Move Stage 1 of text index analysis (dictionary + small postings reading) to always happen in `filterMarksUsingIndex`, alongside other skip indexes. The pre-computed granule is captured and passed to `MergeTreeReaderTextIndex` so it skips re-reading from streams and goes straight to Stage 2 (large postings reading + virtual column filling). This fixes three problems: - `canSkipMark` is only honored for the first prewhere reader, so multiple text indexes or mixed skip indexes lost mark filtering. - Direct read from text index required `use_skip_indexes_on_data_read = 1`. - Enables future distributed text index analysis. The granule flows through `RangesInDataPartReadHints.index_granules` (Path 1: pre-execution) or `SkipIndexReadResult.index_granules` (Path 2: data-read). Each reader gets a `shallowCopy` of the granule for thread-safe independent `current_range`. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
|
Workflow [PR], commit [ce945bd] Summary: ❌
AI ReviewSummaryThis PR refactors text-index direct-read flow by moving index analysis out of Findings❌ Blockers
Tests
ClickHouse Rules
Final VerdictStatus: Minimum required actions:
|
Just to double check: does this mean that I can set |
Yes, that's correct. |
| } | ||
| } | ||
|
|
||
| void MergeTreeReaderTextIndex::prefetchBeginOfRange(Priority priority) |
There was a problem hiding this comment.
Unfortunately, we have to sacrifice prefetches for now. Maybe I'll add prefetches for skip indexes in the general case later.
Ergus
left a comment
There was a problem hiding this comment.
I only have a question:
For remote-filesystem table policies MergeTreePrefetchedReadPool calls reader->prefetchBeginOfRange(priority) for every prewhere reader before the I/O window opens.
ClickHouse/src/Storages/MergeTree/MergeTreePrefetchedReadPool.cpp
Lines 161 to 163 in 3c6d515
Now every text index read becomes a synchronous, unmasked latency event (because there is not override) Is this intended?
This PR intentionally drops the prefetch on remote filesystems?
Yes, this is intended. Prefetch in the text index only worked for the sparse index file. Now its analysis has been moved to the common code path in I have a prototype of prefetch support for skip indexes in general and will open a PR soon. However, we need to be careful with prefetches of skip indexes, as they can slow down queries. I also want to add prefetches for the text index dictionary later, but that requires a small refactoring. |
LLVM Coverage Report
Changed lines: 97.12% (202/208) | lost baseline coverage: 3 line(s) · Uncovered code |
0e4c1ec
Resolve merge conflicts with PR ClickHouse#102255 (Separate text index analysis from `MergeTreeReaderTextIndex`). Key adaptations for the lazy posting list feature: - Constructor: use master's `MergeTreeIndexGranulePtr` parameter and `initializeFallbackReader` extraction; add lazy mode validation before fallback reader initialization. - `readGranule`: use master's `dynamic_pointer_cast<const MergeTreeIndexGranuleText>` pattern; keep `small_postings_stream` as a class member for lazy cursor handles; retain lazy mode codec validation after deserialization. - `makeLazyCursorHandle`: adapt to use `granule->` direct access instead of `assert_cast`. - `canSkipMark`: removed (per master's refactoring). - `readRows`: follow master's simplified loop structure with conditional `readPostingsIfNeeded` skip for lazy mode. - `fillColumn`: use `granule->` direct access for pattern tokens. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
|
please backport it to 26.2 |
|
@zdyj3170101136 Only bugfixes get backported, this PR is feature work. |
`createReadTasksForTextIndex` added an `IndexReadTask` without columns for every useful text index that is not read directly. The tasks used to keep such indexes out of `MergeTreeSkipIndexReader`, but that exclusion was removed in ClickHouse#102255, and a task without columns never gets a `MergeTreeReaderTextIndex`, because read steps are matched to tasks by column names. The only remaining effect was an empty PREWHERE read step per such index. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Improved analysis of multiple text indexes used simultaneously in the same query. Also, the
use_skip_indexes_on_data_readsetting is no longer required for the direct read optimization of text indexes.Version info
26.4.1.910