Files
zulip/zerver/migrations/0528_realmauditlog_zerver_realmauditlog_user_activations_idx.py
Alex Vandiver 3ea0d73182 zerver: Add a partial audit log index for counting active users.
This index is used by `active_users_audit:is_bot:day`, and provides
roughly a 2x speedup.  The existing
`zerver_realmauditlog_realm__event_type__event_time` is used if there
is a realm limit, but the standard statistics fill runs for all realms
at once, and thus cannot use it.
2024-06-03 12:35:35 -07:00

27 lines
864 B
Python

from django.contrib.postgres.operations import AddIndexConcurrently
from django.db import migrations, models
class Migration(migrations.Migration):
atomic = False
dependencies = [
("zerver", "0527_presencesequence"),
]
operations = [
AddIndexConcurrently(
model_name="realmauditlog",
index=models.Index(
# event_type__in:
# AbstractRealmAuditLog.USER_CREATED,
# AbstractRealmAuditLog.USER_ACTIVATED,
# AbstractRealmAuditLog.USER_DEACTIVATED,
# AbstractRealmAuditLog.USER_REACTIVATED,
condition=models.Q(("event_type__in", [101, 102, 103, 104])),
fields=["modified_user", "event_time"],
name="zerver_realmauditlog_user_activations_idx",
),
),
]