Skip to content

perf(notifications): Index notification settings by recipient - #129705

Merged
scttcper merged 2 commits into
masterfrom
scttcper/notification-settings-by-recipient
Nov 3, 2026
Merged

scttcper merged 2 commits into
masterfrom
scttcper/notification-settings-by-recipient

Conversation

@scttcper

@scttcper scttcper commented Nov 3, 2026 •

Copy link
Copy Markdown
Member

Activity notifications pass every project member as a recipient to NotificationController. For each recipient it scanned every loaded setting row, so big projects got slow fast. Groups settings by user/team once and filters only that recipient's rows, results are the same.

get_participants() with a few settings per user:

Project members Before After
200 96 ms 34 ms
1,000 1.8 s 166 ms
2,000 6.6 s 368 ms

get_participants gets called about 140k times a day from send_activity_notifications, a third of those calls take over 100ms.

The controller loads settings for every recipient, then rescans that
whole list once per recipient when layering options and providers.
Activity notifications pass every project member as a recipient, so
this grows with the square of the member count.

Group settings by user/team once and filter only that recipient's rows.
Same filter is still applied to the bucket so results don't change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Nov 3, 2026
@scttcper
scttcper marked this pull request as ready for review November 3, 2026 17:52
@scttcper
scttcper requested a review from a team as a code owner November 3, 2026 17:52
@scttcper
scttcper requested a review from a team November 3, 2026 17:52
@scttcper
scttcper merged commit 48ea254 into master Nov 3, 2026
76 checks passed
@scttcper
scttcper deleted the scttcper/notification-settings-by-recipient branch November 3, 2026 18:48

This branch was successfully deployed

1 active deployment
Preview — 4e6eaabf Deployed Nov 3, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants