The new index uses project_id as the first key. This is important, as it seems that almost all web queries filter over project_id. The index also includes the submission date sorted descending, as this is the default sorting key for the patches list.
Signed-off-by: Franciszek Stachura <[email protected]> --- Based on the MySQL manual: https://dev.mysql.com/doc/refman/8.4/en/order-by-optimization.html I'm pretty sure that the first four fields of the index make sense. Delegate and submitter keys are more of a guess, but they also help in some queries. --- .../0049_patch_patch_covering_idx_default.py | 28 +++++++++++++++++++ patchwork/models.py | 11 ++++++++ 2 files changed, 39 insertions(+) create mode 100644 patchwork/migrations/0049_patch_patch_covering_idx_default.py diff --git a/patchwork/migrations/0049_patch_patch_covering_idx_default.py b/patchwork/migrations/0049_patch_patch_covering_idx_default.py new file mode 100644 index 00000000..272ca5ef --- /dev/null +++ b/patchwork/migrations/0049_patch_patch_covering_idx_default.py @@ -0,0 +1,28 @@ +# Generated by Django 6.0.6 on 2026-08-13 00:14 + +from django.conf import settings +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ('patchwork', '0048_series_dependencies'), + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ] + + operations = [ + migrations.AddIndex( + model_name='patch', + index=models.Index( + fields=[ + 'project', + 'archived', + 'state', + '-date', + 'delegate', + 'submitter', + ], + name='patch_covering_idx_default', + ), + ), + ] diff --git a/patchwork/models.py b/patchwork/models.py index d5cb31de..4f2008c8 100644 --- a/patchwork/models.py +++ b/patchwork/models.py @@ -735,6 +735,17 @@ class Patch(SubmissionMixin): ], name='patch_covering_idx', ), + models.Index( + fields=[ + 'project', + 'archived', + 'state', + '-date', + 'delegate', + 'submitter', + ], + name='patch_covering_idx_default', + ), ] -- 2.55.0 _______________________________________________ Patchwork mailing list [email protected] https://lists.ozlabs.org/listinfo/patchwork
