Repository navigation
Conversation
resolved_group_ids passed the commit lookup to GroupLink as a subquery inside an OR. Postgres can't use that as an index condition, so every call read all commit resolve links and filtered them on the heap. Materializing the ids makes both sides of the OR index lookups. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
resolved_group_idspassed the commit lookup into theGroupLinkquery as a subquery inside an OR. Postgres can't use a subquery there as an index lookup, so every call read all ~427k commit resolve links and filtered them afterwards. Look up the commit ids first and pass them as a list, so both sides of the OR are index lookups.This runs about 13M times a week in
github.webhook.pull_requestat ~144ms p50, roughly 485 hours of db time a week. On the db mirror a typical lookup went from ~250ms to under 1ms including the extra commit query. Example trace, the two ~138mssentry_grouplinkselects are the ones that get faster.Things to know about the explains:
linked_idpartial index for commit resolve links has no index condition, so it returns all ~427k entries, then the heap scan touches ~14k pages and removes all but a handful with the hashed subquery. ~250ms warm, ~350ms cold, ~16k buffers