Force index only on list & stats (#4734)

Following up on https://github.com/grafana/oncall/pull/4731
This commit is contained in:
Vadim Stepanov 2024-07-25 14:25:01 +01:00 committed by GitHub
parent d30d69ba66
commit 71cdf355db
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -332,7 +332,7 @@ class AlertGroupView(
alert_receive_channels_ids = list(alert_receive_channels_qs.values_list("id", flat=True))
queryset = AlertGroup.objects.filter(channel__in=alert_receive_channels_ids)
if settings.ALERT_GROUPS_DISABLE_PREFER_ORDERING_INDEX:
if self.action in ("list", "stats") and settings.ALERT_GROUPS_DISABLE_PREFER_ORDERING_INDEX:
# workaround related to MySQL "ORDER BY LIMIT Query Optimizer Bug"
# read more: https://hackmysql.com/infamous-order-by-limit-query-optimizer-bug/
from django_mysql.models import add_QuerySetMixin