From 03d4bd47acfcdc6444fdc689ceeb636c5a4e2cae Mon Sep 17 00:00:00 2001 From: Jan Szejko Date: Mon, 26 Feb 2018 15:05:06 +0100 Subject: [PATCH 1/1] add index on popularity count --- .../migrations/0022_auto_20180226_1503.py | 19 +++++++++++++++++++ src/catalogue/models/book.py | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 src/catalogue/migrations/0022_auto_20180226_1503.py diff --git a/src/catalogue/migrations/0022_auto_20180226_1503.py b/src/catalogue/migrations/0022_auto_20180226_1503.py new file mode 100644 index 000000000..a673f42e3 --- /dev/null +++ b/src/catalogue/migrations/0022_auto_20180226_1503.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('catalogue', '0021_auto_20171222_1404'), + ] + + operations = [ + migrations.AlterField( + model_name='bookpopularity', + name='count', + field=models.IntegerField(default=0, db_index=True), + ), + ] diff --git a/src/catalogue/models/book.py b/src/catalogue/models/book.py index 0f664c42d..8b85ec718 100644 --- a/src/catalogue/models/book.py +++ b/src/catalogue/models/book.py @@ -715,4 +715,4 @@ add_file_fields() class BookPopularity(models.Model): book = models.OneToOneField(Book, related_name='popularity') - count = models.IntegerField(default=0) + count = models.IntegerField(default=0, db_index=True) -- 2.20.1