diff mbox series

[OSSTEST,04/13] sg-report-host-history: Actually honour $minflight

Message ID 20191108185001.3319-5-ian.jackson@eu.citrix.com (mailing list archive)
State New, archived
Headers show
Series Speed up and restore host history | expand

Commit Message

Ian Jackson Nov. 8, 2019, 6:49 p.m. UTC
This seriously speeds up some of the queries.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
---
 sg-report-host-history | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/sg-report-host-history b/sg-report-host-history
index fc51074d..d47784d9 100755
--- a/sg-report-host-history
+++ b/sg-report-host-history
@@ -67,6 +67,7 @@  while (@ARGV && $ARGV[0] =~ m/^-/) {
 
 our $restrictflight_cond = restrictflight_cond();
 our $flightcond;
+our $minflight;
 
 sub computeflightsrange () {
     if (!$flightlimit) {
@@ -100,7 +101,7 @@  END
 	  LIMIT 1
 END
     $minflightsq->execute();
-    my ($minflight) = $minflightsq->fetchrow_array();
+    ($minflight,) = $minflightsq->fetchrow_array();
     $minflight //= 0;
 
     $flightcond = "(flight > $minflight)";
@@ -127,10 +128,12 @@  sub mainquery () {
 	   AND ($valcond)
 	   AND $flightcond
            AND $restrictflight_cond
+           AND flight > ?
 	 ORDER BY flight DESC
 	 LIMIT ($limit * 3 + 100) * ?
 END
 
+    push @params, $minflight;
     push @params, scalar keys %hosts;
 
     print DEBUG "MAINQUERY...\n";