-
Notifications
You must be signed in to change notification settings - Fork 10
Open
Description
Some database queries in the system have been identified in Sentry as N+1 queries, meaning that multiple database queries are executed where only a single, more optimized query could be used. N+1 queries result in slower performance.
Although each individual query may not take long, executing multiple unnecessary queries adds up and slows down the overall request time.
For example, selecting a scenario from all scenarios is one of the most time-expensive queries, taking about a third of a second. Already the third most expensive query takes only 9.56 milliseconds on average.
By refactoring these slow queries to use join table queries, related data can be fetched in a single query instead of multiple queries.
Steps:
- Identify all current flagged N + 1 queries
- Make a plan to tackle each. This can be either refactoring some code, or make better use of ActiveRecord's optimizations.
mabijkerk and louispt1
Metadata
Metadata
Assignees
Labels
No labels