[Patchew-devel] [PATCH] add more indices to Message

Paolo Bonzini posted 1 patch 5 years, 5 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/patchew-ci tags/patchew/20181031144005.5699-1-pbonzini@redhat.com
There is a newer version of this series
api/migrations/0037_auto_20181031_1439.py | 19 +++++++++++++++++++
api/models.py                             |  4 ++++
2 files changed, 23 insertions(+)
create mode 100644 api/migrations/0037_auto_20181031_1439.py
[Patchew-devel] [PATCH] add more indices to Message
Posted by Paolo Bonzini 5 years, 5 months ago
Add indices to help the series list page.  The project is almost always
used as a search key, either directly or through a parent project, so
include both a variant with the project and one without.  The sorting
keys are left last, while filter keys should come first.

This reduces the SELECT COUNT(*) query in the series list from 180 ms
to 5 ms on a full dump from a few weeks ago.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 api/migrations/0037_auto_20181031_1439.py | 19 +++++++++++++++++++
 api/models.py                             |  4 ++++
 2 files changed, 23 insertions(+)
 create mode 100644 api/migrations/0037_auto_20181031_1439.py

diff --git a/api/migrations/0037_auto_20181031_1439.py b/api/migrations/0037_auto_20181031_1439.py
new file mode 100644
index 0000000..ca75e37
--- /dev/null
+++ b/api/migrations/0037_auto_20181031_1439.py
@@ -0,0 +1,19 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.11.15 on 2018-10-31 14:39
+from __future__ import unicode_literals
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('api', '0036_populate_message_tags'),
+    ]
+
+    operations = [
+        migrations.AlterIndexTogether(
+            name='message',
+            index_together=set([('is_series_head', 'project', 'date'), ('is_series_head', 'date'), ('is_series_head', 'last_reply_date'), ('is_series_head', 'project', 'last_reply_date')]),
+        ),
+    ]
diff --git a/api/models.py b/api/models.py
index ab0bd06..09758f6 100644
--- a/api/models.py
+++ b/api/models.py
@@ -714,6 +714,10 @@ class Message(models.Model):
 
     class Meta:
         unique_together = ('project', 'message_id',)
+        index_together = [('is_series_head', 'project', 'last_reply_date'),
+                          ('is_series_head', 'project', 'date'),
+                          ('is_series_head', 'last_reply_date'),
+                          ('is_series_head', 'date')]
 
 class MessageResult(Result):
     message = models.ForeignKey(Message, related_name='results')
-- 
2.17.1

_______________________________________________
Patchew-devel mailing list
Patchew-devel@redhat.com
https://www.redhat.com/mailman/listinfo/patchew-devel