From e689a459dee231a20a2eb83eb5a5805877860a1e Mon Sep 17 00:00:00 2001 From: Tanya Tereshchenko Date: Tue, 30 Mar 2021 19:36:07 +0200 Subject: [PATCH] Add missing indices It should potentially improve performance of some queries a bit. No benchmarking is done, just those fields are used in various queries. closes #6742 https://pulp.plan.io/issues/6742 --- CHANGES/6742.misc | 1 + .../migrations/0028_create_missing_indices.py | 46 +++++++++++++++++++ pulp_2to3_migration/app/models/content.py | 1 + pulp_2to3_migration/app/models/repository.py | 7 +++ 4 files changed, 55 insertions(+) create mode 100644 CHANGES/6742.misc create mode 100644 pulp_2to3_migration/app/migrations/0028_create_missing_indices.py diff --git a/CHANGES/6742.misc b/CHANGES/6742.misc new file mode 100644 index 00000000..ea75d667 --- /dev/null +++ b/CHANGES/6742.misc @@ -0,0 +1 @@ +Added some indices used in various queries. diff --git a/pulp_2to3_migration/app/migrations/0028_create_missing_indices.py b/pulp_2to3_migration/app/migrations/0028_create_missing_indices.py new file mode 100644 index 00000000..d3bd13f0 --- /dev/null +++ b/pulp_2to3_migration/app/migrations/0028_create_missing_indices.py @@ -0,0 +1,46 @@ +# Generated by Django 2.2.19 on 2021-03-30 17:33 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('pulp_2to3_migration', '0027_pulp2repocontent_created_index'), + ] + + operations = [ + migrations.AddIndex( + model_name='pulp2content', + index=models.Index(fields=['pulp2_last_updated'], name='pulp_2to3_m_pulp2_l_c8b0d6_idx'), + ), + migrations.AddIndex( + model_name='pulp2distributor', + index=models.Index(fields=['pulp2_last_updated'], name='pulp_2to3_m_pulp2_l_2c5996_idx'), + ), + migrations.AddIndex( + model_name='pulp2distributor', + index=models.Index(fields=['pulp2_repo_id'], name='pulp_2to3_m_pulp2_r_77bd32_idx'), + ), + migrations.AddIndex( + model_name='pulp2importer', + index=models.Index(fields=['pulp2_last_updated'], name='pulp_2to3_m_pulp2_l_2bbfde_idx'), + ), + migrations.AddIndex( + model_name='pulp2repository', + index=models.Index(fields=['pulp2_last_unit_added'], name='pulp_2to3_m_pulp2_l_270629_idx'), + ), + migrations.AddIndex( + model_name='pulp2repository', + index=models.Index(fields=['pulp2_last_unit_removed'], name='pulp_2to3_m_pulp2_l_2de33d_idx'), + ), + migrations.AddIndex( + model_name='pulp2repository', + index=models.Index(fields=['pulp2_repo_id'], name='pulp_2to3_m_pulp2_r_68b419_idx'), + ), + migrations.AddIndex( + model_name='pulp2importer', + index=models.Index(fields=['pulp2_repo_id'], name='pulp_2to3_m_pulp2_r_46adaf_idx'), + ), + + ] diff --git a/pulp_2to3_migration/app/models/content.py b/pulp_2to3_migration/app/models/content.py index 313b28ce..c73d7687 100644 --- a/pulp_2to3_migration/app/models/content.py +++ b/pulp_2to3_migration/app/models/content.py @@ -49,6 +49,7 @@ class Meta: ] indexes = [ models.Index(fields=['pulp2_content_type_id']), + models.Index(fields=['pulp2_last_updated']), ] diff --git a/pulp_2to3_migration/app/models/repository.py b/pulp_2to3_migration/app/models/repository.py index 12a4bd6f..b5c78671 100644 --- a/pulp_2to3_migration/app/models/repository.py +++ b/pulp_2to3_migration/app/models/repository.py @@ -65,6 +65,9 @@ class Pulp2Repository(BaseModel): class Meta: indexes = [ models.Index(fields=['pulp2_repo_type']), + models.Index(fields=['pulp2_last_unit_added']), + models.Index(fields=['pulp2_last_unit_removed']), + models.Index(fields=['pulp2_repo_id']), ] @@ -128,6 +131,8 @@ class Pulp2Importer(BaseModel): class Meta: indexes = [ models.Index(fields=['pulp2_type_id']), + models.Index(fields=['pulp2_last_updated']), + models.Index(fields=['pulp2_repo_id']), ] @@ -178,4 +183,6 @@ class Meta: unique_together = ('pulp2_object_id',) indexes = [ models.Index(fields=['pulp2_type_id']), + models.Index(fields=['pulp2_last_updated']), + models.Index(fields=['pulp2_repo_id']), ]