Skip to content

perf(conversations): Read the feed with fewer statements - #3822

Merged
BYK merged 2 commits into
mainfrom
perf/feed-statements
Nov 19, 2026
Merged

BYK merged 2 commits into
mainfrom
perf/feed-statements

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

GET /api/conversations read some rows twice. On the heavy feed seed from #3809 (include=links,media), main runs 21 statements in 3 rounds. This PR cuts that to 18 statements, still in 3 rounds. The response is unchanged.

  • Participants: the access check 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 becomes readConversationAccessRows plus that projection, so its other callers keep working unchanged. Feed rows are roots, so those roots are enough for 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 readFeedThreadRecords each read the children of the same roots. The feed now calls readConversationTrees once and passes the tree to listConversationWork and nestFeedThreads. ConversationTreeNode now carries rootConversationId for the work owners. Other listConversationWork callers read the tree themselves.
Heavy seed Statements Rounds
main 21 3
This PR 18 3

The SQL budgets drop to match:

Budget Before After
list-budget, heavy feed 21/3 18/3
list-brief 15/2 14/2
list-answer 19/3 17/3
tree-state feed 20/3 17/3
tree-state detail 20 statements 19 statements

via @BYK.

--

View Session [Sentry]

Drop three feed reads that repeat another read:

- Read the viewer's participant rows once for access and pin marks.
- Join user photos into the participant reads.
- Read the children of the roots once for work owners and Threads.

Co-Authored-By: BYK <[email protected]>
@vercel

vercel Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
junior-docs Ready Ready Preview Nov 19, 2026 10:25pm UTC

Request Review

@github-actions

Copy link
Copy Markdown
Contributor

9 screenshot changes — 9 changed · 0 added · 0 removed

Review screenshots in Frameshift

Automation Run Details · Desktop
Automation Run Details · Desktop
Changed
Automation Skill Editor · Desktop
Automation Skill Editor · Desktop
Changed
Automation Skill Editor · Mobile
Automation Skill Editor · Mobile
Changed
Automations Runs Filters · Desktop
Automations Runs Filters · Desktop
Changed
Conversation Header Auto Archive Light · Desktop
Conversation Header Auto Archive Light · Desktop
Changed
Conversation Question Stepper · Desktop
Conversation Question Stepper · Desktop
Changed
Show 3 more changed screenshots
Conversation Stop Active · Mobile
Conversation Stop Active · Mobile
Changed
System Cache Missing · Desktop
System Cache Missing · Desktop
Changed
System Cache Warming Refill Running · Desktop
System Cache Warming Refill Running · Desktop
Changed

@BYK
BYK enabled auto-merge (squash) November 19, 2026 22:14
# Conflicts:
#	packages/junior/src/api/conversations/list.ts
#	packages/junior/src/api/conversations/threads.ts
#	packages/junior/tests/integration/api/conversations/list-answer.test.ts
#	packages/junior/tests/integration/api/conversations/list-brief.test.ts
#	packages/junior/tests/integration/api/conversations/tree-state.test.ts
@BYK
BYK merged commit eed1d15 into main Nov 19, 2026
52 checks passed
@BYK
BYK deleted the perf/feed-statements branch November 19, 2026 22:34

This branch was successfully deployed

1 active deployment
Preview – junior-docs — 16417fe0 Deployed Nov 19, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: high PR risk score: high

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant