Add comments user pagination index#970
Merged
Merged
Conversation
rickyrombo
approved these changes
Jun 22, 2026
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.
Summary
/v1/users/:id/commentspaginationcomment_threadsjoin from the user-comments id page queryFullCommentsunchangedDB evidence
Read-only investigation against
discovery-1-replicashowed this route is currently dominating the read replica.Live 60-second
pg_stat_statementsdelta:SELECT comment_id as id FROM comments ... WHERE user_id = $1 ... ORDER BY comments.created_at DESC LIMIT/OFFSETPost-rollout 30-second delta still showed ongoing pressure:
Representative
EXPLAIN (ANALYZE, BUFFERS)on the replica:527480232,LIMIT 10 OFFSET 0: ~1.07s20,LIMIT 10 OFFSET 0: ~1.05s527480232,LIMIT 10 OFFSET 1000: ~1.08sThe plan scans the full
commentstable, hashescomment_threads, sorts, and returns only a page of ids. Catalog check showedcommentsonly hadcomments_pkeyandcomments_blocknumber_idx, with no index matchinguser_id + Track + active + created_at.Bridge logs also show the live traffic source is IP
162.220.232.107usingapp_name=TEMPO,TEMPO_sync,TEMPO_engage, andTEMPO_analyticsagainst/v1/users/:userId/comments.Test
go test ./api -run 'TestUserComments|Test200UnAuthed' -count=1