Skip to content

perf(sentry_apps): Eager load app and token in proxy user lookup - #127720

Draft
scttcper wants to merge 1 commit into
masterfrom
scttcper/proxy-user-rpc-select-related
Draft

scttcper wants to merge 1 commit into
masterfrom
scttcper/proxy-user-rpc-select-related

Conversation

@scttcper

Copy link
Copy Markdown
Member

Eager load the sentry app's application and the installation's api token in find_installation_by_proxy_user, serialization was lazy loading both as separate queries.

This RPC runs about 141M times a week (any API request using a sentry app token) at ~24ms p50. The application lookup ran ~166M times a week on the control db, most of it from here. Example trace, the third query under the RPC handler is the application lookup that goes away.

find_installation_by_proxy_user loaded the sentry app and installation, then serialization lazy loaded app.application and installation.api_token as separate queries. select_related both so it's two queries instead of up to four.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Oct 16, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant