mirror of
https://github.com/pretix/pretix.git
synced 2026-04-28 00:02:37 +00:00
New attempt at improving CheckinList.checkin_count
This commit is contained in:
@@ -3,7 +3,7 @@ from django.db import models
|
||||
from django.db.models import Exists, F, Max, OuterRef, Q, Subquery
|
||||
from django.utils.timezone import now
|
||||
from django.utils.translation import gettext_lazy as _, pgettext_lazy
|
||||
from django_scopes import ScopedManager
|
||||
from django_scopes import ScopedManager, scopes_disabled
|
||||
from jsonfallback.fields import FallbackJSONField
|
||||
|
||||
from pretix.base.models import LoggedModel
|
||||
@@ -90,6 +90,9 @@ class CheckinList(LoggedModel):
|
||||
).count()
|
||||
|
||||
@property
|
||||
@scopes_disabled()
|
||||
# Disable scopes, because this query is safe and the additional organizer filter in the EXISTS() subquery tricks PostgreSQL into a bad
|
||||
# subplan that sequentially scans all events
|
||||
def checkin_count(self):
|
||||
return self.event.cache.get_or_set(
|
||||
'checkin_list_{}_checkin_count'.format(self.pk),
|
||||
|
||||
Reference in New Issue
Block a user