aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStewart Smith <stewart@linux.ibm.com>2018-08-10 18:01:03 +1000
committerStephen Finucane <stephen@that.guru>2018-09-10 14:24:24 -0600
commit332956146469575c3ceeb3ecd94c7459e1e3dbea (patch)
treeb3c38f925f41a0e3d5368a4fb524615830ddb822
parent5b8b6fb5261dc2cb1c95bc82ab7a5466e6699d03 (diff)
downloadpatchwork-332956146469575c3ceeb3ecd94c7459e1e3dbea.tar
patchwork-332956146469575c3ceeb3ecd94c7459e1e3dbea.tar.gz
Add covering index to patchwork_submissions for /list/ queries
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>
-rw-r--r--patchwork/migrations/0030_add_submission_covering_index.py19
-rw-r--r--patchwork/models.py8
2 files changed, 27 insertions, 0 deletions
diff --git a/patchwork/migrations/0030_add_submission_covering_index.py b/patchwork/migrations/0030_add_submission_covering_index.py
new file mode 100644
index 0000000..e74c0cc
--- /dev/null
+++ b/patchwork/migrations/0030_add_submission_covering_index.py
@@ -0,0 +1,19 @@
+# -*- 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'),
+ ),
+ ]
diff --git a/patchwork/models.py b/patchwork/models.py
index cfa9b6c..d2d8f34 100644
--- a/patchwork/models.py
+++ b/patchwork/models.py
@@ -383,6 +383,14 @@ class Submission(FilenameMixin, EmailMixin, models.Model):
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):