This gets PostgreSQL to generate *much* better query plans, gaining us
about two orders of magnitude in performance on the /list/ query for the
worst state project on the patchwork.ozlabs.org instance (qemu-devel).
Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
[stephenfin: Regenerate migrations per addition of 0027 in earlier
patch]
Signed-off-by: Stephen Finucane <stephen@that.guru>
--- /dev/null
+# -*- coding: utf-8 -*-
+# Generated by Django 1.11.15 on 2018-08-31 23:47
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('patchwork', '0029_add_list_covering_index'),
+ ]
+
+ operations = [
+ migrations.AddIndex(
+ model_name='submission',
+ index=models.Index(fields=['date', 'project', 'submitter', 'name'], name='submission_covering_idx'),
+ ),
+ ]
class Meta:
ordering = ['date']
unique_together = [('msgid', 'project')]
+ indexes = [
+ # This is a covering index for the /list/ query
+ # Like what we have for Patch, but used for displaying what we want
+ # rather than for working out the count (of course, this all
+ # depends on the SQL optimiser of your db engine)
+ models.Index(fields=['date', 'project', 'submitter', 'name'],
+ name='submission_covering_idx'),
+ ]
class SeriesMixin(object):