From nobody Thu Apr 18 23:18:26 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=patchew-devel-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=patchew-devel-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1541011120411405.81075273316503; Wed, 31 Oct 2018 11:38:40 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 208CDC0587D2; Wed, 31 Oct 2018 18:38:39 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0C6044D71A; Wed, 31 Oct 2018 18:38:39 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id F26044BB79; Wed, 31 Oct 2018 18:38:38 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w9VIWHss002279 for ; Wed, 31 Oct 2018 14:32:17 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8CC6D5C1B2; Wed, 31 Oct 2018 18:32:17 +0000 (UTC) Received: from donizetti.redhat.com (ovpn-112-62.ams2.redhat.com [10.36.112.62]) by smtp.corp.redhat.com (Postfix) with ESMTP id E55525C66F for ; Wed, 31 Oct 2018 18:32:13 +0000 (UTC) From: Paolo Bonzini To: patchew-devel@redhat.com Date: Wed, 31 Oct 2018 19:32:12 +0100 Message-Id: <20181031183212.11345-1-pbonzini@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: patchew-devel@redhat.com Subject: [Patchew-devel] [PATCH v3] add more indices to Message X-BeenThere: patchew-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Patchew development and discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: patchew-devel-bounces@redhat.com Errors-To: patchew-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 31 Oct 2018 18:38:39 +0000 (UTC) Content-Type: text/plain; charset="utf-8" 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 --- api/migrations/0037_auto_20181031_1439.py | 19 +++++++++++++++++++ api/models.py | 4 ++++ tests/test_import.py | 6 ++++-- 3 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 api/migrations/0037_auto_20181031_1439.py diff --git a/api/migrations/0037_auto_20181031_1439.py b/api/migrations/003= 7_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 =3D [ + ('api', '0036_populate_message_tags'), + ] + + operations =3D [ + migrations.AlterIndexTogether( + name=3D'message', + index_together=3Dset([('is_series_head', 'project', 'date'), (= 'is_series_head', 'date'), ('is_series_head', 'last_reply_date'), ('is_seri= es_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): =20 class Meta: unique_together =3D ('project', 'message_id',) + index_together =3D [('is_series_head', 'project', 'last_reply_date= '), + ('is_series_head', 'project', 'date'), + ('is_series_head', 'last_reply_date'), + ('is_series_head', 'date')] =20 class MessageResult(Result): message =3D models.ForeignKey(Message, related_name=3D'results') diff --git a/tests/test_import.py b/tests/test_import.py index 5693d7e..64d8c66 100755 --- a/tests/test_import.py +++ b/tests/test_import.py @@ -91,8 +91,10 @@ class ImportTest(PatchewTestCase): self.assertTrue(s.project.name, sp.name) =20 self.cli_import("0020-libvirt.mbox.gz") - subj2 =3D subj + '\n[libvirt] [PATCH v2] vcpupin: add clear featu= re' - self.check_cli(["search", "project:Libvirt"], stdout=3Dsubj2) + # the order of the search results may change, so we cannot use std= out=3D... + a, b =3D self.check_cli(["search", "project:Libvirt"]) + self.assertEqual(sorted(a.split('\n')), + ['[libvirt] [PATCH v2] vcpupin: add clear featur= e', subj]) self.check_cli(["search", "project:Libvirt-python"], stdout=3Dsubj) =20 class UnprivilegedImportTest(ImportTest): --=20 2.17.1 _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://www.redhat.com/mailman/listinfo/patchew-devel