GO-6758 Optimize full chat messages reindex with batched fetching#3081
Open
GO-6758 Optimize full chat messages reindex with batched fetching#3081
Conversation
Replace single GetMessages call that loads all messages into memory with batched iteration (100 messages per batch). Add OrderAsc field to GetMessagesRequest for forward pagination. Extract shared chatMessageToSearchDoc helper to eliminate duplication. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Remove unnecessary OrderAsc field from GetMessagesRequest. Paginate using existing BeforeOrderId with batch[0].OrderId as cursor, since queryMessages always returns results sorted ascending. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Coverage provided by https://github.com/seriousben/go-patch-cover-action |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
GetMessagescall (which loads all messages into memory at once) with batched iteration of 100 messages per batch inprepareChatSearchDocsAllchatMessageToSearchDochelper to eliminate code duplication between batch and single-message pathsLinear
GO-6758
Test plan
TestPrepareSearchDocs_ChatObject/all_messagespassesTestPrepareSearchDocs_ChatObject/messages_by_orderIdpassesTestPrepareSearchDocs_ChatObject/all_messages_batchedtest with 150 messages (exceeds batch size) verifies all messages are fetched in correct ordergo test ./core/block/chats/chatrepository/...)go test ./core/indexer/...)🤖 Generated with Claude Code