perf(messages): batch list enrichment to fix N+1 queries #99
No reviewers
Labels
No labels
area:api
area:core
area:docs
area:infra
area:ux
dependencies
documentation
duplicate
good first issue
help wanted
invalid
question
rust
status:complete
status:partial
status:planned
type:bug
type:design
type:feature
type:infra
type:refactor
type:refactor
type:research
type:ux
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
icub3d/decentcom!99
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feature/84-batch-message-enrichment"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Fixes #84.
list_messagesenriched each message with three separate queries (attachments, reaction counts, thread summary) in a sequential loop — a 50-message page issued ~150 round-trips.Fix
list_attachments_for_messages(&[id])andlist_reaction_counts_for_messages(&[id], viewer)usingIN (...)queries (mirroring the existinglist_thread_summaries).list_thread_summariesnow returns(parent_message_id, ThreadSummary)so results can be grouped (previously it dropped the parent id, which is why the list path couldn't use it).enrich_messageshelper: 3 batch queries total, assembled per-message in memory withHashMaps, preserving input order.list_messagesuses it. Single-message paths (create/get/update) keep the simpleenrich_message.Net: 3 queries per page instead of 3 × N.
Tests
list_batches_reactions_to_correct_messages: a reaction on one of two messages appears only on that message after listing.thread_summaries_enrichmentfor the new tuple return.Full server suite green (116 tests);
clippy -D warningsclean.Closes #84