Skip to content

Platform Hub: N+1 query for feature counts per project #6694

@khvn26

Description

@khvn26

N+1 query for feature counts per project

Medium Severity

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.

Additional Locations (1)

Fix in Cursor Fix in Web

Originally posted by @cursor[bot] in #6692 (comment)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions