diff mbox

[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
State Accepted
Headers show

Commit Message

Michael-Doyle Hudson Oct. 13, 2011, 11 p.m. UTC
------------------------------------------------------------
revno: 83
committer: Michael Hudson-Doyle <michael.hudson@linaro.org>
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
diff mbox

Patch

=== 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",