:p
atchew
Login
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 XXXXXXX..XXXXXXX --- /dev/null +++ b/api/migrations/0037_auto_20181031_1439.py @@ -XXX,XX +XXX,XX @@ +# -*- 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 XXXXXXX..XXXXXXX 100644 --- a/api/models.py +++ b/api/models.py @@ -XXX,XX +XXX,XX @@ 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
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 ++++ tests/test_import.py | 2 +- 3 files changed, 24 insertions(+), 1 deletion(-) 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 XXXXXXX..XXXXXXX --- /dev/null +++ b/api/migrations/0037_auto_20181031_1439.py @@ -XXX,XX +XXX,XX @@ +# -*- 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 XXXXXXX..XXXXXXX 100644 --- a/api/models.py +++ b/api/models.py @@ -XXX,XX +XXX,XX @@ 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') diff --git a/tests/test_import.py b/tests/test_import.py index XXXXXXX..XXXXXXX 100755 --- a/tests/test_import.py +++ b/tests/test_import.py @@ -XXX,XX +XXX,XX @@ class ImportTest(PatchewTestCase): self.assertTrue(s.project.name, sp.name) self.cli_import("0020-libvirt.mbox.gz") - subj2 = subj + '\n[libvirt] [PATCH v2] vcpupin: add clear feature' + subj2 = '[libvirt] [PATCH v2] vcpupin: add clear feature\n' + subj self.check_cli(["search", "project:Libvirt"], stdout=subj2) self.check_cli(["search", "project:Libvirt-python"], stdout=subj) -- 2.17.1 _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://www.redhat.com/mailman/listinfo/patchew-devel