Skip to content

Use the pfor posting list codec for text indexes by default - #127489

Merged
CurtizJ merged 6 commits into
ClickHouse:masterfrom
CurtizJ:text-index-pfor-default
Nov 2, 2026
Merged

CurtizJ merged 6 commits into
ClickHouse:masterfrom
CurtizJ:text-index-pfor-default

Conversation

@CurtizJ

@CurtizJ CurtizJ commented Oct 22, 2026 •

Copy link
Copy Markdown
Member

Related: #118123

Changelog category (leave one):

  • Improvement

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

Text indexes now use the pfor posting list codec by default (MergeTree setting text_index_posting_list_codec), which makes them smaller and enables lazy posting list decoding. Parts written with pfor cannot be read by servers older than 26.10; set compatibility to an older version during a rolling upgrade to keep writing uncompressed posting lists.


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

Version info

  • Merged into: 26.11.1.1105-master (included in 26.11 and later)

CurtizJ and others added 2 commits October 7, 2026 18:32
Change the default of the MergeTree setting `text_index_posting_list_codec`
from `none` to `pfor`. The settings history entry for 26.10 makes
`compatibility` below 26.10 revert it to `none`, so a compatibility pin keeps
upgraded servers writing parts that older servers can read.

Adjust tests that relied on `none` being the default:
- `02346_text_index_posting_list_compression_data_size_validation`: pin
  `posting_list_codec = 'none'` for the uncompressed table.
- `04355_text_index_table_settings`: use `none` as the non-default codec and
  `pfor` as the default one.
- `test_text_index_upgrade`: pin the codec to `none` together with
  `v0_initial` before the downgrade, and rely on the default codec in the
  `pfor` downgrade test.

Update the documentation and stale comments accordingly.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@mintlify

mintlify Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Preview approval required

This pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit 74fc94c.

Approve preview

@clickhouse-gh

clickhouse-gh Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [74fc94c]


AI Review

Summary

Switches the default text-index posting list codec to pfor, with compatibility history, upgrade guidance, and updated tests. One previously reported performance blocker remains at head 74fc94c98cadea96e41123c7a8b8cddf04e88f1c; no new inline findings.

Findings

❌ Blockers

  • src/Storages/MergeTree/MergeTreeSettings.cpp:896: Changing the default more than doubles common multi-token count latency. [dismissed by author -- https://github.com/Use the pfor posting list codec for text indexes by default #127489#discussion_r4412768643] The author accepts this tradeoff; I retain the concern because the latest measurements reproduce a substantial regression on the default execution path.

    In the ARM run from 2026-10-29, text_index_trivial_count queries 2 and 3 increase from approximately 4.0 ms to 8.7/8.6 ms with the postings cache disabled. Both repeat the slowdown measured on 2026-10-22. Each latest comparison has 30 samples per binary; raw-sample, quantile-shift, and history checks confirm the regression, exceeding adaptive thresholds of 15.0%/15.4%.

    The current MergeTreeIndexGranuleText::analyzePostings eagerly materializes single-segment lists before cursor selection. With the default block size of 1,048,576, the benchmark's 500,000-entry common-token list takes this path, and SegmentedPostingListCodec::decode reconstructs its Roaring bitmap through addMany every 128 IDs. Lazy decoding therefore does not avoid the added work.

    Address this materialization cost before switching the default, or retain none until it is addressed. The author-resolved thread remains closed; this finding is not reposted inline.

Final Verdict

Status: ❌ Block. Fix the single-segment count regression or retain the previous default, then rerun text_index_trivial_count with the default block size and postings cache disabled.

@clickhouse-gh clickhouse-gh Bot added the pr-improvement Pull request with some product improvements label Oct 22, 2026
The `settings_changes_history` style check requires a changed default to
have a record under the current master version, which is 26.11 now.
Move the `text_index_posting_list_codec` record from 26.10 to 26.11 and
update the documentation accordingly.

https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=127489&sha=3b3fa3fbf121ffba37ee621d06ceff4cb2e2dbdc&name_0=PR&name_1=Style%20check
ClickHouse#127489

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@clickhouse-gh clickhouse-gh Bot added the comp-text-index Full-text search: inverted/text index in MergeTree (tokenizers, posting lists, GIN-style index bu... label Oct 22, 2026
Split the dense paragraph about the posting list codec into short ones:
`text_index_serialization_version` does not control the codec, `pfor`
parts cannot be read before 26.10, and `pfor` is the default since 26.11,
which a `compatibility` pin below 26.11 reverts to `none` during a rolling
upgrade.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 74fc94c98 with master 86e0a62bf (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

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

Job report

@ahmadov ahmadov self-assigned this Oct 25, 2026

@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 and others added 2 commits October 29, 2026 12:42
Add a `tab_pfor` table to
`02346_text_index_posting_list_compression_data_size_validation`, so the
exact text index size is pinned for `pfor` next to `bitpacking` and `none`,
on the same dataset with its 128-value block edge cases.
`05060_text_index_posting_list_codec_size` only checks the size ordering.

Review comment: ClickHouse#127489 (comment)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@CurtizJ

CurtizJ commented Nov 2, 2026

Copy link
Copy Markdown
Member Author

Slowdown of short queries that read 1-segment postings is known. I'll address it later. I think, it's not a blocker for merge.

Screenshot 2026-11-02 at 14 24 21

@CurtizJ
CurtizJ added this pull request to the merge queue Nov 2, 2026
@clickhouse-gh clickhouse-gh Bot added the can be tested Allows running workflows for external contributors label Nov 2, 2026
Merged via the queue into ClickHouse:master with commit 0f8ede7 Nov 2, 2026
217 of 230 checks passed
@CurtizJ
CurtizJ deleted the text-index-pfor-default branch November 2, 2026 15:55
@robot-ch-test-poll robot-ch-test-poll added the pr-synced-to-cloud The PR is synced to the cloud repo label Nov 2, 2026
antonio2368 added a commit that referenced this pull request Nov 3, 2026
#127489 changed the default of
`text_index_posting_list_codec` to `pfor`. The compressed postings take fewer
page cache blocks, so the default query had only 83 page cache misses and the
`misses >= 100` assertion failed in the merge queue. The test is about the
lookahead, not the codec, so keep the postings uncompressed.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?REF=gh-readonly-queue/master/pr-125770-3b3f22da1d188310dfaf55af6b993fa8477e7bf4&sha=6ba1096d6fd295909fd5b518f171b6578c0ec2dc&name_0=MergeQueueCI
PR: #125770

Co-Authored-By: Claude Opus 5.5 <[email protected]>
CurtizJ added a commit to CurtizJ/ClickHouse that referenced this pull request Nov 10, 2026
…roximate dense ones

The analysis decoded single-segment `pfor` and `bitpacking` posting lists into a Roaring bitmap
before folding them, which made `pfor` much slower than `none` on dense lists (perf test
`text_index_trivial_count`, queries #2 and #3).

- `FoldedPostings`: the rows of block-compressed posting lists are decoded straight into sorted
  arrays, no bitmap is built. An intersection is a sorted array, intersected with a compressed
  posting list without decoding the blocks with none of its rows. A union is kept as its largest
  array and the merged other arrays, so the rows of a dense list are not copied: its cardinality
  is counted from both, and the lazy readers take a cursor per array.
- `approximatePostings`: a dense posting list of an `Any` or single-token query is approximated by
  the row spans of its packed blocks. The last row of a block is a row of the posting list, so only
  a block whose span holds a whole mark needs decoding, and the approximation is exact at the
  granularity of marks. The readers read such posting lists themselves with cursors, so it is used
  only in the lazy mode without patterns, and not by `ReadFromTextIndexCount`.
- New event `TextIndexAnalysisApproximatedPostings`, test 05616.

Related: ClickHouse#127489 (comment)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@clickgapai

Copy link
Copy Markdown
Contributor

@CurtizJ @ahmadov — this PR looks backward incompatible but is categorized as Improvement.

Why: MergeTreeSettings.cpp:885 changes an on-disk default (history {"26.11", "none", "pfor"} at :889); parts written by default fail on 26.8 LTS and 26.9 with CORRUPTED_DATA: Unknown posting list codec type in text index header: 2 (reproduced with the official images). The PR body has no changelog entry text.

Suggested category: Backward Incompatible Change. Ignore if the change is intentionally non-breaking.

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-text-index Full-text search: inverted/text index in MergeTree (tokenizers, posting lists, GIN-style index bu... pr-improvement Pull request with some product 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.

4 participants