From 2f4ebe50ef7ad52d89d606c9417933ddde0abc1d Mon Sep 17 00:00:00 2001 From: Luke Couzens Date: Wed, 6 Nov 2024 09:25:15 +0000 Subject: [PATCH] Performance improvmeent for OCP label deletes (#5362) --- .../database/sql/reporting_ocpstoragevolumelabel_summary.sql | 3 ++- koku/masu/database/sql/reporting_ocpusagepodlabel_summary.sql | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/koku/masu/database/sql/reporting_ocpstoragevolumelabel_summary.sql b/koku/masu/database/sql/reporting_ocpstoragevolumelabel_summary.sql index 1976bb4628..cd8ebe2835 100644 --- a/koku/masu/database/sql/reporting_ocpstoragevolumelabel_summary.sql +++ b/koku/masu/database/sql/reporting_ocpstoragevolumelabel_summary.sql @@ -187,7 +187,8 @@ ON CONFLICT DO NOTHING DELETE FROM {{schema | sqlsafe}}.reporting_ocpstoragevolumelabel_summary AS ls WHERE uuid IN ( SELECT uuid FROM {{schema | sqlsafe}}.reporting_ocpstoragevolumelabel_summary AS ls - WHERE EXISTS ( + WHERE ls.report_period_id IN {{ report_period_ids | inclause }} + AND EXISTS ( SELECT 1 FROM {{schema | sqlsafe}}.reporting_enabledtagkeys AS etk WHERE etk.enabled = false diff --git a/koku/masu/database/sql/reporting_ocpusagepodlabel_summary.sql b/koku/masu/database/sql/reporting_ocpusagepodlabel_summary.sql index 28b78ed931..5d053cbe7f 100644 --- a/koku/masu/database/sql/reporting_ocpusagepodlabel_summary.sql +++ b/koku/masu/database/sql/reporting_ocpusagepodlabel_summary.sql @@ -94,7 +94,8 @@ create unique index ix_cte_kv_cluster_agg_{{uuid | sqlsafe}} DELETE FROM {{schema | sqlsafe}}.reporting_ocpusagepodlabel_summary AS ls WHERE uuid IN ( SELECT uuid FROM {{schema | sqlsafe}}.reporting_ocpusagepodlabel_summary as ls - WHERE EXISTS ( + WHERE ls.report_period_id IN {{ report_period_ids | inclause }} + AND EXISTS ( SELECT 1 FROM {{schema | sqlsafe}}.reporting_enabledtagkeys AS etk WHERE etk.enabled = false