Skip to content

[dashboard] Investigate and fix N+1 query issue #1806

Open
@bmispelon

Description

@bmispelon

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:

SELECT dashboard_datum.id, dashboard_datum.content_type_id, dashboard_datum.object_id,
  dashboard_datum.timestamp, dashboard_datum.measurement
FROM dashboard_datum
WHERE (
  dashboard_datum.content_type_id = %s AND dashboard_datum.object_id = %s
)
ORDER BY dashboard_datum.timestamp DESC
LIMIT 1

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() or prefetch_related() somewhere in the view, but it might also be more complicated than that.

Metadata

Metadata

Assignees

No one assigned

    Labels

    help-neededHelp neededopsOperationspythonPull requests that update Python code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions