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:
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: