Попытка оптимизации #3 (Индексы)

This commit is contained in:
zakhy 2025-06-06 11:04:23 +07:00
parent bae2125269
commit 7912998c94
7 changed files with 155 additions and 14 deletions

View File

@ -0,0 +1,37 @@
# Generated by Django 3.2.25 on 2025-06-06 11:00
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('gto', '0022_auto_20250606_1015'),
]
operations = [
migrations.RemoveIndex(
model_name='equipment',
name='gto_equipme_time_91d62e_idx',
),
migrations.RemoveIndex(
model_name='equipment',
name='gto_equipme_block_328df7_idx',
),
migrations.RemoveIndex(
model_name='equipmenttracking',
name='gto_equipme_equipme_490e56_idx',
),
migrations.RemoveIndex(
model_name='equipmenttracking',
name='gto_equipme_time_e9a7cd_idx',
),
migrations.AddIndex(
model_name='equipment',
index=models.Index(fields=['time'], name='gto_equipme_time_f2ed8b_idx'),
),
migrations.AddIndex(
model_name='equipmenttracking',
index=models.Index(fields=['time'], name='gto_equipme_time_ffb373_idx'),
),
]

View File

@ -107,9 +107,8 @@ class Equipment(models.Model): # Оборудование
verbose_name = "объект"
verbose_name_plural = "объекты"
indexes = [
models.Index(fields=["uid", ]),
models.Index(fields=["name", ]),
models.Index(fields=["-time", ]),
models.Index(fields=["block", "-time"]),
models.Index(fields=["uid"]),
models.Index(fields=["name"]),
models.Index(fields=["time"]),
models.Index(fields=["block", "time"]),
]

View File

@ -63,7 +63,6 @@ class EquipmentTracking(models.Model): # Передвижение оборуд
verbose_name_plural = "Передвижение оборудования"
indexes = [
models.Index(fields=["eventid"]),
models.Index(fields=["equipment", "-time"]),
models.Index(fields=["-time"]),
models.Index(fields=["time"]),
models.Index(fields=["equipment", "time"]),
]

View File

@ -0,0 +1,77 @@
# Generated by Django 3.2.25 on 2025-06-06 11:00
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('workerslocation', '0014_auto_20250606_0959'),
]
operations = [
migrations.RemoveIndex(
model_name='workerslocation',
name='uid_idx',
),
migrations.RemoveIndex(
model_name='workerslocation',
name='name_idx',
),
migrations.RemoveIndex(
model_name='workerslocation',
name='neg_update_time_idx',
),
migrations.RemoveIndex(
model_name='workerslocation',
name='active_neg_update_time_idx',
),
migrations.RemoveIndex(
model_name='workerslocation',
name='active_update_icon_idx',
),
migrations.RemoveIndex(
model_name='workerstracking',
name='workersloca_worker__c2007b_idx',
),
migrations.RemoveIndex(
model_name='workerstracking',
name='workersloca_time_4b870c_idx',
),
migrations.RemoveIndex(
model_name='workerstracking',
name='worker_time_idx',
),
migrations.AddIndex(
model_name='workerslocation',
index=models.Index(fields=['uid'], name='workersloca_uid_cbf84d_idx'),
),
migrations.AddIndex(
model_name='workerslocation',
index=models.Index(fields=['name'], name='workersloca_name_cc95e1_idx'),
),
migrations.AddIndex(
model_name='workerslocation',
index=models.Index(fields=['active'], name='workersloca_active_a8a207_idx'),
),
migrations.AddIndex(
model_name='workerslocation',
index=models.Index(fields=['active', 'update_time'], name='workersloca_active_c3b753_idx'),
),
migrations.AddIndex(
model_name='workerslocation',
index=models.Index(fields=['icon'], name='workersloca_icon_id_a97339_idx'),
),
migrations.AddIndex(
model_name='workerstracking',
index=models.Index(fields=['worker'], name='workersloca_worker__d7aec1_idx'),
),
migrations.AddIndex(
model_name='workerstracking',
index=models.Index(fields=['time'], name='workersloca_time_9a1c92_idx'),
),
migrations.AddIndex(
model_name='workerstracking',
index=models.Index(fields=['worker', 'time'], name='workersloca_worker__f6ee2a_idx'),
),
]

View File

@ -0,0 +1,29 @@
# Generated by Django 3.2.25 on 2025-06-06 11:04
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('workerslocation', '0015_auto_20250606_1100'),
]
operations = [
migrations.RemoveIndex(
model_name='workerslocation',
name='workersloca_active_c3b753_idx',
),
migrations.RemoveIndex(
model_name='workerstracking',
name='workersloca_worker__f6ee2a_idx',
),
migrations.AddIndex(
model_name='workerslocation',
index=models.Index(fields=['update_time', 'active'], name='workersloca_update__4a6860_idx'),
),
migrations.AddIndex(
model_name='workerstracking',
index=models.Index(fields=['time', 'worker'], name='workersloca_time_83493b_idx'),
),
]

View File

@ -83,9 +83,9 @@ class WorkersLocation(models.Model):
verbose_name = "объект"
verbose_name_plural = "объекты"
indexes = [
models.Index(fields=["uid"], name="uid_idx"),
models.Index(fields=["name"], name="name_idx"),
models.Index(fields=["-update_time"], name="neg_update_time_idx"),
models.Index(fields=["active", "-update_time"], name="active_neg_update_time_idx"),
models.Index(fields=["active", "update_time", "icon"], name="active_update_icon_idx"),
models.Index(fields=["uid"]),
models.Index(fields=["name"]),
models.Index(fields=["active"]),
models.Index(fields=["update_time", "active"]),
models.Index(fields=["icon"]),
]

View File

@ -59,7 +59,7 @@ class WorkersTracking(models.Model): # Передвижение персона
verbose_name = "Передвижение сотрудника"
verbose_name_plural = "Передвижения сотрудников"
indexes = [
models.Index(fields=["worker", "-time"]),
models.Index(fields=["-time",]),
models.Index(fields=["worker", "time"], name="worker_time_idx"),
models.Index(fields=["worker"]),
models.Index(fields=["time",]),
models.Index(fields=["time","worker"]),
]