perf(access): only do demo mode checks if demo mode#88993
Merged
Conversation
obostjancic
approved these changes
Apr 8, 2025
obostjancic
left a comment
Member
There was a problem hiding this comment.
Looks good! Thanks for doing this!
vgrozdanic
approved these changes
Apr 8, 2025
andrewshie-sentry
pushed a commit
that referenced
this pull request
Apr 8, 2025
see #inc-1104. our database load is getting to be quite high. one of the biggest sources is SELECT queries on the organization table. Looking at the [queries module](https://sentry.sentry.io/insights/backend/database/spans/span/c40fc66225c6f13e?environment=de&project=1&statsPeriod=30d&transaction=%2Fapi%2F0%2Fprojects%2F%7Borganization_id_or_slug%7D%2F%7Bproject_id_or_slug%7D%2Ffiles%2Fdsyms%2F&transactionMethod=GET) and from there exemplar traces and [profiles](https://sentry.sentry.io/explore/profiling/profile/sentry/feff8345eacd4440af7d4721ffa3c684/flamegraph/?colorCoding=by%20system%20vs%20application%20frame&fov=0%2C93%2C88763000%2C14&query=organiza&sorting=call%20order&tid=136381799052992&view=top%20down), it was determined the bulk of these queries come from our permissions middleware. The first thing I've noticed to optimize is that regardless of a user being demo mode or not, we still do these queries to get the organization right now. This is unneeded work, and can be skipped if it's not the demo user. This PR moves the logic so we only do these extra checks if we're in demo mode. This runs most requests, so this should provide some relief on our database.
Christinarlong
pushed a commit
that referenced
this pull request
Apr 10, 2025
see #inc-1104. our database load is getting to be quite high. one of the biggest sources is SELECT queries on the organization table. Looking at the [queries module](https://sentry.sentry.io/insights/backend/database/spans/span/c40fc66225c6f13e?environment=de&project=1&statsPeriod=30d&transaction=%2Fapi%2F0%2Fprojects%2F%7Borganization_id_or_slug%7D%2F%7Bproject_id_or_slug%7D%2Ffiles%2Fdsyms%2F&transactionMethod=GET) and from there exemplar traces and [profiles](https://sentry.sentry.io/explore/profiling/profile/sentry/feff8345eacd4440af7d4721ffa3c684/flamegraph/?colorCoding=by%20system%20vs%20application%20frame&fov=0%2C93%2C88763000%2C14&query=organiza&sorting=call%20order&tid=136381799052992&view=top%20down), it was determined the bulk of these queries come from our permissions middleware. The first thing I've noticed to optimize is that regardless of a user being demo mode or not, we still do these queries to get the organization right now. This is unneeded work, and can be skipped if it's not the demo user. This PR moves the logic so we only do these extra checks if we're in demo mode. This runs most requests, so this should provide some relief on our database.
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.
see #inc-1104. our database load is getting to be quite high. one of the biggest sources is SELECT queries on the organization table. Looking at the queries module and from there exemplar traces and profiles, it was determined the bulk of these queries come from our permissions middleware.
The first thing I've noticed to optimize is that regardless of a user being demo mode or not, we still do these queries to get the organization right now. This is unneeded work, and can be skipped if it's not the demo user.
This PR moves the logic so we only do these extra checks if we're in demo mode.
This runs most requests, so this should provide some relief on our database.