From nobody Fri Mar 29 08:17:11 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=patchew-devel-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=patchew-devel-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1663680073; cv=none; d=zohomail.com; s=zohoarc; b=kma/Jo833l1vqkIXmodsr1dV2iJrKkO4esC6vgbOeqTKcumZQSpjWGWnd0YfQ0OClgb6PwHckf91sBpqNv7ekRGNIaqd+PRd1D5nnHnZOUUnVakI6gcRaH82FTHQTaPU80n04I7nEQi24ps01MPWR4DCsh4D733AZvVpba1mu1Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663680073; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=mb442VZC36WKF9yfNI1gwe/wfIdNySNbIO0Zk1ah3JA=; b=IS3y5zoEPe6yBR8bCyY1sAz1Jb+oj2oUxd2wr9W09m6TXo2nGvnH8Ah8h+Zd8v4RtywG3EHIrhKV3pMZAv489jFOyvdtemNT+XaoyP+aYquoyrWQ+63HCCxcX+qyjHl+mN+lQLdsigBB2oWatOdHqCA2VV5A2+OOIURKKlSBlg0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=patchew-devel-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1663680073435125.91398971321837; Tue, 20 Sep 2022 06:21:13 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-370-_rxSo0LRNMuzLA1p-OJxlA-1; Tue, 20 Sep 2022 09:21:09 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D7EF318E0A6C; Tue, 20 Sep 2022 13:21:08 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id D030A492B1B; Tue, 20 Sep 2022 13:21:08 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id BE5DD19465A0; Tue, 20 Sep 2022 13:21:08 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id E0BB51946588 for ; Tue, 20 Sep 2022 13:04:18 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id C3E8840E80EA; Tue, 20 Sep 2022 13:04:18 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BD81240E80E7 for ; Tue, 20 Sep 2022 13:04:18 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9FF3087B2A8 for ; Tue, 20 Sep 2022 13:04:18 +0000 (UTC) Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-591-9jZ0KH-QOWyiLmYHndWLcg-1; Tue, 20 Sep 2022 09:04:17 -0400 Received: by mail-ej1-f72.google.com with SMTP id xj11-20020a170906db0b00b0077b6ecb23fcso1348600ejb.5 for ; Tue, 20 Sep 2022 06:04:16 -0700 (PDT) Received: from [192.168.10.118] ([2001:b07:6468:f312:9af8:e5f5:7516:fa89]) by smtp.gmail.com with ESMTPSA id v13-20020aa7dbcd000000b004548dfb895asm465992edt.34.2022.09.20.06.04.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Sep 2022 06:04:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663680072; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=mb442VZC36WKF9yfNI1gwe/wfIdNySNbIO0Zk1ah3JA=; b=ekavdxVBuwt5F1reRcto0b8tEHTHHRYSejn36P3QlxTo6sN1ynZg0hTdFvAr1KN8eDQkAE UDWkguJS3xvdzYBYzfSQUS4xTPZKpo6i1b72LXmgs/St2p9HOAX+MUWqKY9F585oLJaccx 7GZDnvoIX4mJvSAZTWWfDKbS8EDrFBo= X-MC-Unique: _rxSo0LRNMuzLA1p-OJxlA-1 X-Original-To: patchew-devel@listman.corp.redhat.com X-MC-Unique: 9jZ0KH-QOWyiLmYHndWLcg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=H0cGop/9y9EnrPEWh+kpeWwioDA854IgyiZr0Hf+ZVw=; b=6TgZGjYMJsY3PSDs5ltnVqiF1DW07kJJEqEjSRVz51VMVlnkAWIP9VF4Xyqttn2w/C OA7ZhRMbdt12OkV42J0ipEiOLuThQDFJGzU0CYYM4akDDl5HZi856FLeXz9oJrRidPnD bQpAnmSVPg0CgJqhdJDbHVQ2cZsTdHF4KyS6uL1HUNez5oxCawt9jBJYKsT4m8MQWc1G E1ZTq1g/Syuv0TTEx9s1QzCcEnXenSiAKpbLxI5veqlXn/e1F3TAwCbJTqsEdkrMBTqQ pVLmlN674cF820n1LfI1dCFQcLp86C8AnRKQV4G99FRYzBwsDX1pSNlGSfdAFJYgxMVX l4tA== X-Gm-Message-State: ACrzQf29ScYOKRTkllXqd7SasA46Th1TO0/Jh67HqJMpRbjzdzKdHXNK tR6wNqTH2JpWW4+fr573IzKouydKQURj2wRDTc38JbJZsp1ZUTzY291a37bpKAD+Z+/JYS756Si Y9Ba6AXrulYynjLcbC77PS+vWOUAvAx9t9X4dBRt5n83e87eSu1S2DooexM2eySrX43mjTEhlNQ == X-Received: by 2002:a17:907:3f87:b0:781:ee94:7f91 with SMTP id hr7-20020a1709073f8700b00781ee947f91mr145592ejc.52.1663679055613; Tue, 20 Sep 2022 06:04:15 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7wtWpPXUcX7D36wFw9NaPv1EinQkpn7D16w1V2asGFA5JqrLbfzF4og/W3l0RF+EAC/HHhAA== X-Received: by 2002:a17:907:3f87:b0:781:ee94:7f91 with SMTP id hr7-20020a1709073f8700b00781ee947f91mr145560ejc.52.1663679055208; Tue, 20 Sep 2022 06:04:15 -0700 (PDT) From: Paolo Bonzini To: patchew-devel@redhat.com Date: Tue, 20 Sep 2022 15:04:04 +0200 Message-Id: <20220920130404.39806-5-pbonzini@redhat.com> In-Reply-To: <20220920130404.39806-1-pbonzini@redhat.com> References: <20220920130404.39806-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 Subject: [Patchew-devel] [PATCH 4/4] git: use denormalized project to query unapplied messages X-BeenThere: patchew-devel@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Patchew development and discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dcaratti@redhat.com Errors-To: patchew-devel-bounces@redhat.com Sender: "Patchew-devel" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1663680075330100001 Content-Type: text/plain; charset="utf-8" In order to find unapplied MessageResults for a given set of projects, the database would have to walk all the messages for the project and jump from Message to MessageResult to Result. For efficiency, look up the project, name ("git") and status ("pending") in a single index. Signed-off-by: Paolo Bonzini --- api/migrations/0070_auto_20220919_1016.py | 17 +++++++++++++++++ api/models.py | 2 +- mods/git.py | 6 ++---- 3 files changed, 20 insertions(+), 5 deletions(-) create mode 100644 api/migrations/0070_auto_20220919_1016.py diff --git a/api/migrations/0070_auto_20220919_1016.py b/api/migrations/007= 0_auto_20220919_1016.py new file mode 100644 index 0000000..5ea23c1 --- /dev/null +++ b/api/migrations/0070_auto_20220919_1016.py @@ -0,0 +1,17 @@ +# Generated by Django 3.1.14 on 2022-09-19 10:16 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies =3D [ + ('api', '0069_auto_20220919_1008'), + ] + + operations =3D [ + migrations.AlterIndexTogether( + name=3D'result', + index_together=3D{('status', 'name', 'project')}, + ), + ] diff --git a/api/models.py b/api/models.py index b942e20..b1b42c1 100644 --- a/api/models.py +++ b/api/models.py @@ -69,7 +69,7 @@ class Result(models.Model): ) =20 class Meta: - index_together =3D [("status", "name")] + index_together =3D [("status", "name", "project")] =20 def is_success(self): return self.status =3D=3D self.SUCCESS diff --git a/mods/git.py b/mods/git.py index 5b3dddc..8220d5d 100644 --- a/mods/git.py +++ b/mods/git.py @@ -283,8 +283,6 @@ class GitModule(PatchewModule): ) =20 def pending_series(self, target_repo): - q =3D Message.objects.filter(results__name=3D"git", results__statu= s=3D"pending") - # Postgres could use JSON fields instead. Fortunately projects are # few so this is cheap def match_target_repo(config, target_repo): @@ -302,8 +300,8 @@ class GitModule(PatchewModule): projects =3D [ pid for pid, config in projects if match_target_repo(config, t= arget_repo) ] - q =3D q.filter(project__pk__in=3Dprojects) - return q + return Message.objects.filter(results__name=3D"git", results__stat= us=3D"pending", + results__project__pk__in=3Dprojects) =20 =20 class UnappliedSeriesSerializer(SeriesSerializer): --=20 2.37.2 _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://listman.redhat.com/mailman/listinfo/patchew-devel