Skip to content

Commit cb2d754

Browse files
committed
OpenConceptLab/ocl_issues#1035 Slow concepts and mappings select
1 parent 10d40e9 commit cb2d754

4 files changed

Lines changed: 44 additions & 2 deletions

File tree

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Generated by Django 3.2.7 on 2021-10-12 11:07
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('concepts', '0020_auto_20211012_1025'),
10+
]
11+
12+
operations = [
13+
migrations.RemoveIndex(
14+
model_name='concept',
15+
name='concepts_is_acti_ee42ab_idx',
16+
),
17+
migrations.AddIndex(
18+
model_name='concept',
19+
index=models.Index(fields=['is_active', 'retired', 'is_latest_version', 'public_access', '-updated_at'], name='concepts_is_acti_ec40a2_idx'),
20+
),
21+
]

core/concepts/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ class Meta:
143143
db_table = 'concepts'
144144
unique_together = ('mnemonic', 'version', 'parent')
145145
indexes = [
146-
models.Index(fields=['is_active', 'retired', 'is_latest_version', 'public_access', 'updated_at']),
146+
models.Index(fields=['is_active', 'retired', 'is_latest_version', 'public_access', '-updated_at']),
147147
] + VersionedModel.Meta.indexes
148148

149149
external_id = models.TextField(null=True, blank=True)
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Generated by Django 3.2.7 on 2021-10-12 11:07
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('mappings', '0021_remove_mapping_internal_reference_id'),
10+
]
11+
12+
operations = [
13+
migrations.RemoveIndex(
14+
model_name='mapping',
15+
name='mappings_is_acti_ccfa00_idx',
16+
),
17+
migrations.AddIndex(
18+
model_name='mapping',
19+
index=models.Index(fields=['is_active', 'retired', 'is_latest_version', 'public_access', '-updated_at'], name='mappings_is_acti_3af71d_idx'),
20+
),
21+
]

core/mappings/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class Meta:
2121
db_table = 'mappings'
2222
unique_together = ('mnemonic', 'version', 'parent')
2323
indexes = [
24-
models.Index(fields=['is_active', 'retired', 'is_latest_version', 'public_access']),
24+
models.Index(fields=['is_active', 'retired', 'is_latest_version', 'public_access', '-updated_at']),
2525
] + VersionedModel.Meta.indexes
2626

2727
parent = models.ForeignKey('sources.Source', related_name='mappings_set', on_delete=models.CASCADE)

0 commit comments

Comments
 (0)