Skip to content

feat(search): reduce DB pressure during email search backfills#2007

Merged
gbirman merged 5 commits intomainfrom
gab/feat/reduce-db-read-pressure-for-sps
Mar 18, 2026
Merged

feat(search): reduce DB pressure during email search backfills#2007
gbirman merged 5 commits intomainfrom
gab/feat/reduce-db-read-pressure-for-sps

Conversation

@gbirman
Copy link
Copy Markdown
Contributor

@gbirman gbirman commented Mar 17, 2026

Summary

  • Add EmailThreadBatchMessage SQS type that batches 50 threads per message (vs 1 thread per message previously)
  • Add get_parsed_search_messages_by_thread_ids DB query using WHERE thread_id = ANY($1) to fetch messages for all 50 threads in a single query
  • Increase per-thread message page size from 10 to 100 for the existing single-thread path
  • Add vendored OpenSSL to email_service for cross-compilation support

This reduces DB round-trips by ~50x during backfills. Previously each thread required 4 DB queries (messages + senders + recipients + labels). Now 50 threads share those same 4 queries.

@gbirman gbirman requested a review from a team as a code owner March 17, 2026 23:10
@gbirman gbirman changed the title feat(sps): reduce DB pressure during email search backfills feat(search): reduce DB pressure during email search backfills Mar 17, 2026
@gbirman gbirman merged commit cce91c5 into main Mar 18, 2026
40 checks passed
@gbirman gbirman deleted the gab/feat/reduce-db-read-pressure-for-sps branch March 18, 2026 00:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant