Add case-insensitive index on UserProfile.email.

This fixes a performance issue looking up UserProfile objects for
realms with a large number of users in the case that a UserProfile
object is not in the cache.

Thanks to @dbiollo for the suggestion!
This commit is contained in:
Tim Abbott 2015-12-25 12:20:57 -08:00
parent a98b0cf35d
commit ebcb569c96
1 changed files with 16 additions and 0 deletions

View File

@ -0,0 +1,16 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('zerver', '0005_auto_20150920_1340'),
]
operations = [
migrations.RunSQL("CREATE INDEX upper_userprofile_email_idx ON zerver_userprofile ((upper(email)));",
reverse_sql="DROP INDEX upper_userprofile_email_idx;"),
]