Skip to content

GO-6758 Optimize full chat messages reindex with batched fetching#3081

Open
KirillSto wants to merge 3 commits intodevelopfrom
go-6758-optimize-full-chat-messages-reindex
Open

GO-6758 Optimize full chat messages reindex with batched fetching#3081
KirillSto wants to merge 3 commits intodevelopfrom
go-6758-optimize-full-chat-messages-reindex

Conversation

@KirillSto
Copy link
Copy Markdown
Member

@KirillSto KirillSto commented Apr 8, 2026

Summary

  • Replace single GetMessages call (which loads all messages into memory at once) with batched iteration of 100 messages per batch in prepareChatSearchDocsAll
  • Extract chatMessageToSearchDoc helper to eliminate code duplication between batch and single-message paths

Linear

GO-6758

Test plan

  • Existing TestPrepareSearchDocs_ChatObject/all_messages passes
  • Existing TestPrepareSearchDocs_ChatObject/messages_by_orderId passes
  • New TestPrepareSearchDocs_ChatObject/all_messages_batched test with 150 messages (exceeds batch size) verifies all messages are fetched in correct order
  • All chat repository tests pass (go test ./core/block/chats/chatrepository/...)
  • Full indexer test suite passes (go test ./core/indexer/...)

🤖 Generated with Claude Code

KirillSto and others added 2 commits April 8, 2026 12:01
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>
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 8, 2026

New Coverage 47.2% of statements
Patch Coverage 72.7% of changed statements (16/22)

Coverage provided by https://github.com/seriousben/go-patch-cover-action

@KirillSto KirillSto self-assigned this Apr 8, 2026
@KirillSto KirillSto requested a review from deff7 April 8, 2026 11:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant