Skip to content

Commit 6474393

Browse files
authored
Telemetry: create index to speed up queries (#12432)
Fixes https://read-the-docs.sentry.io/issues/5537486737/
1 parent 43ad56f commit 6474393

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Generated by Django 5.2.4 on 2025-08-22 12:14
2+
3+
from django.db import migrations
4+
from django.db import models
5+
from django_safemigrate import Safe
6+
7+
8+
class Migration(migrations.Migration):
9+
safe = Safe.before_deploy()
10+
dependencies = [
11+
("telemetry", "0001_initial"),
12+
]
13+
14+
operations = [
15+
migrations.AddIndex(
16+
model_name="builddata",
17+
index=models.Index(fields=["created"], name="telemetry_b_created_31070a_idx"),
18+
),
19+
]

readthedocs/telemetry/models.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,10 @@ def collect(self, build, data):
110110
class BuildData(TimeStampedModel):
111111
class Meta:
112112
verbose_name_plural = "Build data"
113+
indexes = [
114+
# Speeds up `delete_old_build_data` task.
115+
models.Index(fields=["created"]),
116+
]
113117

114118
data = models.JSONField()
115119
objects = BuildDataManager()

0 commit comments

Comments
 (0)