Skip to content

Commit

Permalink
Prefetch results to speed up election page query
Browse files Browse the repository at this point in the history
  • Loading branch information
symroe committed May 22, 2024
1 parent c476178 commit 9d08d20
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion ynr/apps/elections/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ def get_context_data(self, **kwargs):
.prefetch_related(
Prefetch(
"membership_set",
Membership.objects.select_related("party", "person")
Membership.objects.select_related(
"party", "person", "result"
)
.annotate(last_name=LastWord("person__name"))
.annotate(
name_for_ordering=Coalesce(
Expand Down

0 comments on commit 9d08d20

Please sign in to comment.