Skip to content

group_projection_payload re-adds a prefetch_related("candidates", "rule_evaluations") that convergence_run_queryset() already declares (redundant) #291

Description

@erskingardner

Summary

filtered_convergence_runs() returns a queryset built from convergence_run_queryset() (forensics/views.py:1862-1867), which already declares prefetch_related(Prefetch("evidence_events", …), "candidates", "rule_evaluations"). But group_projection_payload re-specifies the same two lookups when it passes the queryset into paginated_payloads:

convergence.prefetch_related("candidates", "rule_evaluations")   # views.py:1332

Django deduplicates identical string lookups in prefetch_related_objects (the second prefetch_to is found in done_queries and skipped), so this issues no extra query — it is dead/redundant code, not a perf regression.

The redundancy is also asymmetric: the sibling api_group_convergence_runs (views.py:1057) and the streaming export (views.py:3247) call paginated_payloads on the same queryset without the extra .prefetch_related(...), so the base queryset was clearly meant to carry the prefetch.

Suggested fix

Drop .prefetch_related("candidates", "rule_evaluations") at views.py:1332 and pass convergence directly, matching the other two call sites.

Not a duplicate

No open issue flags this redundant view-layer prefetch. The convergence perf/prefetch issues (#152, #166, #177) concern the ingest hot path; #200/#154 concern LIMIT-dropping amplification; #158/#194/#248/#259/#201 concern admin changelists.

Metadata

Metadata

Assignees

No one assigned

    Labels

    LOWSeverity: minor correctness, polish, or maintainability issue

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions