]> xenbits.xensource.com Git - osstest.git/commitdiff
sg-report-job-history (nfc): Query hosts runvars in one go
authorIan Jackson <ian.jackson@eu.citrix.com>
Mon, 10 Aug 2020 15:10:50 +0000 (16:10 +0100)
committerIan Jackson <ian.jackson@eu.citrix.com>
Wed, 19 Aug 2020 10:41:18 +0000 (11:41 +0100)
Rather than doing one query for each entry in @hostvarcols, do one
query for all the relevant runvars.  This is quite a bit faster and
will enable us to use the cache.

This is correct because @hostvarcols was the union of all the host
runvars, so this produces the same answers as the individual queries.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
sg-report-job-history

index fb2930a9594e571ad54a73c1a8cac163bd983103..5d913b96e12c2cff6e546bc7aa022cad88664294 100755 (executable)
@@ -167,16 +167,19 @@ END
     }
 
     my $hostq= db_prepare(<<END);
-        SELECT val FROM runvars WHERE flight=? AND job=? AND name=?
+        SELECT name, val
+          FROM runvars
+         WHERE flight=?
+           AND job=?
+           AND (name = 'host' OR name LIKE '%\\_host')
 END
 
     while (my $f= $flightsq->fetchrow_hashref()) {
         my $ri= report_run_getinfo($f);
 
        $ri->{Hosts} = { };
-       foreach my $hostvar (@hostvarcols) {
-           $hostq->execute($f->{flight}, $f->{job}, $hostvar);
-           my ($host) = $hostq->fetchrow_array();
+       $hostq->execute($f->{flight}, $f->{job});
+       while (my ($hostvar,$host) = $hostq->fetchrow_array()) {
            $ri->{Hosts}{$hostvar} = $host;
        }