Adding extra index to improve slow queries speed

remotes/origin/fixing-ordering-on-archived
Jesús Espino 2017-04-06 09:34:26 +02:00
parent 8f1f001872
commit 3dccb9e90e
3 changed files with 39 additions and 1 deletions

View File

@ -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')]),
),
]

View File

@ -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 *

View File

@ -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'))"),
]