Skip to content

Commit

Permalink
api: Optmize the number of queries for events
Browse files Browse the repository at this point in the history
We were fetching event.name for every entry of list, but event.name can
be part of the initial select to retrieve the list of events to
serialize.

This brings the number of queries from 22 to 2 (which makes sense since
we default to retrieving 20 entries).

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
  • Loading branch information
Damien Lespiau committed Nov 2, 2015
1 parent e9102a5 commit 6874ac7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion patchwork/views/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ class EventLogViewSet(mixins.ListModelMixin,
ListMixin,
viewsets.GenericViewSet):
permission_classes = (MaintainerPermission, )
queryset = EventLog.objects.all()
queryset = EventLog.objects.all().select_related('event')
serializer_class = EventLogSerializer
filter_backends = (filters.DjangoFilterBackend,)
filter_class = EventTimeFilter
Expand Down

0 comments on commit 6874ac7

Please sign in to comment.