Add index on Status.remote_id

This field is often used in WHERE-clauses in queries that are very slow on bookwyrm.social.
This commit is contained in:
Bart Schuurmans 2024-04-02 21:54:30 +02:00
parent f28800af7f
commit 4bbdd0b2d0
2 changed files with 22 additions and 0 deletions

View file

@ -0,0 +1,19 @@
# Generated by Django 3.2.25 on 2024-04-02 19:53
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("bookwyrm", "0198_book_search_vector_author_aliases"),
]
operations = [
migrations.AddIndex(
model_name="status",
index=models.Index(
fields=["remote_id"], name="bookwyrm_st_remote__06aeba_idx"
),
),
]

View file

@ -80,6 +80,9 @@ class Status(OrderedCollectionPageMixin, BookWyrmModel):
"""default sorting""" """default sorting"""
ordering = ("-published_date",) ordering = ("-published_date",)
indexes = [
models.Index(fields=["remote_id"]),
]
def save(self, *args, **kwargs): def save(self, *args, **kwargs):
"""save and notify""" """save and notify"""