Repository navigation
Save synced GitHub repositories in one statement instead of one per repository - #350
Open
superlog-responder[bot] wants to merge 1 commit into
Open
superlog-responder[bot] wants to merge 1 commit into
superlog-responder[bot] wants to merge 1 commit into
Conversation
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.
Sentry flagged an N+1 query on
POST /api/webhooks/github(RESPONDER-PROD-2V). Since #306, theinstallation_repositorieswebhook resyncs the repository list, andreplaceRepositoriessaved each repository with its own insert. An installation with hundreds of repositories made hundreds of round trips inside one transaction.replaceRepositoriesnow saves repositories in batches of 500 with a single insert per batch, updating existing rows from the inserted values.Behaviour is unchanged: repositories missing from the list are still marked unavailable, and listed ones are marked available with their latest name, default branch, visibility and metadata.
Checked: typecheck, lint, the GitHub webhook and route tests, and the generated SQL.
🤖 Generated with Claude Code
Summary by cubic
Fixes the N+1 query on
POST /api/webhooks/githubthat made one insert per repository when resyncing the list, causing hundreds of round trips on large installations.replaceRepositoriesnow saves synced repositories in batches of 500, one upsert per batch, and saves repositories listed twice only once, keeping the last entry. Behavior is unchanged: repositories missing from the list are still marked unavailable, and listed ones keep their latest name, default branch, visibility, and metadata.Written for commit ff39f55. Summary will update on new commits.