Repository navigation
Conversation
A text index virtual column whose tokens the index analysis folded completely (every posting list is one block) is now skipped in the per-mark loop of `readRows` and filled once for all rows of the read from the folded postings, in both `materialize` and `lazy` modes. The `lazy` direct fill from folded postings becomes unreachable and is removed. The new ProfileEvent `TextIndexFilledFromFoldedPostings` counts these fills. Based on the analysis and patch by @ snelheidai, ClickHouse#122557 (issuecomment-5887340898). Co-Authored-By: Claude Opus 5.5 <[email protected]>
The stateless test compares direct read with evaluation without the index over single-block posting lists: dense and sparse tokens, reads of one granule and of many, reverse order, several parts, lazy mode, arrays and a multi-block control, and checks `TextIndexFilledFromFoldedPostings` so the new path is known to run. The performance test covers dense, sparse and `pfor` searches on parts of about 910000 rows. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Remove three comments that restate the code or the getFoldedPostings contract, and the duplicate pointer in buildPostingsForMark. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Internal second-model review: adjudication log (click to expand)Pre-publication review by an independent model (engine: codex; 0 findings) plus my own review (3 nits).
Severity: 💡 nit. Session id: cron:clickhouse-review-slot-9:20260929-134300 |
|
Workflow [PR], commit [63c3809] Summary: ✅
AI ReviewSummaryThis PR fills text-index virtual columns once per contiguous read when the analyzer has fully folded the required posting lists, while preserving the existing lazy, phrase, and fallback paths. The current diff has no actionable findings; the reported measurements support the performance claim. Missing context / blind spots
Final VerdictStatus: ✅ Approve. No code changes requested; normal CI requirements still apply. |
Build profile diff (arm_release)Commit See the job log for details. |
|
📊 Cloud Performance Report ✅ AI verdict: This PR changes only the text index reader: when the posting lists folded during index analysis fully answer the search, it fills the virtual column for all rows of a read at once, instead of building posting lists for every granule. It also adds a profile event and new tests. None of the five flagged improvements (ClickBench Q18, Q33, Q34 and TPC-H Q1, Q7, between -10.5% and -21.8%) touch a text index, every PR median is inside master's recent range, and all five queries are historically noisy, so all five are downgraded to not sure. The benefit this PR targets should show up in the new text_index_single_block_postings performance test, not in ClickBench or TPC-H. clickbenchFlagged queries (3 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_officialFlagged queries (2 of 22)
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. Debug info
|
Co-Authored-By: Claude Opus 5.5 <[email protected]>
CI finish ledger - b6660aaEvery failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
146 of 149 check runs passed or were not selected, Session id: cron:our-pr-ci-monitor:20260929-183205 |
# Conflicts: # src/Common/ProfileEvents.cpp # src/Storages/MergeTree/MergeTreeReaderTextIndex.cpp # src/Storages/MergeTree/MergeTreeReaderTextIndex.h
| @@ -0,0 +1,41 @@ | |||
| <test> | |||
| <settings> | |||
There was a problem hiding this comment.
let's use substitutions to get rid of duplication.
<substitutions>
<substitution>
<name>codec</name>
<values>
<value>none</value>
<value>pfor</value>
</values>
</substitution>
</substitutions>There was a problem hiding this comment.
Done in 63c3809: both tables now come from one codec substitution.
| @@ -0,0 +1,188 @@ | |||
| -- { echo } | |||
There was a problem hiding this comment.
let's not echo the whole SQL queries into the reference. Instead group relevant SELECT queries under a title by SELECT '....'; Keep the titles brief and short.
There was a problem hiding this comment.
Done in 63c3809: the queries are no longer echoed, and the results are grouped under short SELECT '...' titles.
|
|
||
| const PostingList * MergeTreeReaderTextIndex::getFoldedPostings(size_t column_idx) const | ||
| { | ||
| if (is_always_true[column_idx] || use_fallback[column_idx]) |
There was a problem hiding this comment.
we should add check for use_lazy_mode here as well.
There was a problem hiding this comment.
Done in 63c3809: lazy mode keeps its cursor path for folded postings, and the test now expects the new profile event to stay 0 there (so the pfor arm of the perf test, lazy by default, is an unchanged control).
Lazy mode fills a fully folded column from the cursor over the flattened postings, shared by the readers of the granule, so the fill once per read now applies outside lazy mode only. The perf test runs both codecs through a substitution, and the stateless test prints short titles instead of echoing the queries. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…-intersect-per-container Master builds `range_posting` lazily in `buildPostingsForMark` and skips columns answered by the analyzer's folded postings (ClickHouse#122896); the per-container path only runs when postings must still be read, so it is disjoint from the folded one. `setIndexGranule` keeps only the reset of `intersection_steps`: master moved the per-granule phrase results into `phrase_streams` (ClickHouse#118885) and dropped `blocked_positions_scratch`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…n they need validation `getFoldedPostings`, added on `master` by ClickHouse#122896, fills a virtual column from the postings folded during index analysis. It did not know two properties of `jsonPathValues` queries: - A prefix lookup (`startsWith`, `LIKE 'abc%'`, key existence) has neither tokens nor patterns: its tokens are collected from the dictionary by `pattern_token_prefixes`. Such a query was answered with empty postings, so it matched no row. - A query with dynamic fallback (e.g. `endsWith` over truncated values) has folded postings that also hold the candidate rows that still have to be validated on the column. They were taken as the result, so unvalidated rows matched. Check `hasPatternLookup` as `classifyVirtualColumns` and `buildPostingsForMark` already do, and do not use folded postings for columns with dynamic fallback. Fixes the `Fast test` failures of `04839_json_path_values_core`, `04840_json_path_values_dynamic`, `04841_json_path_values_patterns`, `04842_json_path_values_collections`, `04856_json_path_values_subcolumns` and `04866_json_path_values_regressions`. https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=114613&sha=df313397ce1ec1fa96b1c82f0ad3e87768aed83b&name_0=PR&name_1=Fast%20test ClickHouse#114613 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01E5v7QTSR65LdYnQEv9HJVu
Related: #122557
Related: #122597
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Text index direct read is faster for token searches whose tokens each match at most
text_index_posting_list_block_sizerows in a part (with the defaults, every token search on parts of up to about one million rows), outside thelazyposting list apply mode: the result column is filled once for all rows of a read from the posting list built during the index analysis, instead of once per granule.Description
When the index analysis has read the whole posting list of every token of a search (each list is one block), the text index reader still clipped that per-part list to every granule, flattened and scattered it, although one read covers a run of granules. Such columns are now skipped in the per-granule loop and filled once per read. The
lazymode, the default for compressed posting lists, keeps its cursor over the flattened postings. Multi-block tokens, phrase and fallback searches keep the current code. The new profile eventTextIndexFilledFromFoldedPostingscounts the fills. Based on the analysis and patch by @ snelheidai.On x86 release builds, against an A/A control, searches on 8192-row granules run 3-7% faster at one thread with 32-63% less text index read time, and index-bound reads of a 10M-row part 22-38% faster. On 1M-row granules a read is one granule, so the work is unchanged; unchanged paths stay within the noise. Peak memory grows by up to 0.75 MiB at four threads on 8192-row granules (the row id buffer now spans a read), and not at one thread.
A new test compares with evaluation without the index (dense and sparse tokens, reads of one granule and of many, reverse order, several parts, lazy mode, arrays, a multi-block control) and checks the event; a sweep of 1386 predicate and setting combinations over three codecs matched master.
A window-wise bit expansion on top (the posted patch's fill) cut up to another 47% of read time and about 4 MiB at four threads on 1M-row granules, but was 4-13% slower where a token matches about 8% of rows and up to 54% slower to read isolated granules, so it is not included.
Independent of #122597: the two change disjoint paths.
Measurements
Crossover effect FIX/BASE over 20 paired rounds, postings cache off; "within" = inside the A/A noise.
count(), sum(ts),hasToken(msg, 'ERROR')(25%), 11 parts of 1.8M rows, 8192-row granulescount(), same searchcount(),hasAnyTokens(msg, ['timeout', 'ERROR'])hasToken(msg, 'panic')(0.1%)hasToken(msg, 'timeout')(5%)count()without the count optimization,hasAnyTokensover 8% of rows🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/122896]
Version info
26.11.1.81-master(included in26.11and later)