Skip to content

Commit

Permalink
add database indexes to speed up oai-pmh
Browse files Browse the repository at this point in the history
  • Loading branch information
aaxelb committed May 21, 2024
1 parent 8c018eb commit 3c53ffd
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
23 changes: 23 additions & 0 deletions trove/migrations/0005_indexes_for_oaipmh.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 3.2.25 on 2024-05-21 19:11

from django.db import migrations, models
from django.contrib.postgres.operations import AddIndexConcurrently


class Migration(migrations.Migration):
atomic = False # allow adding indexes concurrently (without locking tables)

dependencies = [
('trove', '0004_auto_20230804_2021'),
]

operations = [
AddIndexConcurrently(
model_name='indexcard',
index=models.Index(fields=['deleted'], name='trove_index_deleted_bcffde_idx'),
),
AddIndexConcurrently(
model_name='latestindexcardrdf',
index=models.Index(fields=['modified'], name='trove_lates_modifie_c6b0b1_idx'),
),
]
8 changes: 8 additions & 0 deletions trove/models/indexcard.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@ class Indexcard(models.Model):
related_name='+',
)

class Meta:
indexes = [
models.Index(fields=('deleted',)),
]

@property
def latest_rdf(self) -> Optional['LatestIndexcardRdf']:
'''convenience for the "other side" of LatestIndexcardRdf.indexcard
Expand Down Expand Up @@ -242,6 +247,9 @@ class Meta:
name='%(app_label)s_%(class)s_uniq_indexcard',
),
]
indexes = [
models.Index(fields=('modified',)),
]


class ArchivedIndexcardRdf(IndexcardRdf):
Expand Down

0 comments on commit 3c53ffd

Please sign in to comment.