Index the user field of the recent document model to reduce view rendering as per profiling results.

This commit is contained in:
Roberto Rosario
2015-08-24 03:04:24 -04:00
parent 603d2e7417
commit fbc28f5bbc
2 changed files with 33 additions and 1 deletions

View File

@@ -0,0 +1,30 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('documents', '0026_auto_20150729_2140'),
]
operations = [
migrations.AlterModelOptions(
name='documenttypefilename',
options={'ordering': ('filename',), 'verbose_name': 'Quick rename template', 'verbose_name_plural': 'Quick rename templates'},
),
migrations.AlterField(
model_name='document',
name='is_stub',
field=models.BooleanField(default=True, help_text='A document stub is a document with an entry on the database but no file uploaded. This could be an interrupted upload or a deferred upload via the API.', verbose_name='Is stub?', editable=False),
preserve_default=True,
),
migrations.AlterField(
model_name='documenttypefilename',
name='filename',
field=models.CharField(max_length=128, verbose_name='Label', db_index=True),
preserve_default=True,
),
]

View File

@@ -756,7 +756,9 @@ class RecentDocument(models.Model):
Keeps a list of the n most recent accessed or created document for
a given user
"""
user = models.ForeignKey(User, editable=False, verbose_name=_('User'))
user = models.ForeignKey(
User, db_index=True, editable=False, verbose_name=_('User')
)
document = models.ForeignKey(
Document, editable=False, verbose_name=_('Document')
)