Repository navigation
perf(conversations): Read the feed in three rounds - #3820
Merged
Merged
Conversation
Start the waiting rows, the Thread records and the Slack tenants with the reads they do not depend on: - Read the waiting rows in the first round, with the waiting ids as a subquery of the row read. - Read the Thread records in the main batch and nest them after access. - Take the Slack tenant of each preview from the feed rows. Co-Authored-By: BYK <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
# Conflicts: # packages/junior/src/api/conversations/list.ts
The heavy feed reads in 21 statements and 3 serial rounds.
BYK
approved these changes
Nov 19, 2026
BYK
added a commit
that referenced
this pull request
Nov 19, 2026
`GET /api/conversations` read some rows twice. On the heavy feed seed from #3809 (`include=links,media`), it ran 23 statements. It now runs 20. The response stays the same. - **Participants:** access read the viewer's participant rows, and the pin marks read the same rows again with `pinned_at is not null`. The feed now reads them once with `readMemberParticipants` and passes the roots to `conversationAccessFromRows`. `readConversationAccessFromSql` is now `readConversationAccessRows` plus that projection, so its other callers do not change. Feed rows are roots, so these roots cover the access check. An actor email feed with no viewer still reads only its pin marks. - **Avatars:** `readConversationParticipants` and `readConversationAuthors` read user photos in a second statement. Both participant reads now join the photo Identities with `hasUserPhoto`. `userAvatarUrlsFromJoinedPhotos` picks the photo, and `readMentionedPeople` uses it too. - **Children:** `listConversationWork` and `readFeedThreads` each read the children of the same roots. The feed reads `readConversationTrees` once and passes it to both. `ConversationTreeNode` now carries `rootConversationId` for the work owners. Other `listConversationWork` callers read the tree themselves. | Heavy seed | Statements | Rounds | | --- | --- | --- | | Before | 23 | 7 | | After | 20 | 7 | The rounds do not change here. #3820 removes them. On the same seed with preview mentions and an untitled Thread, the request goes from 25 statements to 22. The SQL budgets go down to match: `list-brief` 15 → 14 statements, `list-answer` 19/5 → 17/4, `tree-state` feed 20/5 → 17/4 and detail 20 → 19 statements. This PR and #3820 both change `readConversationFeedFromSql`. The one that merges second merges `main` in and keeps both changes. <!-- junior-request-attribution:start --> via @BYK. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:agent%3A2c3e432e56cd1bf6d0fbfabed08dc476 --> -- [View Session](https://junior-prod.sentry.dev/conversations/agent%3A2c3e432e56cd1bf6d0fbfabed08dc476) [[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3A2c3e432e56cd1bf6d0fbfabed08dc476/?project=4510944073809921) <!-- junior-session-footer:end --> Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: BYK <[email protected]>
22 tasks done
This branch was successfully deployed
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.
GET /api/conversationswaited on reads that did not depend on each other. On the heavy feed seed from #3809 (include=links,media), it ran 23 statements in 7 serial rounds. It now runs 21 statements in 3 rounds. The response stays the same.waitingConversationIdsQueryas a subquery, and the feed dedupes it in JS against the pins and the page.listWaitingConversationsand the subquery share one root expression.readFeedThreadswaited on access before it read anything.readFeedThreadRecordsnow reads the Thread rows, trees and the first messages of untitled Threads in the main batch, andnestFeedThreadsapplies access afterwards.attachActivityPreviewMentionsread each conversation's tenant again. The feed now takes it from the rows it already has, throughconversationSlackTenantId, whichloadConversationSlackTenantIdsalso uses. The detail route keeps its lookup.Mention resolution and sidebar annotations now run together after the batch.
On the same seed with preview mentions and an untitled Thread, the request goes from 25 statements in 9 rounds to 23 in 5.
The
serialRoundsbudgets on the feed scenarios go down to match:list-brief3 → 2,list-answer5 → 3,tree-statefeed 5 → 3. The statement budgets do not change.The heavy viewer's feed in
list-budget.test.tsnow also has anexpectSqlBudgetof 21 statements and 3 serial rounds.via @BYK.
--
View Session [Sentry]