mirror of
https://github.com/pretix/pretix.git
synced 2026-08-08 10:27:49 +00:00
Check-in history: Avoid JOINs
On a test dataset, this was a speedup from 18s to 900ms
This commit is contained in:
@@ -484,10 +484,17 @@ class CheckinListView(EventPermissionRequiredMixin, PaginationMixin, ListView):
|
||||
|
||||
def get_queryset(self):
|
||||
qs = Checkin.all.filter(
|
||||
list__event=self.request.event,
|
||||
).select_related(
|
||||
'position', 'position__order', 'position__item', 'position__variation', 'position__subevent'
|
||||
list_in=self.request.event.checkin_lists.values_list('id', flat=True),
|
||||
).prefetch_related(
|
||||
# For events with huge numbers of check-ins, prefetch_related is a lot more efficient than
|
||||
# select_related, since it just needs to query one page size of positions instead of joining
|
||||
# multiple huge tables during result computation
|
||||
Prefetch(
|
||||
'position',
|
||||
queryset=OrderPosition.all.select_related(
|
||||
'order', 'item', 'variation', 'subevent',
|
||||
)
|
||||
),
|
||||
'list', 'gate', 'device'
|
||||
)
|
||||
if self.filter_form.is_valid():
|
||||
|
||||
Reference in New Issue
Block a user