--disable-checkpoint : do not generate checkpoint report.
--enable-log_duration : force pgbadger to use log_duration even if
log_min_duration_statement format is autodetected.
+ --enable-log_min_duration: force pgbadger to use log_min_duration even if
+ log_duration format is autodetected.
Examples:
log_min_duration_statement = 0
Note that pgBadger is not compatible with statements logs provided by
- log_statement and log_duration.
+ log_statement and log_duration. See next chapter for more information.
With 'stderr' log format, log_line_prefix must be at least:
but this is not only recommanded by pgbadger.
+log_min_duration_statement versus log_duration
+ If you want full statistics reports from your log file you must set
+ log_min_duration_statement = 0. If you just want to report duration and
+ number of queries and don't want all detail about queries, set
+ log_min_duration_statement to -1 and enable log_duration. If you want to
+ report only queries that tooks more than 5 seconds for example but still
+ want to report all queries duration and number of queries you will need
+ to generate 2 reports. One using the log_min_duration_statement and the
+ second using the log_duration. Proceed as follow:
+
+ pgbadger --enable-log_duration /var/log/postgresql.log
+
+ to generate hourly statistics about the number of queries and duration
+ stats. To generate detailled reports about queries use the following
+ command:
+
+ pgbadger --enable-log_min_duration /var/log/postgresql.log
+
+ Note that enabling log_statement will not help at all and enabling those
+ two options in the same command will report an error.
+
+ Use those options if you don't want to log each queries to preserve your
+ I/O but still want to know the slowest queries upper a certain time and
+ still have a report on the number of queries and their duration.
+ Otherwize if you don't have too much performance lost with a
+ log_min_duration_statement set to 0, do not enable log_duration in your
+ postgresql.conf file.
+
INSTALLATION
Download the tarball from github and unpack the archive as follow:
--disable-checkpoint : do not generate checkpoint report.
--enable-log_duration : force pgbadger to use log_duration even if
log_min_duration_statement format is autodetected.
+ --enable-log_min_duration: force pgbadger to use log_min_duration even if
+ log_duration format is autodetected.
Examples:
log_min_duration_statement = 0
Note that pgBadger is not compatible with statements logs provided by log_statement and log_duration.
+See next chapter for more information.
With 'stderr' log format, log_line_prefix must be at least:
but this is not only recommanded by pgbadger.
+=head1 log_min_duration_statement versus log_duration
+
+If you want full statistics reports from your log file you must set log_min_duration_statement = 0.
+If you just want to report duration and number of queries and don't want all detail about queries,
+set log_min_duration_statement to -1 and enable log_duration. If you want to report only queries that
+tooks more than 5 seconds for example but still want to report all queries duration and number of
+queries you will need to generate 2 reports. One using the log_min_duration_statement and the second
+using the log_duration. Proceed as follow:
+
+ pgbadger --enable-log_duration /var/log/postgresql.log
+
+to generate hourly statistics about the number of queries and duration stats. To generate detailled
+reports about queries use the following command:
+
+ pgbadger --enable-log_min_duration /var/log/postgresql.log
+
+Note that enabling log_statement will not help at all and enabling those two options in the same
+command will report an error.
+
+Use those options if you don't want to log each queries to preserve your I/O but still want to know
+the slowest queries upper a certain time and still have a report on the number of queries and their
+duration. Otherwize if you don't have too much performance lost with a log_min_duration_statement
+set to 0, do not enable log_duration in your postgresql.conf file.
=head1 INSTALLATION
my $t_max_hour = 0;
my $log_duration = 0;
my $enable_log_duration = 0;
+my $enable_log_min_duration = 0;
my $NUMPROGRESS = 10000;
my @DIMENSIONS = (800, 300);
"disable-temporary!" => \$disable_temporary,
"disable-checkpoint!" => \$disable_checkpoint,
"enable-log_duration!" => \$enable_log_duration,
+ "enable-log_min_duration!" => \$enable_log_min_duration,
);
if ($ver) {
$log_duration ||= &autodetect_duration($log_files[0]);
$log_duration = 1 if ($enable_log_duration);
+$log_duration = 0 if ($enable_log_min_duration);
+
+if ($enable_log_min_duration && $enable_log_duration) {
+ print STDERR "FATAL: you must choose between reports based on log_duration or log_min_duration_statement.\n\n";
+ &usage();
+}
# Set default top query
$top ||= 20;
--disable-checkpoint : do not generate checkpoint report.
--enable-log_duration : force pgbadger to use log_duration even if
log_min_duration_statement format is autodetected
+ --enable-log_min_duration: force pgbadger to use log_min_duration even if
+ log_duration format is autodetected.
Examples:
};
}
- if (!$disable_type && !$log_duration) {
+ if (!$disable_type && (!$log_duration || $enable_log_min_duration)) {
# INSERT/DELETE/UPDATE/SELECT repartition
my $totala = $overall_stat{'SELECT'} + $overall_stat{'INSERT'} + $overall_stat{'UPDATE'} + $overall_stat{'DELETE'};
}
# Show top informations
- if (!$disable_query && !$log_duration) {
+ if (!$disable_query && (!$log_duration || $enable_log_min_duration)) {
print $fh "\n- Slowest queries ------------------------------------------------------\n\n";
print $fh "Rank Duration (s) Query\n";
for (my $i = 0 ; $i <= $#top_slowest ; $i++) {
if (!$disable_hourly && $overall_stat{'queries_number'}) {
print $fh qq{<a href="#HourlyStatsReport">Hourly statistics</a> | };
}
- if (!$disable_type && !$log_duration) {
+ if (!$disable_type && (!$log_duration || $enable_log_min_duration)) {
print $fh qq{<a href="#QueriesByTypeReport">Queries by type</a> | };
}
- if (!$disable_query && !$log_duration) {
+ if (!$disable_query && (!$log_duration || $enable_log_min_duration)) {
print $fh qq{
<a href="#SlowestQueriesReport">Slowest queries</a> |
<a href="#NormalizedQueriesMostTimeReport">Queries that took up the most time (N)</a> |
if (!$disable_hourly && $overall_stat{'queries_number'}) {
print $fh qq{<li><a href="#HourlyStatsReport">Hourly statistics</a></li>};
}
- if (!$disable_type && !$log_duration) {
+ if (!$disable_type && (!$log_duration || $enable_log_min_duration)) {
print $fh qq{<li><a href="#QueriesByTypeReport">Queries by type</a></li>};
}
if (!$disable_lock && scalar keys %lock_info > 0) {
print $fh qq{<li><a href="#ConnectionsHostReport">Connections per host</a></li><li>};
}
}
- if (!$disable_query && !$log_duration) {
+ if (!$disable_query && (!$log_duration || $enable_log_min_duration)) {
print $fh
qq{<a href="#SlowestQueriesReport">Slowest queries</a></li><li><a href="#NormalizedQueriesMostTimeReport">Queries that took up the most time (N)</a></li><li><a href="#NormalizedQueriesMostFrequentReport">Most frequent queries (N)</a></li><li><a href="#NormalizedQueriesSlowestAverageReport">Slowest queries (N)</a></li>};
}
$d1 = '';
$d2 = '';
- if (!$disable_query && !$log_duration) {
+ if (!$disable_query && (!$log_duration || $enable_log_min_duration)) {
# Select queries
foreach my $tm (sort {$a <=> $b} keys %per_hour_info) {
$tm =~ /(\d{4})(\d{2})(\d{2})/;
}
# INSERT/DELETE/UPDATE/SELECT repartition
- if (!$disable_type && !$log_duration) {
+ if (!$disable_type && (!$log_duration || $enable_log_min_duration)) {
print $fh qq{
<h2 id="QueriesByTypeReport">Queries by type <a href="#top" title="Back to top">^</a></h2>
<table>
}
# Show top informations
- if (!$disable_query && !$log_duration) {
+ if (!$disable_query && (!$log_duration || $enable_log_min_duration)) {
print $fh qq{
<h2 id="SlowestQueriesReport">Slowest queries <a href="#top" title="Back to top">^</a></h2>
<table class="queryList">
$t_duration = $1;
$t_action = 'statement';
$prefix_vars{'t_query'} = 'No log_min_duration';
- } else {
+ } elsif (!$enable_log_min_duration) {
if (exists $cur_info{$t_pid} && ($prefix_vars{'t_session_line'} != $cur_info{$t_pid}{session})) {
&store_queries($t_pid);
delete $cur_info{$t_pid};
}
return;
}
- } else {
+ }
+ if (!$log_duration || $enable_log_min_duration) {
if ($prefix_vars{'t_query'} =~ s/duration: ([0-9\.]+) ms (query|statement): //is) {
$t_duration = $1;
$t_action = $2;