From: Ian Jackson Subject: [OSSTEST PATCH 22/25] sg-report-host-history: Move per-row endedq query into per-host transaction Date: Wed, 17 Jun 2015 17:45:18 +0100 Message-ID: <1434559521-8751-23-git-send-email-ian.jackson@eu.citrix.com> References: <1434559521-8751-1-git-send-email-ian.jackson@eu.citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Z5GT7-0004Jc-QH for xen-devel@lists.xenproject.org; Wed, 17 Jun 2015 16:45:41 +0000 In-Reply-To: <1434559521-8751-1-git-send-email-ian.jackson@eu.citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xenproject.org Cc: Ian Jackson , Ian Campbell List-Id: xen-devel@lists.xenproject.org No substantial change, but reduces the work done in the main transaction. Signed-off-by: Ian Jackson --- sg-report-host-history | 46 ++++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/sg-report-host-history b/sg-report-host-history index bab636e..cd9ec61 100755 --- a/sg-report-host-history +++ b/sg-report-host-history @@ -122,29 +122,12 @@ END push @params, scalar keys %hosts; - our $endedq //= db_prepare(<execute(@params); print DEBUG "FIRST PASS\n"; while (my $jr= $runvarq->fetchrow_hashref()) { print DEBUG "JOB $jr->{flight}.$jr->{job} "; - - my $endedrow = jobquery($endedq, $jr); - if (!$endedrow) { - print DEBUG "no-finished\n"; - next; - } - print DEBUG join " ", map { $endedrow->{$_} } sort keys %$endedrow; - print DEBUG ".\n"; - - push @{ $hosts{$jr->{val}} }, { %$jr, %$endedrow }; + push @{ $hosts{$jr->{val}} }, $jr; } } @@ -173,6 +156,14 @@ sub reporthost ($) { print H "\n"; + our $endedq //= db_prepare(<{flight}.$jr->{job}\n"; - print DEBUG "FOUND ", (scalar @rows), " ROWS for $hostname\n"; + my $endedrow = jobquery($endedq, $jr); + if (!$endedrow) { + print DEBUG "no-finished\n"; + next; + } + print DEBUG join " ", map { $endedrow->{$_} } sort keys %$endedrow; + print DEBUG ".\n"; + + push @rows, { %$jr, %$endedrow }; + } @rows = sort { $b->{finished} <=> $a->{finished} } @rows; $#rows = $limit-1 if @rows > $limit; my $alternate = 0; foreach my $jr (@rows) { - print DEBUG "JOB $jr->{flight}.$jr->{job}\n"; - my $ir = jobquery($infoq, $jr); my $ar = jobquery($allocdq, $jr); -- 1.7.10.4