Skip to content

Optimize notification unread polling#987

Merged
raymondjacobson merged 1 commit into
mainfrom
codex/notification-unread-poll-gating
Jul 6, 2026
Merged

Optimize notification unread polling#987
raymondjacobson merged 1 commit into
mainfrom
codex/notification-unread-poll-gating

Conversation

@raymondjacobson

@raymondjacobson raymondjacobson commented Jul 6, 2026

Copy link
Copy Markdown
Member

Summary

  • Gate limit=0 notification unread polling behind the fast single-recipient path before touching the broader multi-recipient GIN scan.
  • Add a concurrent partial GIN index for multi-recipient notification.user_ids rows.
  • Cover capped unread count and single/multi group dedupe behavior in tests.

Live analysis

  • Current bridge reads; replication lag was ms-level during the investigation.
  • Remaining /v1/notifications/:userId 504s were low-volume but concentrated in a few users, with requests timing out at the 8s notification read deadline.
  • Read-only EXPLAIN against the replica for top user DvEvv/77214 improved the unread poll shape from roughly 132ms / 39,651 buffer hits to roughly 14ms / 1,132 buffer hits by avoiding the multi-recipient branch when the single-recipient branch already satisfied the capped unread count.
  • User eJ57D/51 showed the same branch-elision behavior.
  • Residual users with fewer than 20 single-recipient unread groups still need the fallback, so the partial multi-recipient GIN index targets that path.

Testing

  • go test ./api -run '^$'
  • git diff --check

Note: focused notification integration tests could not run locally because the local test Postgres at localhost:21300 was not running.

@raymondjacobson raymondjacobson merged commit 42c4ada into main Jul 6, 2026
2 checks passed
@raymondjacobson raymondjacobson deleted the codex/notification-unread-poll-gating branch July 6, 2026 18:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant