From nobody Tue Apr 23 16:40:34 2024 Delivered-To: importer2@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1663679672; cv=none; d=zohomail.com; s=zohoarc; b=YyvuBy9A4xIJ1SoAsuo9786dVsCQzXH7GWe+FMhqzrjZrxyNBE9ymg6JAdxFzMEyPFZgz2vmpp7gMMfde160JpBwq9yr2IpJi3o7sooGZg1OezSjo9LPt1W5m6ewXUls+rj0ScvnNJsWjLvY5h6WgjFAZgAn09iaDcEVKDQLEJk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663679672; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=tr4An9eNU0DPcyyu+hUxfY/kjrT00kw3V9oHWLgNlSs=; b=UKBYt+XAHRXXU/dOhd0aLZUEdRhAxuOBaPr4V6IcZO+vY4jsewu6orlg0GCIr9+HU7GZIBtkVf6U6ji3gOIXsRStKoRwk6I7yRMXXV2Nu40nuLKvscxgc9vpih3klyASr12o1nPRvW1vnpiSg38UAhkmaIrof0Cpc6qWsZdSMms= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.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.129.124]) by mx.zohomail.com with SMTPS id 1663679672021567.7621715881544; Tue, 20 Sep 2022 06:14:32 -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-173-SIxgulmCMG6NjgGwm8Tgag-1; Tue, 20 Sep 2022 09:14:27 -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 52717858F13; Tue, 20 Sep 2022 13:14:27 +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 4BA2B492B08; Tue, 20 Sep 2022 13:14:27 +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 0D46519465B6; Tue, 20 Sep 2022 13:14:27 +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 C1CA01946588 for ; Tue, 20 Sep 2022 13:00:28 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id A269C40C6FA0; Tue, 20 Sep 2022 13:00:28 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast08.extmail.prod.ext.rdu2.redhat.com [10.11.55.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9A66B40C6F9F for ; Tue, 20 Sep 2022 13:00:28 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (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 7DE463815D38 for ; Tue, 20 Sep 2022 13:00:28 +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-663-HdaLe9n4PF2AdPKerMTkOg-1; Tue, 20 Sep 2022 09:00:27 -0400 Received: by mail-ej1-f72.google.com with SMTP id xh12-20020a170906da8c00b007413144e87fso1334310ejb.14 for ; Tue, 20 Sep 2022 06:00:27 -0700 (PDT) Received: from [192.168.10.118] ([2001:b07:6468:f312:9af8:e5f5:7516:fa89]) by smtp.gmail.com with ESMTPSA id 2-20020a170906200200b0073dc5bb7c32sm849205ejo.64.2022.09.20.06.00.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Sep 2022 06:00:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663679670; 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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=tr4An9eNU0DPcyyu+hUxfY/kjrT00kw3V9oHWLgNlSs=; b=OmyGpTUWKjzdlOZLHKEzQmT849x1AerrbDHvSP5wl9WKium11gemJJwKWSkypGUNENWMPn BLZ/xr59a4DoNEqX8BL0KAuoqxFQtG2X8J9FzvbG9fT33U5cnsbrFgo8njpnue011mbkJQ Qwms5j0FDxbPL9ZG32sVeiB0n87hCMc= X-MC-Unique: SIxgulmCMG6NjgGwm8Tgag-1 X-Original-To: patchew-devel@listman.corp.redhat.com X-MC-Unique: HdaLe9n4PF2AdPKerMTkOg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date; bh=cKhYfuByGTc3T7rcRI/huOHKYa0aVjCBoqQTFZMQ69o=; b=VHofFaOaBcPp7T8EqNTe1qE+zOaUSsj5CHP/Yq6bX90T1mug/brHJpy92XfVZe+NKz JRfZ7YfQjZ33aZIhCJcXPCFDxWODLFh2EGMuf7hR3GqQGVE0U51ZC/n6x4PGgIcPnnAT 9MSv+gWAU34eAI7eq6IzOZtkZwAzfj1XkBkPfXnqBIPpeOjkG27pk5GNBHkwm9o3sCwR cIzM1tf7ysS5vXesNrZJ/4BKQjQdob0rt5s1IVPVVKajElCv70swXgDCSqd7Pmeehx4j VLdJGYd+2ogWwiONxMSkEru127tqTg77/TK96TGxDj2RlPugXm/VrSaoZu900FSd+3nx 4krw== X-Gm-Message-State: ACrzQf1sz5eeVmUhrv4Hmq574JiCK3WhFWgJF++TDZOzIPSoRXS2YS5B RzRyhFtS+4fI+MGSJTeed8CEQgZwwmOAFXKxBshtGDXkYL43NnrxVgstR10CF7iDzk8lpeVGe2e B0RmdD+exWUzmLU0kAGicnjFezsS4XX+hqZ7D32WSQPVD135rGywv0YUI5jQlf+JTjti5wRWGVQ == X-Received: by 2002:a05:6402:3549:b0:454:414e:a7fd with SMTP id f9-20020a056402354900b00454414ea7fdmr6471998edd.69.1663678825548; Tue, 20 Sep 2022 06:00:25 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4F6A69E9MNEnELfS60AO1IjQYirHU9VOda/xpESEiKGzGU5ApNzoAPBXxqc9Y6USwD7Z+rBw== X-Received: by 2002:a05:6402:3549:b0:454:414e:a7fd with SMTP id f9-20020a056402354900b00454414ea7fdmr6471972edd.69.1663678825266; Tue, 20 Sep 2022 06:00:25 -0700 (PDT) From: Paolo Bonzini To: patchew-devel@redhat.com Date: Tue, 20 Sep 2022 15:00:23 +0200 Message-Id: <20220920130023.39630-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 Subject: [Patchew-devel] [PATCH] models: force execution of project/parent-project subquery 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: 1663679711256100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Paolo Bonzini --- api/models.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/api/models.py b/api/models.py index 721366d..a3fd3e7 100644 --- a/api/models.py +++ b/api/models.py @@ -303,11 +303,18 @@ class Project(models.Model): =20 @classmethod def get_project_ids_by_id(cls, id): - return cls.objects.filter(Q(id=3Did) | Q(parent_project__id=3Did))= .values_list('id') + q =3D cls.objects.filter(Q(id=3Did) | Q(parent_project__id=3Did)).= values_list('id') + # Force execution of the query. PostgreSQL sometimes (but not alw= ays...) + # sees the subquery and does not use the (project, topic, date) in= dex; + # instead it uses the (topic, date) index and filters on the proje= ct later, + # which is horrible for projects that have very few messages. Sin= ce our + # intended plan is to first walk the small project table, do that = explicitly. + return [x[0] for x in list(q)] =20 @classmethod def get_project_ids_by_name(cls, name): - return cls.objects.filter(Q(name=3Dname) | Q(parent_project__name= =3Dname)).values_list('id') + q =3D cls.objects.filter(Q(name=3Dname) | Q(parent_project__name= =3Dname)).values_list('id') + return [x[0] for x in list(q)] =20 def get_project_head(self): return self.get_property("git.head") --=20 2.37.2 _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://listman.redhat.com/mailman/listinfo/patchew-devel