sql: index fields spotted in slow queries (#68317) #18

Merged
pducroquet merged 1 commits from wip/68317-sql-indexes into main 2023-03-09 16:42:57 +01:00
4 changed files with 43 additions and 1 deletions

View File

@ -0,0 +1,20 @@
# Generated by Django 3.2.18 on 2023-03-09 14:16
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('custom_user', '0034_user_email_verified_sources'),
]
operations = [
migrations.AlterField(
model_name='user',
name='username',
field=models.CharField(
blank=True, db_index=True, max_length=256, null=True, verbose_name='username'
),
),
]

View File

@ -176,7 +176,7 @@ class User(AbstractBaseUser):
uuid = models.CharField(
_('uuid'), max_length=32, default=utils_misc.get_hex_uuid, editable=False, unique=True
)
username = models.CharField(_('username'), max_length=256, null=True, blank=True)
username = models.CharField(_('username'), max_length=256, null=True, blank=True, db_index=True)
first_name = models.CharField(_('first name'), max_length=128, blank=True)
last_name = models.CharField(_('last name'), max_length=128, blank=True)
email = models.EmailField(_('email address'), blank=True, max_length=254, validators=[email_validator])

View File

@ -0,0 +1,19 @@
# Generated by Django 3.2.18 on 2023-03-09 14:16
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('saml', '0019_auto_20200621_1558'),
]
operations = [
migrations.AddIndex(
model_name='libertysession',
index=models.Index(
fields=['provider_id', 'django_session_key'], name='saml_libert_provide_39bb6c_idx'
),
),
]

View File

@ -644,6 +644,9 @@ class LibertySession(models.Model):
class Meta:
verbose_name = _("SAML session")
verbose_name_plural = _("SAML sessions")
indexes = [
models.Index(fields=['provider_id', 'django_session_key']),
]
class KeyValue(models.Model):