Added db index to siteinterfacedictionary text for optimize

This commit is contained in:
dormantman 2020-01-18 01:04:30 +03:00
parent be96a6c7ba
commit 51114b0e95
2 changed files with 22 additions and 0 deletions

View File

@ -0,0 +1,18 @@
# Generated by Django 2.2.7 on 2020-01-17 22:01
import django.contrib.postgres.indexes
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('translation', '0007_language_is_active'),
]
operations = [
migrations.AddIndex(
model_name='siteinterfacedictionary',
index=django.contrib.postgres.indexes.GinIndex(fields=['text'], name='translation_text_0b2bfa_gin'),
),
]

View File

@ -1,5 +1,6 @@
"""Translation app models."""
from django.contrib.postgres.fields import JSONField
from django.contrib.postgres.indexes import GinIndex
from django.db import models
from django.utils.translation import gettext_lazy as _
from django.apps import apps
@ -105,6 +106,9 @@ class SiteInterfaceDictionary(ProjectBaseMixin):
verbose_name = _('Site interface dictionary')
verbose_name_plural = _('Site interface dictionary')
indexes = [
GinIndex(fields=['text'])
]
def __str__(self):
return f'{self.page}: {self.keywords}'