From 3dccb9e90e2ef96bd7695413da6d29bcdc7f1b61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Espino?= Date: Thu, 6 Apr 2017 09:34:26 +0200 Subject: [PATCH] Adding extra index to improve slow queries speed --- .../migrations/0007_auto_20170406_0615.py | 20 +++++++++++++++++++ taiga/timeline/models.py | 3 ++- .../migrations/0024_auto_20170406_0727.py | 17 ++++++++++++++++ 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 taiga/timeline/migrations/0007_auto_20170406_0615.py create mode 100644 taiga/users/migrations/0024_auto_20170406_0727.py diff --git a/taiga/timeline/migrations/0007_auto_20170406_0615.py b/taiga/timeline/migrations/0007_auto_20170406_0615.py new file mode 100644 index 00000000..e1b2fa77 --- /dev/null +++ b/taiga/timeline/migrations/0007_auto_20170406_0615.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.6 on 2017-04-06 06:15 +from __future__ import unicode_literals + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('contenttypes', '0002_remove_content_type_name'), + ('timeline', '0006_json_to_jsonb'), + ] + + operations = [ + migrations.AlterIndexTogether( + name='timeline', + index_together=set([('content_type', 'object_id', 'namespace'), ('namespace', 'created')]), + ), + ] diff --git a/taiga/timeline/models.py b/taiga/timeline/models.py index 3e75c0ea..2fc1ddde 100644 --- a/taiga/timeline/models.py +++ b/taiga/timeline/models.py @@ -38,7 +38,8 @@ class Timeline(models.Model): created = models.DateTimeField(default=timezone.now, db_index=True) class Meta: - index_together = [('content_type', 'object_id', 'namespace'), ] + index_together = [('content_type', 'object_id', 'namespace'), + ('namespace', 'created'),] # Register all implementations from .timeline_implementations import * diff --git a/taiga/users/migrations/0024_auto_20170406_0727.py b/taiga/users/migrations/0024_auto_20170406_0727.py new file mode 100644 index 00000000..62c4fe76 --- /dev/null +++ b/taiga/users/migrations/0024_auto_20170406_0727.py @@ -0,0 +1,17 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.6 on 2017-04-06 07:27 +from __future__ import unicode_literals + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('users', '0023_json_to_jsonb'), + ] + + operations = [ + migrations.RunSQL("CREATE INDEX ON users_user (UPPER('username'))"), + migrations.RunSQL("CREATE INDEX ON users_user (UPPER('email'))"), + ]