-
-
Notifications
You must be signed in to change notification settings - Fork 995
[dashboard] Investigate and fix N+1 query issue #1806
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
DjangoDebugToolbar is reporting this query as repeating 19 times, which corresponds to 1 time for each metric that is displayed on the dashboard. There is a for loop iterating over the metrics to get the latest datum for each metric. I'll open a draft PR that seems to reduce the number of sql queries down from 35 to 9 for the dashboard page. |
Hi @bmispelon |
Would it help to combine the information into a materialized view? Perhaps the view can be updated once an hour so that it is close to real time? |
I noticed today that Sentry was reporting a possible N+1 query issue on the dashboard homepage.
Here's the query that Sentry is claiming is being repeated:
I'd recomment trying to see ifthe Django Debug Toolbar (installed by default I think) is reporting the duplicated query also. And if so, we should try to fix it. Usually it's a matter of adding a
select_related()
orprefetch_related()
somewhere in the view, but it might also be more complicated than that.The text was updated successfully, but these errors were encountered: