core: add index on folder and sas properties of SithFile to speed up SAS

This commit is contained in:
Antoine Bartuccio 2019-09-06 16:16:03 +02:00
parent ca042fe75e
commit 83e225a744
Signed by: klmp200
GPG Key ID: E7245548C53F904B
2 changed files with 29 additions and 2 deletions

View File

@ -0,0 +1,27 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.24 on 2019-09-06 14:15
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [("core", "0030_auto_20190704_1500")]
operations = [
migrations.AlterField(
model_name="sithfile",
name="is_folder",
field=models.BooleanField(
db_index=True, default=True, verbose_name="is folder"
),
),
migrations.AlterField(
model_name="sithfile",
name="is_in_sas",
field=models.BooleanField(
db_index=True, default=False, verbose_name="is in the SAS"
),
),
]

View File

@ -807,7 +807,7 @@ class SithFile(models.Model):
view_groups = models.ManyToManyField(
Group, related_name="viewable_files", verbose_name=_("view group"), blank=True
)
is_folder = models.BooleanField(_("is folder"), default=True)
is_folder = models.BooleanField(_("is folder"), default=True, db_index=True)
mime_type = models.CharField(_("mime type"), max_length=30)
size = models.IntegerField(_("size"), default=0)
date = models.DateTimeField(_("date"), default=timezone.now)
@ -821,7 +821,7 @@ class SithFile(models.Model):
)
asked_for_removal = models.BooleanField(_("asked for removal"), default=False)
is_in_sas = models.BooleanField(
_("is in the SAS"), default=False
_("is in the SAS"), default=False, db_index=True
) # Allows to query this flag, updated at each call to save()
class Meta: