From 3770efd069ff9e9b9dd87cc60351078210527194 Mon Sep 17 00:00:00 2001 From: Colleen O'Rourke Date: Fri, 8 Aug 2025 15:43:30 -0700 Subject: [PATCH 1/3] feat(inc): Add index to GroupOpenPeriod data jsonfield --- src/sentry/models/groupopenperiod.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/sentry/models/groupopenperiod.py b/src/sentry/models/groupopenperiod.py index d5d7adef14cd1e..f3a89033183d6e 100644 --- a/src/sentry/models/groupopenperiod.py +++ b/src/sentry/models/groupopenperiod.py @@ -73,6 +73,10 @@ class Meta: indexes = ( # get all open periods since a certain date models.Index(fields=("group", "date_started")), + models.Index( + models.F("data__pending_incident_detector_id"), + name="data__pend_inc_detector_id_idx", + ), ) constraints = ( From aab255c0def3b79a4083b120b343a9a39039e655 Mon Sep 17 00:00:00 2001 From: Colleen O'Rourke Date: Fri, 8 Aug 2025 16:06:54 -0700 Subject: [PATCH 2/3] rebase --- migrations_lockfile.txt | 2 +- ...riod_data_pending_inc_detector_id_index.py | 35 +++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 src/sentry/migrations/0966_groupopenperiod_data_pending_inc_detector_id_index.py diff --git a/migrations_lockfile.txt b/migrations_lockfile.txt index 2d03a269bd5daf..9e9f6cb59f86fc 100644 --- a/migrations_lockfile.txt +++ b/migrations_lockfile.txt @@ -27,7 +27,7 @@ preprod: 0014_commitcomparisons_fk replays: 0006_add_bulk_delete_job -sentry: 0965_gzippeddict_big_tables +sentry: 0966_groupopenperiod_data_pending_inc_detector_id_index social_auth: 0003_social_auth_json_field diff --git a/src/sentry/migrations/0966_groupopenperiod_data_pending_inc_detector_id_index.py b/src/sentry/migrations/0966_groupopenperiod_data_pending_inc_detector_id_index.py new file mode 100644 index 00000000000000..0cc87a5fc83272 --- /dev/null +++ b/src/sentry/migrations/0966_groupopenperiod_data_pending_inc_detector_id_index.py @@ -0,0 +1,35 @@ +# Generated by Django 5.2.1 on 2025-08-08 23:06 + +from django.db import migrations, models + +from sentry.new_migrations.migrations import CheckedMigration + + +class Migration(CheckedMigration): + # This flag is used to mark that a migration shouldn't be automatically run in production. + # This should only be used for operations where it's safe to run the migration after your + # code has deployed. So this should not be used for most operations that alter the schema + # of a table. + # Here are some things that make sense to mark as post deployment: + # - Large data migrations. Typically we want these to be run manually so that they can be + # monitored and not block the deploy for a long period of time while they run. + # - Adding indexes to large tables. Since this can take a long time, we'd generally prefer to + # run this outside deployments so that we don't block them. Note that while adding an index + # is a schema change, it's completely safe to run the operation after the code has deployed. + # Once deployed, run these manually via: https://develop.sentry.dev/database-migrations/#migration-deployment + + is_post_deployment = False + + dependencies = [ + ("sentry", "0965_gzippeddict_big_tables"), + ] + + operations = [ + migrations.AddIndex( + model_name="groupopenperiod", + index=models.Index( + models.F("data__pending_incident_detector_id"), + name="data__pend_inc_detector_id_idx", + ), + ), + ] From 9a25ed7676a6b32f577e2d4513d971eea885bfd8 Mon Sep 17 00:00:00 2001 From: Colleen O'Rourke Date: Mon, 11 Aug 2025 09:32:37 -0700 Subject: [PATCH 3/3] make post deployment --- .../0966_groupopenperiod_data_pending_inc_detector_id_index.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sentry/migrations/0966_groupopenperiod_data_pending_inc_detector_id_index.py b/src/sentry/migrations/0966_groupopenperiod_data_pending_inc_detector_id_index.py index 0cc87a5fc83272..1decad68a2d9cc 100644 --- a/src/sentry/migrations/0966_groupopenperiod_data_pending_inc_detector_id_index.py +++ b/src/sentry/migrations/0966_groupopenperiod_data_pending_inc_detector_id_index.py @@ -18,7 +18,7 @@ class Migration(CheckedMigration): # is a schema change, it's completely safe to run the operation after the code has deployed. # Once deployed, run these manually via: https://develop.sentry.dev/database-migrations/#migration-deployment - is_post_deployment = False + is_post_deployment = True dependencies = [ ("sentry", "0965_gzippeddict_big_tables"),