perf(issues): Fix N+1 query on repository in get_sorted_code_mapping_configs#106466
Merged
perf(issues): Fix N+1 query on repository in get_sorted_code_mapping_configs#106466
Conversation
shashjar
approved these changes
Jan 16, 2026
wedamija
approved these changes
Jan 16, 2026
…_configs
Add select_related("repository") to the RepositoryProjectPathConfig
query. The N+1 was triggered in GroupAutofixEndpoint._get_legacy which
iterates over code mappings and accesses mapping.repository.external_id.
Co-Authored-By: Claude <noreply@anthropic.com>
db67158 to
680423d
Compare
BYK
pushed a commit
that referenced
this pull request
Jan 19, 2026
…configs (#106466) Add select_related("repository") to the RepositoryProjectPathConfig query. - GroupAutofixEndpoint._get_legacy - iterates over code mappings and accesses mapping.repository.external_id - ProjectSeerPreferencesEndpoint.get - calls get_autofix_repos_from_project_code_mappings (seer/autofix/utils.py:319) which accesses code_mapping.repository.name, .provider, .external_id - ProjectStacktraceLinkEndpoint.get - calls get_stacktrace_config (integrations/utils/stacktrace_link.py:112) which accesses config.repository in the loop and passes it to get_link for install.get_stacktrace_link() - process_commit_context task - calls find_commit_context_for_event_all_frames → _generate_integration_to_files_mapping (integrations/utils/commit_context.py:255) which accesses code_mapping.repository n+1 issues https://sentry.sentry.io/issues/6218481153/ https://sentry.sentry.io/issues/6866977334/ https://sentry.sentry.io/issues/6834551736/ Co-authored-by: Claude <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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Add select_related("repository") to the RepositoryProjectPathConfig query.
n+1 issues
https://sentry.sentry.io/issues/6218481153/
https://sentry.sentry.io/issues/6866977334/
https://sentry.sentry.io/issues/6834551736/