Repository navigation
perf: sort fewer rows when grouping notifications - #473
Open
SanderMuller wants to merge 1 commit into
Open
SanderMuller wants to merge 1 commit into
SanderMuller wants to merge 1 commit into
Conversation
Move the whole-history windows into their own CTE, count the badge as distinct groups with an unread notification, and group narrow rows, joining whole notifications after group_rank = 1. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
The inbox and the unread badge, which every page shows, both group a user's notifications with window functions. This makes that grouping cheaper in three ways:
group_rankandunread_count.group_rank = 1.What the inbox shows stays the same. On the stress database, the inbox and badge queries return the same rows as on
production. The existing tests cover the group popover.I measured it on the StressSeeder database, for an account with 38,583 notifications (20,250 unread). Each query ran 15 times with
EXPLAIN ANALYZE, alternating with theproductionversion:productionmedianThe machine was under load during the run, so the absolute times run high. The two versions ran back to back, so the ratio holds.
#407 changes lines next to these, so it may need a small rebase. #308 moves the inbox query into a new method, which would need the same join after a rebase.
🤖 Generated with Claude Code