zilencer: Add some indexes on Remote* models.

These are for making fix_remote_realm_foreign_keys more efficient.
This commit is contained in:
Mateusz Mandera 2023-12-05 22:45:00 +01:00 committed by Tim Abbott
parent 39b0628f09
commit d631c76747
2 changed files with 64 additions and 0 deletions

View File

@ -0,0 +1,44 @@
# Generated by Django 4.2.7 on 2023-12-05 19:33
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("zilencer", "0044_remoterealmbillinguser"),
]
operations = [
migrations.AddIndex(
model_name="remoterealmauditlog",
index=models.Index(
condition=models.Q(("remote_realm__isnull", True)),
fields=["server", "realm_id"],
name="zilencer_remoterealmauditlog_server_realm",
),
),
migrations.AddIndex(
model_name="remoterealmauditlog",
index=models.Index(
condition=models.Q(("remote_realm__isnull", True)),
fields=["server"],
name="zilencer_remoterealmauditlog_server",
),
),
migrations.AddIndex(
model_name="remoterealmcount",
index=models.Index(
condition=models.Q(("remote_realm__isnull", True)),
fields=["server", "realm_id"],
name="zilencer_remoterealmcount_server_realm",
),
),
migrations.AddIndex(
model_name="remoterealmcount",
index=models.Index(
condition=models.Q(("remote_realm__isnull", True)),
fields=["server"],
name="zilencer_remoterealmcount_server",
),
),
]

View File

@ -212,6 +212,16 @@ class RemoteRealmAuditLog(AbstractRealmAuditLog):
fields=["server", "realm_id", "remote_id"],
name="zilencer_remoterealmauditlog_server_realm_remote",
),
models.Index(
fields=["server", "realm_id"],
condition=Q(remote_realm__isnull=True),
name="zilencer_remoterealmauditlog_server_realm",
),
models.Index(
fields=["server"],
condition=Q(remote_realm__isnull=True),
name="zilencer_remoterealmauditlog_server",
),
]
@ -296,6 +306,16 @@ class RemoteRealmCount(BaseRemoteCount):
fields=["property", "end_time"],
name="zilencer_remoterealmcount_property_end_time_506a0b38_idx",
),
models.Index(
fields=["server", "realm_id"],
condition=Q(remote_realm__isnull=True),
name="zilencer_remoterealmcount_server_realm",
),
models.Index(
fields=["server"],
condition=Q(remote_realm__isnull=True),
name="zilencer_remoterealmcount_server",
),
]
@override