From 71cdf355db41517823b579e32414b4683e0e77e7 Mon Sep 17 00:00:00 2001 From: Vadim Stepanov Date: Thu, 25 Jul 2024 14:25:01 +0100 Subject: [PATCH] Force index only on list & stats (#4734) Following up on https://github.com/grafana/oncall/pull/4731 --- engine/apps/api/views/alert_group.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engine/apps/api/views/alert_group.py b/engine/apps/api/views/alert_group.py index bd0dec38..e59ab7aa 100644 --- a/engine/apps/api/views/alert_group.py +++ b/engine/apps/api/views/alert_group.py @@ -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