From: Darold Gilles Date: Tue, 7 Oct 2014 08:41:23 +0000 (+0200) Subject: Do not display queries in Slowest individual, Time consuming and Normalized slowest... X-Git-Tag: v6.2~4 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d45dc5fd890662052ffe72dff0de5510056e3348;p=pgbadger Do not display queries in Slowest individual, Time consuming and Normalized slowest queries reports when there is no duration in log file. Diplay NO DATASET instead. --- diff --git a/pgbadger b/pgbadger index d67aa38..d165c4b 100755 --- a/pgbadger +++ b/pgbadger @@ -7040,9 +7040,11 @@ sub print_time_consuming }; my $rank = 1; + my $found = 0; foreach my $k (sort {$normalyzed_info{$b}{duration} <=> $normalyzed_info{$a}{duration}} keys %normalyzed_info) { - next if (!$normalyzed_info{$k}{count}); + next if (!$normalyzed_info{$k}{count} || !exists $normalyzed_info{$k}{duration}); last if ($rank > $top); + $found++; $normalyzed_info{$k}{average} = $normalyzed_info{$k}{duration} / $normalyzed_info{$k}{count}; my $duration = &convert_time($normalyzed_info{$k}{duration}); my $count = &comma_numbers($normalyzed_info{$k}{count}); @@ -7170,9 +7172,8 @@ sub print_time_consuming }; $rank++; } - - if (scalar keys %normalyzed_info == 0) { - print $fh qq{$NODATA}; + if (!$found) { + print $fh qq{$NODATA}; } print $fh qq{ @@ -7368,9 +7369,11 @@ sub print_slowest_queries }; my $rank = 1; + my $found = 0; foreach my $k (sort {$normalyzed_info{$b}{average} <=> $normalyzed_info{$a}{average}} keys %normalyzed_info) { - next if (!$k || !$normalyzed_info{$k}{count}); + next if (!$k || !$normalyzed_info{$k}{count} || !exists $normalyzed_info{$k}{duration}); last if ($rank > $top); + $found++; $normalyzed_info{$k}{average} = $normalyzed_info{$k}{duration} / $normalyzed_info{$k}{count}; my $duration = &convert_time($normalyzed_info{$k}{duration}); my $count = &comma_numbers($normalyzed_info{$k}{count}); @@ -7499,8 +7502,8 @@ sub print_slowest_queries }; $rank++; } - if (scalar keys %normalyzed_info == 0) { - print $fh qq{$NODATA}; + if (!$found) { + print $fh qq{$NODATA}; } print $fh qq{ @@ -9639,6 +9642,7 @@ sub store_queries # Store normalized query count and duration per time $normalyzed_info{$normalized}{chronos}{"$cur_day_str"}{"$cur_hour_str"}{count}++; $normalyzed_info{$normalized}{chronos}{"$cur_day_str"}{"$cur_hour_str"}{min}{$cur_info{$t_pid}{min}}++; + if ($cur_info{$t_pid}{duration}) { # Update top slowest queries statistics