mirror of https://github.com/zulip/zulip.git
audit-logs: Add index to RealmAuditLog for realm and event type.
Adds an index on RealmAuditLog for the realm, event_type, and event_time in order to improve database queries on these audit logs. tabbott verified using EXPLAIN ANALYZE that this also considerably speeds up queries that order by ID rather than event_time, but event_time is how these should be ordered given the possibility of backfills.
This commit is contained in:
parent
962ab13203
commit
1d5897060a
|
@ -0,0 +1,19 @@
|
|||
# Generated by Django 4.2.12 on 2024-04-17 10:33
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
("zerver", "0509_fix_emoji_metadata"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddIndex(
|
||||
model_name="realmauditlog",
|
||||
index=models.Index(
|
||||
fields=["realm", "event_type", "event_time"],
|
||||
name="zerver_realmauditlog_realm__event_type__event_time",
|
||||
),
|
||||
),
|
||||
]
|
|
@ -227,6 +227,10 @@ class RealmAuditLog(AbstractRealmAuditLog):
|
|||
|
||||
class Meta:
|
||||
indexes = [
|
||||
models.Index(
|
||||
name="zerver_realmauditlog_realm__event_type__event_time",
|
||||
fields=["realm", "event_type", "event_time"],
|
||||
),
|
||||
models.Index(
|
||||
name="zerver_realmauditlog_user_subscriptions_idx",
|
||||
fields=["modified_user", "modified_stream"],
|
||||
|
@ -237,7 +241,7 @@ class RealmAuditLog(AbstractRealmAuditLog):
|
|||
AbstractRealmAuditLog.SUBSCRIPTION_DEACTIVATED,
|
||||
]
|
||||
),
|
||||
)
|
||||
),
|
||||
]
|
||||
|
||||
@override
|
||||
|
|
Loading…
Reference in New Issue