From patchwork Wed Sep 12 21:57:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Finucane X-Patchwork-Id: 969208 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 429bJJ3ND0z9s4V for ; Thu, 13 Sep 2018 07:58:24 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=that.guru Authentication-Results: ozlabs.org; dkim=fail reason="key not found in DNS" (0-bit key; unprotected) header.d=that.guru header.i=@that.guru header.b="d6tgXVPX"; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 429bJJ1jQdzF3Rm for ; Thu, 13 Sep 2018 07:58:24 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=that.guru Authentication-Results: lists.ozlabs.org; dkim=fail reason="key not found in DNS" (0-bit key; unprotected) header.d=that.guru header.i=@that.guru header.b="d6tgXVPX"; dkim-atps=neutral X-Original-To: patchwork@lists.ozlabs.org Delivered-To: patchwork@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=that.guru (client-ip=185.234.75.3; helo=relay-direct21.mxroute.com; envelope-from=stephen@that.guru; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=that.guru Authentication-Results: lists.ozlabs.org; dkim=fail reason="key not found in DNS" (0-bit key; unprotected) header.d=that.guru header.i=@that.guru header.b="d6tgXVPX"; dkim-atps=neutral Received: from relay-direct21.mxroute.com (relay-direct21.mxroute.com [185.234.75.3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 429bJB6mXJzF3RD for ; Thu, 13 Sep 2018 07:58:18 +1000 (AEST) Received: from filter002.mxroute.com (unknown [185.133.192.179]) by relay-direct21.mxroute.com (Postfix) with ESMTP id EFADB3FCFE for ; Wed, 12 Sep 2018 21:57:45 +0000 (UTC) Received: from one.mxroute.com (one.mxroute.com [195.201.59.211]) by filter002.mxroute.com (Postfix) with ESMTPS id D30C63F532 for ; Wed, 12 Sep 2018 21:57:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=that.guru; s=default; h=Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version :Content-Type:Content-Transfer-Encoding:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=Ed6m5CUEPfhRbfP4I89ZHNQvl6NJMs21gooaeOSWDQc=; b=d6tgXVPX3GrwPpT7yLrUwNcKDH /W9s4tzO5CvNtHIhChywcLcB2rMoVpZm5c31N01lMkaj+E0GprV6oFhZ34G0H+ZQnXyI4jE8+IA3A Fxy/3u3Z/dPhOimKiNVBCVEom/PfeHPdu1YhgP8nl3STZxTwNXftffCVSFph1mT8VV3iuOnbNHJbY R33xd93A8wdI2YfVCaTgqDqfzZUZJoC59QAh61Q6zMbFiUGkQdPpkg41ge/boQlU0l87Xl49/YTBT I1XIxSj/LUKtz4lF0H2DdNYghz/6xQ9rCKSMG6S8wurCdk3EEtmeIo9imGdwvU0wjOKDX7CFzvesb 6+CJWztw==; From: Stephen Finucane To: patchwork@lists.ozlabs.org Subject: [PATCH] admin: Configure 'list_select_related', 'get_queryset' Date: Wed, 12 Sep 2018 15:57:39 -0600 Message-Id: <20180912215739.22074-1-stephen@that.guru> X-Mailer: git-send-email 2.17.1 X-AuthUser: stephen@that.guru X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Patchwork development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Patchwork" This has a significant improvement for the patch and series views. /patchwork/patch FROM: ~114 queries TO: ~14 queries /patchwork/series FROM: ~210 queries TO: ~10 queries Signed-off-by: Stephen Finucane --- patchwork/admin.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/patchwork/admin.py b/patchwork/admin.py index 133872ac..1a2c0370 100644 --- a/patchwork/admin.py +++ b/patchwork/admin.py @@ -105,6 +105,7 @@ class PatchAdmin(admin.ModelAdmin): list_display = ('name', 'submitter', 'project', 'state', 'date', 'archived', 'is_pull_request') list_filter = ('project', 'state', 'archived') + list_select_related = ('submitter', 'project', 'state') search_fields = ('name', 'submitter__name', 'submitter__email') date_hierarchy = 'date' @@ -145,6 +146,10 @@ class SeriesAdmin(admin.ModelAdmin): return series.received_all received_all.boolean = True + def get_queryset(self, request): + qs = super(SeriesAdmin, self).get_queryset(request) + return qs.prefetch_related('patches',) + admin.site.register(Series, SeriesAdmin)