From patchwork Thu Oct 13 23:00:16 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael-Doyle Hudson X-Patchwork-Id: 4668 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 518A523F58 for ; Thu, 13 Oct 2011 23:00:18 +0000 (UTC) Received: from mail-bw0-f52.google.com (mail-bw0-f52.google.com [209.85.214.52]) by fiordland.canonical.com (Postfix) with ESMTP id 2DAF1A186E7 for ; Thu, 13 Oct 2011 23:00:18 +0000 (UTC) Received: by bkbzs2 with SMTP id zs2so1404103bkb.11 for ; Thu, 13 Oct 2011 16:00:18 -0700 (PDT) Received: by 10.204.136.16 with SMTP id p16mr4639370bkt.61.1318546817720; Thu, 13 Oct 2011 16:00:17 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.152.24.41 with SMTP id r9cs277446laf; Thu, 13 Oct 2011 16:00:17 -0700 (PDT) Received: by 10.227.170.4 with SMTP id b4mr2011108wbz.63.1318546816601; Thu, 13 Oct 2011 16:00:16 -0700 (PDT) Received: from indium.canonical.com (indium.canonical.com. [91.189.90.7]) by mx.google.com with ESMTPS id fh14si4512370wbb.8.2011.10.13.16.00.16 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 13 Oct 2011 16:00:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.7 as permitted sender) client-ip=91.189.90.7; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.7 as permitted sender) smtp.mail=bounces@canonical.com Received: from ackee.canonical.com ([91.189.89.26]) by indium.canonical.com with esmtp (Exim 4.71 #1 (Debian)) id 1REUG8-0003zl-1e for ; Thu, 13 Oct 2011 23:00:16 +0000 Received: from ackee.canonical.com (localhost [127.0.0.1]) by ackee.canonical.com (Postfix) with ESMTP id 02093E019F for ; Thu, 13 Oct 2011 23:00:16 +0000 (UTC) MIME-Version: 1.0 X-Launchpad-Project: lava-scheduler X-Launchpad-Branch: ~linaro-validation/lava-scheduler/trunk X-Launchpad-Message-Rationale: Subscriber X-Launchpad-Branch-Revision-Number: 83 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~linaro-validation/lava-scheduler/trunk] Rev 83: sprinkle a few select_relateds around to massively reduce query count (felt most on alljobs page ... Message-Id: <20111013230016.12125.73559.launchpad@ackee.canonical.com> Date: Thu, 13 Oct 2011 23:00:16 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="14124"; Instance="launchpad-lazr.conf" X-Launchpad-Hash: 224aadccf66500b9e76b35ec609ff2e545de8b60 ------------------------------------------------------------ revno: 83 committer: Michael Hudson-Doyle branch nick: jobs-listing-performance timestamp: Fri 2011-10-14 11:58:01 +1300 message: sprinkle a few select_relateds around to massively reduce query count (felt most on alljobs page for now) modified: lava_scheduler_app/views.py --- lp:lava-scheduler https://code.launchpad.net/~linaro-validation/lava-scheduler/trunk You are subscribed to branch lp:lava-scheduler. To unsubscribe from this branch go to https://code.launchpad.net/~linaro-validation/lava-scheduler/trunk/+edit-subscription === modified file 'lava_scheduler_app/views.py' --- lava_scheduler_app/views.py 2011-08-24 10:58:25 +0000 +++ lava_scheduler_app/views.py 2011-10-13 22:58:01 +0000 @@ -28,8 +28,10 @@ return render_to_response( "lava_scheduler_app/index.html", { - 'devices': Device.objects.all(), - 'jobs': TestJob.objects.filter(status__in=[ + 'devices': Device.objects.select_related("device_type"), + 'jobs': TestJob.objects.select_related( + "actual_device", "requested_device", "requested_device_type", + "submitter").filter(status__in=[ TestJob.SUBMITTED, TestJob.RUNNING]), }, RequestContext(request)) @@ -39,7 +41,9 @@ return render_to_response( "lava_scheduler_app/alljobs.html", { - 'jobs': TestJob.objects.all(), + 'jobs': TestJob.objects.select_related( + "actual_device", "requested_device", "requested_device_type", + "submitter").all(), }, RequestContext(request)) @@ -116,7 +120,9 @@ def device(request, pk): device = Device.objects.get(pk=pk) - recent_jobs = TestJob.objects.all().filter( + recent_jobs = TestJob.objects.select_related( + "actual_device", "requested_device", "requested_device_type", + "submitter").filter( actual_device=device).order_by('-start_time') return render_to_response( "lava_scheduler_app/device.html",