Skip to content

Inverted Text Index v3 - #91518

Merged
fm4v merged 32 commits into
ClickHouse:masterfrom
CurtizJ:text-index-v3
Dec 18, 2025
Merged

fm4v merged 32 commits into
ClickHouse:masterfrom
CurtizJ:text-index-v3

Conversation

@CurtizJ

@CurtizJ CurtizJ commented Dec 4, 2025 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Backward Incompatible Change

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

Improved storage layout of the inverted text index to be more efficient for reading from the object storage. Improved performance of merges in tables with inverted text indexes. If you used the experimental text index before version 25.12, you need to drop the index before the upgrade and rebuild it on the new version.

Details

The new index format is optimized for reading from object storage by reducing the number of random reads required for index analysis.

The key changes:

  • In the new format, an inverted index is always built for the whole part (with infinite granularity).
  • The format is almost the same (sparse index -> dictionary split into blocks -> posting lists), but the posting lists are divided into blocks to allow partial reading, and bloom filters are removed.
  • During merges, the index is not rebuilt; instead, it is merged. To merge indexes, we build a mapping from part offsets in the old part to part offsets in the new part (using an existing part of the implementation of projections with _part_offset) and recalculate the posting lists using this mapping.
  • Materialization of index works in two steps now: building segments of indexes and merging them (similar to materialization of projections).
  • The performance of the cold run on S3 became about 10 times better
  • Interfaces of text search didn’t change, except for changes in the parameters of the text index.

@clickhouse-gh

clickhouse-gh Bot commented Dec 4, 2025 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [14c03ea]

Summary: ⏳

job_name test_name status info comment
Docs check failure
Build docusaurus failure cidb
Integration tests (amd_tsan, 2/6) failure
test_keeper_reconfig_remove/test.py::test_reconfig_remove_followers_from_3 FAIL cidb
Performance Comparison (amd_release, master_head, 2/6) failure
Check Results failure

@clickhouse-gh clickhouse-gh Bot added the pr-backward-incompatible Pull request with backwards incompatible changes label Dec 4, 2025
@CurtizJ
CurtizJ marked this pull request as ready for review December 11, 2025 15:06
@EmeraldShift

Copy link
Copy Markdown
Contributor

Do I understand right (just skimming the code) that this effectively brings back part-wide postings and/or dictionaries via GRANULARITY <big-number>? That sounds exciting!

rschu1ze

This comment was marked as resolved.

@ahmadov ahmadov self-assigned this Dec 16, 2025

@rschu1ze rschu1ze 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.

Wanted to check the entire PR today (including the machinery in TextIndexUtils) but only found time to check the index itself. Looks overall great.

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.

minor: we use 02346_text_index_... prefix to identify all text index tests. Even the new ones get the same prefix.

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.

The practical aspect is that running clickhouse-test 02346_text_index runs all text index related tests.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

You can run clickhouse-test text_index as well.


serializeBloomFilter(tokens_and_postings.size(), bloom_filter, *index_stream);
serializeSparseIndex(sparse_index_block, *index_stream);
TextIndexSerialization::serializeSparseIndex(sparse_index_block, index_stream->compressed_hashing);

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.

since we're moving into a stable release with the text index, we might need to introduce a version header now.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ok, let's introduce the header version.

std::vector<TokenPostingsInfo> token_infos;
};

class TextIndexHeader

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.

If we decide to include the version in the header, it might to good to re-introduce the TextIndexHeader again.

@alexey-milovidov alexey-milovidov added the 🎅 🎁 gift🎄 To make people wonder label Dec 18, 2025
@fm4v

fm4v commented Dec 18, 2025

Copy link
Copy Markdown
Member

Failed docs check is irrelevant, broken in other PRs
#92452

@fm4v
fm4v enabled auto-merge December 18, 2025 12:31
@fm4v
fm4v added this pull request to the merge queue Dec 18, 2025
Merged via the queue into ClickHouse:master with commit 4debe5f Dec 18, 2025
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-synced-to-cloud The PR is synced to the cloud repo label Dec 18, 2025
@EmeraldShift

Copy link
Copy Markdown
Contributor

Since this is marked backward-incompatible, how should I upgrade to the next version if I already have some V2 text indexes?

@fm4v

fm4v commented Dec 18, 2025

Copy link
Copy Markdown
Member

@EmeraldShift please drop the index, upgrade clickhouse and create new one

@CurtizJ

CurtizJ commented Dec 18, 2025

Copy link
Copy Markdown
Member Author

@EmeraldShift

Do I understand right (just skimming the code) that this effectively brings back part-wide postings and/or dictionaries via GRANULARITY

Yes. I've updated the description of PR to highlight the changes in the new format.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🎅 🎁 gift🎄 To make people wonder pr-backward-incompatible Pull request with backwards incompatible changes 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.

7 participants