From 16502205be1bc1a2a2191c4457c0a29ee5843a30 Mon Sep 17 00:00:00 2001 From: Joey Orlando Date: Thu, 20 Apr 2023 18:30:49 +0200 Subject: [PATCH] add channel__team to internal api serializer select_related (#1805) Locally I reproduced a slow `GET /api/internal/v1/alertgroups` query (took 9s - 10s). After adding this line to the alert group serializer for the internal api it: - cut the response time in half - cut the number of executed SQL queries from 52 to 30 --- CHANGELOG.md | 1 + engine/apps/api/serializers/alert_group.py | 1 + 2 files changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 451e5432..b1d9f1c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Helm chart: Fix helm hook for db migration job +- Performance improvements to `GET /api/internal/v1/alertgroups` endpoint by @joeyorlando and @iskhakov ([#1805](https://github.com/grafana/oncall/pull/1805)) ## v1.2.14 (2023-04-19) diff --git a/engine/apps/api/serializers/alert_group.py b/engine/apps/api/serializers/alert_group.py index 91247463..aab66f71 100644 --- a/engine/apps/api/serializers/alert_group.py +++ b/engine/apps/api/serializers/alert_group.py @@ -99,6 +99,7 @@ class AlertGroupListSerializer(EagerLoadingMixin, AlertGroupFieldsCacheSerialize SELECT_RELATED = [ "channel__organization", + "channel__team", "root_alert_group", "resolved_by_user", "acknowledged_by_user",