From f4eb2bbf2e00ddcd0a7d74240352ef0a5a1e745d Mon Sep 17 00:00:00 2001 From: Matias Bordese Date: Mon, 26 Jun 2023 11:12:10 -0300 Subject: [PATCH] Remove unused prefetch_related in metrics task (#2343) The `prefecth_related` data here is not being used later (since we are applying filters not getting `.all`) and it is preloading all alert groups for integrations into memory (which can be a lot). --- engine/apps/metrics_exporter/tasks.py | 1 - 1 file changed, 1 deletion(-) diff --git a/engine/apps/metrics_exporter/tasks.py b/engine/apps/metrics_exporter/tasks.py index 9fe47e79..605d111d 100644 --- a/engine/apps/metrics_exporter/tasks.py +++ b/engine/apps/metrics_exporter/tasks.py @@ -81,7 +81,6 @@ def calculate_and_cache_metrics(organization_id, force=False): AlertReceiveChannel.objects.using(get_random_readonly_database_key_if_present_otherwise_default()) .filter(~Q(integration=AlertReceiveChannel.INTEGRATION_MAINTENANCE) & Q(organization_id=organization_id)) .select_related("organization", "team") - .prefetch_related("alert_groups") ) response_time_period = get_response_time_period()