add some indexes

5% improvement
pull/94/head^2
eric 2024-11-22 15:31:06 -05:00
parent 7bd6fba096
commit fc0d32e541
2 changed files with 27 additions and 2 deletions

View File

@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.29 on 2024-11-22 15:25
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('core', '0028_auto_20240819_1450'),
]
operations = [
migrations.AlterField(
model_name='subject',
name='name',
field=models.CharField(db_index=True, max_length=200, unique=True),
),
migrations.AlterField(
model_name='work',
name='is_free',
field=models.BooleanField(db_index=True, default=False),
),
]

View File

@ -130,7 +130,7 @@ class Work(models.Model):
# repurposed earliest_publication to actually be publication range # repurposed earliest_publication to actually be publication range
publication_range = models.CharField(max_length=50, null=True, blank=True) publication_range = models.CharField(max_length=50, null=True, blank=True)
featured = models.DateTimeField(null=True, blank=True, db_index=True,) featured = models.DateTimeField(null=True, blank=True, db_index=True,)
is_free = models.BooleanField(default=False) is_free = models.BooleanField(default=False, db_index=True)
related = models.ManyToManyField('self', symmetrical=False, blank=True, through='WorkRelation', related_name='reverse_related') related = models.ManyToManyField('self', symmetrical=False, blank=True, through='WorkRelation', related_name='reverse_related')
age_level = models.CharField(max_length=5, choices=AGE_LEVEL_CHOICES, default='', blank=True) age_level = models.CharField(max_length=5, choices=AGE_LEVEL_CHOICES, default='', blank=True)
@ -787,7 +787,7 @@ AUTHMATCH = re.compile(r'\s*!([a-z]+):?\s+(.*)')
class Subject(models.Model): class Subject(models.Model):
created = models.DateTimeField(auto_now_add=True) created = models.DateTimeField(auto_now_add=True)
name = models.CharField(max_length=200, unique=True) name = models.CharField(max_length=200, unique=True, db_index=True)
works = models.ManyToManyField("Work", related_name="subjects") works = models.ManyToManyField("Work", related_name="subjects")
is_visible = models.BooleanField(default=True) is_visible = models.BooleanField(default=True)
authority = models.CharField(max_length=10, blank=False, default="") authority = models.CharField(max_length=10, blank=False, default="")