From nobody Wed Oct 30 19:55:56 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 1540998469918953.2475217417806; Wed, 31 Oct 2018 08:07:49 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7428D81F09; Wed, 31 Oct 2018 15:07:42 +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 63C4060C62; Wed, 31 Oct 2018 15:07:42 +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 51B4E3FA56; Wed, 31 Oct 2018 15:07:42 +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 w9VF00hM002992 for ; Wed, 31 Oct 2018 11:00:00 -0400 Received: by smtp.corp.redhat.com (Postfix) id B5F9F63133; Wed, 31 Oct 2018 15:00:00 +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 1923F6147B for ; Wed, 31 Oct 2018 14:59:54 +0000 (UTC) From: Paolo Bonzini To: patchew-devel@redhat.com Date: Wed, 31 Oct 2018 15:59:53 +0100 Message-Id: <20181031145953.15261-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 v2] 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 31 Oct 2018 15:07:42 +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 | 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/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..b6e2d73 100755 --- a/tests/test_import.py +++ b/tests/test_import.py @@ -91,7 +91,7 @@ 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' + subj2 =3D '[libvirt] [PATCH v2] vcpupin: add clear feature\n' + s= ubj self.check_cli(["search", "project:Libvirt"], stdout=3Dsubj2) self.check_cli(["search", "project:Libvirt-python"], stdout=3Dsubj) =20 --=20 2.17.1 _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://www.redhat.com/mailman/listinfo/patchew-devel