base: add a BRIN index on ResourceLog.timestamp (#88960)

This commit is contained in:
Benjamin Dauvergne 2024-04-02 13:19:01 +02:00
parent abafd19553
commit 9d1bdbcd1d
2 changed files with 25 additions and 1 deletions

View File

@ -0,0 +1,23 @@
# Generated by Django 3.2.18 on 2024-04-02 11:18
import django.contrib.postgres.indexes
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('base', '0030_resourcelog_base_resour_appname_298cbc_idx'),
]
operations = [
migrations.RemoveIndex(
model_name='resourcelog',
name='base_resour_appname_298cbc_idx',
),
migrations.AddIndex(
model_name='resourcelog',
index=django.contrib.postgres.indexes.BrinIndex(
fields=['timestamp'], name='base_resour_timesta_ca10d1_brin'
),
),
]

View File

@ -19,6 +19,7 @@ from django.conf import settings
from django.contrib.contenttypes import fields
from django.contrib.contenttypes.models import ContentType
from django.contrib.postgres.fields import ArrayField
from django.contrib.postgres.indexes import BrinIndex
from django.core.exceptions import PermissionDenied, ValidationError
from django.core.files.base import ContentFile
from django.db import connection, models, transaction
@ -914,7 +915,7 @@ class ResourceLog(models.Model):
ordering = ('id',)
permissions = (('see_resourcelog', 'Can see resource logs'),)
indexes = [
models.Index(fields=['appname', '-timestamp']),
BrinIndex(fields=['timestamp']),
]
@property