Skip to content

Commit 3eb8d9f

Browse files
chore(migrations): Drop unused index in Incident table (#58449)
This PR gets rid of the index on `id, date_added`. This was originally added in #58207 to make a query in #58032 more efficient, however, after it was added, we determined that it was still really slow. We'll be using a different approach, so this one is no longer needed.
1 parent c6797f0 commit 3eb8d9f

File tree

3 files changed

+32
-5
lines changed

3 files changed

+32
-5
lines changed

migrations_lockfile.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ feedback: 0003_feedback_add_env
99
hybridcloud: 0005_add_missing_org_integration_scope
1010
nodestore: 0002_nodestore_no_dictfield
1111
replays: 0003_add_size_to_recording_segment
12-
sentry: 0576_add_missing_org_integration_scope
12+
sentry: 0577_drop_latest_incident_index
1313
social_auth: 0002_default_auto_field

src/sentry/incidents/models.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -203,10 +203,7 @@ class Meta:
203203
app_label = "sentry"
204204
db_table = "sentry_incident"
205205
unique_together = (("organization", "identifier"),)
206-
index_together = (
207-
("alert_rule", "type", "status"),
208-
("id", "date_added"),
209-
)
206+
index_together = (("alert_rule", "type", "status"),)
210207

211208
@property
212209
def current_end_date(self):
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Generated by Django 3.2.20 on 2023-10-19 15:50
2+
3+
from django.db import migrations
4+
5+
from sentry.new_migrations.migrations import CheckedMigration
6+
7+
8+
class Migration(CheckedMigration):
9+
# This flag is used to mark that a migration shouldn't be automatically run in production. For
10+
# the most part, this should only be used for operations where it's safe to run the migration
11+
# after your code has deployed. So this should not be used for most operations that alter the
12+
# schema of a table.
13+
# Here are some things that make sense to mark as dangerous:
14+
# - Large data migrations. Typically we want these to be run manually by ops so that they can
15+
# be monitored and not block the deploy for a long period of time while they run.
16+
# - Adding indexes to large tables. Since this can take a long time, we'd generally prefer to
17+
# have ops run this and not block the deploy. Note that while adding an index is a schema
18+
# change, it's completely safe to run the operation after the code has deployed.
19+
is_dangerous = False
20+
21+
dependencies = [
22+
("sentry", "0576_add_missing_org_integration_scope"),
23+
]
24+
25+
operations = [
26+
migrations.AlterIndexTogether(
27+
name="incident",
28+
index_together={("alert_rule", "type", "status")},
29+
),
30+
]

0 commit comments

Comments
 (0)