Skip to content

Commit 40a05c1

Browse files
authored
Add speed up indexes (#11614)
* Add speed up indexes This dramatically improves the normal queries we do on these tables. * Make it a list like other indexes
1 parent b7835d4 commit 40a05c1

File tree

4 files changed

+46
-0
lines changed

4 files changed

+46
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Generated by Django 4.2.16 on 2024-09-23 20:22
2+
3+
from django.db import migrations, models
4+
from django_safemigrate import Safe
5+
6+
7+
class Migration(migrations.Migration):
8+
safe = Safe.always
9+
dependencies = [
10+
("integrations", "0013_set_timestamp_fields_as_no_null"),
11+
]
12+
13+
operations = [
14+
migrations.AddIndex(
15+
model_name="httpexchange",
16+
index=models.Index(
17+
fields=["content_type", "object_id", "date"],
18+
name="integration_content_5d4e98_idx",
19+
),
20+
),
21+
]

readthedocs/integrations/models.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ class HttpExchange(models.Model):
169169

170170
class Meta:
171171
ordering = ["-date"]
172+
indexes = [models.Index(fields=["content_type", "object_id", "date"])]
172173

173174
def __str__(self):
174175
return _("Exchange {0}").format(self.pk)
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Generated by Django 4.2.16 on 2024-09-23 20:22
2+
3+
from django.db import migrations, models
4+
from django_safemigrate import Safe
5+
6+
7+
class Migration(migrations.Migration):
8+
safe = Safe.always
9+
dependencies = [
10+
("search", "0005_alter_searchquery_id"),
11+
]
12+
13+
operations = [
14+
migrations.AddIndex(
15+
model_name="searchquery",
16+
index=models.Index(
17+
fields=["modified", "project", "version"],
18+
name="search_sear_modifie_3ac4ab_idx",
19+
),
20+
),
21+
]

readthedocs/search/models.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ class SearchQuery(TimeStampedModel):
4141
class Meta:
4242
verbose_name = "Search query"
4343
verbose_name_plural = "Search queries"
44+
indexes = [
45+
models.Index(fields=["modified", "project", "version"]),
46+
]
4447

4548
def __str__(self):
4649
return self.query

0 commit comments

Comments
 (0)