forked from CGM_Public/pretix_original
API: Prefetch customer in order list view (#3768)
Before this change, each order row needed an additional database query just to resolve the customer id (integer) to customer identifier (string). With this change, django does a database JOIN.
This commit is contained in:
committed by
GitHub
parent
f543cf2da5
commit
c5ede32649
@@ -222,6 +222,8 @@ class OrderViewSetMixin:
|
|||||||
qs = qs.prefetch_related('refunds', 'refunds__payment')
|
qs = qs.prefetch_related('refunds', 'refunds__payment')
|
||||||
if 'invoice_address' not in self.request.GET.getlist('exclude'):
|
if 'invoice_address' not in self.request.GET.getlist('exclude'):
|
||||||
qs = qs.select_related('invoice_address')
|
qs = qs.select_related('invoice_address')
|
||||||
|
if 'customer' not in self.request.GET.getlist('exclude'):
|
||||||
|
qs = qs.select_related('customer')
|
||||||
|
|
||||||
qs = qs.prefetch_related(self._positions_prefetch(self.request))
|
qs = qs.prefetch_related(self._positions_prefetch(self.request))
|
||||||
return qs
|
return qs
|
||||||
|
|||||||
Reference in New Issue
Block a user