mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 13:03:29 +00:00
zilencer: Update remoterealm indexes.
There is no reason to have an index on just `realm_id` or `remote_id`, as those values mean nothing outside of the scope of a specific `server_id`. Remove those never-used single-column indexes from the two tables that have them. By contrast, the pair of `server_id` and `remote_id` is quite useful and specific -- it is a unique pair, and every POST of statistics from a remote host requires looking up the highest `remote_id` for a given `server_id`, which (without this index) is otherwise a quite large scan. Add a unique constraint, which (in PostgreSQL) is implemented as a unique index.
This commit is contained in:
committed by
Tim Abbott
parent
d228c502e9
commit
902498ec4f
45
zilencer/migrations/0029_update_remoterealm_indexes.py
Normal file
45
zilencer/migrations/0029_update_remoterealm_indexes.py
Normal file
@@ -0,0 +1,45 @@
|
||||
# Generated by Django 4.2.5 on 2023-09-13 05:02
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
("zilencer", "0028_rename_extradatajson_remoteauditlog_extra_data"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name="remoterealmauditlog",
|
||||
name="realm_id",
|
||||
field=models.IntegerField(),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name="remoterealmauditlog",
|
||||
name="remote_id",
|
||||
field=models.IntegerField(),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name="remoterealmcount",
|
||||
name="realm_id",
|
||||
field=models.IntegerField(),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name="remoterealmcount",
|
||||
name="remote_id",
|
||||
field=models.IntegerField(),
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name="remoterealmauditlog",
|
||||
constraint=models.UniqueConstraint(
|
||||
fields=("server", "remote_id"), name="zilencer_remoterealmauditlog_server_remote"
|
||||
),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name="remoterealmauditlog",
|
||||
index=models.Index(
|
||||
fields=["server", "realm_id", "remote_id"],
|
||||
name="zilencer_remoterealmauditlog_server_realm_remote",
|
||||
),
|
||||
),
|
||||
]
|
||||
Reference in New Issue
Block a user