From: Ian Jackson Date: Fri, 24 Jul 2020 15:11:49 +0000 (+0100) Subject: sg-report-host-history: Do the main query per host X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=3bdd184df7f592f0ec65502bc1c647bcbc8191c1;p=osstest.git sg-report-host-history: Do the main query per host In f6001d628c3b3fd42b10cd15351981a04bc02572 we combined these queries into one: sg-report-host-history: Aggregate runvars query for all hosts Now that we have an index, there is a faster way for the db to do this query: via that index. But it doesn't like to do that if be aggregate the queries. Experimentally, doing this query separately once per host is significantly faster. Also, later, it will allow us to parallelise this work. So, we undo that. (Not by reverting, though.) Signed-off-by: Ian Jackson --- v2: Use proper \ escaping for underscores in LIKE --- diff --git a/schema/runvars-host-index.sql b/schema/runvars-host-index.sql index 222a0a3..6a3ef37 100644 --- a/schema/runvars-host-index.sql +++ b/schema/runvars-host-index.sql @@ -1,4 +1,4 @@ --- ##OSSTEST## 009 Preparatory +-- ##OSSTEST## 009 Needed -- -- This index helps sg-report-host-history find relevant flights. diff --git a/sg-report-host-history b/sg-report-host-history index 1c2d19a..15866ab 100755 --- a/sg-report-host-history +++ b/sg-report-host-history @@ -165,34 +165,25 @@ sub jobquery ($$$) { our %hosts; sub mainquery () { - our $valcond = join " OR ", map { "val = ?" } keys %hosts; - our @params = keys %hosts; - our $runvarq //= db_prepare(< ? ORDER BY flight DESC - LIMIT ($limit * 3 + 100) * ? + LIMIT $limit * 2 END + foreach my $host (sort keys %hosts) { + print DEBUG "MAINQUERY $host...\n"; + $runvarq->execute($host, $minflight); - push @params, $minflight; - push @params, scalar keys %hosts; - - print DEBUG "MAINQUERY...\n"; - $runvarq->execute(@params); - - print DEBUG "FIRST PASS\n"; - while (my $jr= $runvarq->fetchrow_hashref()) { - print DEBUG " $jr->{flight}.$jr->{job} "; - push @{ $hosts{$jr->{val}} }, $jr; + $hosts{$host} = $runvarq->fetchall_arrayref({}); + print DEBUG "MAINQUERY $host got ".(scalar @{ $hosts{$host} })."\n"; } - print DEBUG "\n"; } sub reporthost ($) {