You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Feature.objects.filter(project=project).count() runs inside a per-project loop in both get_organisation_metrics (line 295) and get_stale_flags_per_project (line 491). For an instance-wide dashboard covering many organizations, this results in one database query per project. A single annotated queryset grouped by project_id could replace all these calls.
N+1 query for feature counts per project
Medium Severity
Feature.objects.filter(project=project).count()runs inside a per-project loop in bothget_organisation_metrics(line 295) andget_stale_flags_per_project(line 491). For an instance-wide dashboard covering many organizations, this results in one database query per project. A single annotated queryset grouped byproject_idcould replace all these calls.Additional Locations (1)
api/platform_hub/services.py#L490-L491Originally posted by @cursor[bot] in #6692 (comment)