The following sample reports are built from a log file generated by a pgbench script so they are not really representative of the output generated with a real life log.
The following command generates a default report:
$ pgfouine.php -file logs_pgbench_20051211063633.log > sample_default.html
If we suppose UPDATE queries are not relevant to optimize our application, we can filter them:
$ pgfouine.php -file logs_pgbench_20051211063633.log -onlyselect > sample_only_select.html
We can choose the generated reports with the -reports option:
$ pgfouine.php -file logs_pgbench_20051211063633.log -reports overall,bytype > sample_reports.html
If we want more examples for normalized queries, we can define it with the -examples option:
$ pgfouine.php -file logs_pgbench_20051211063633.log -examples 10 > sample_examples.html
If we want to generate an error report, we can use the "n-mostfrequenterrors" report type:
$ pgfouine.php -file logs_pgbench_20051211063633.log -reports n-mostfrequenterrors > sample_errors.html
It is also possible generate hourly statistics graphs which can help you to understand the activity of your database:
$ pgfouine.php -file logs_pgbench_20051211063633.log -report sample_hourly.html=overall,bytype,hourly \ -format html-with-graphs
$ pgfouine.php -file logs_history_sample.log -report history > sample_history.html
This is the command line I usually use to generate our reports:
$ pgfouine.php -file pgsql.log -top 40 \ -report queries.html=overall,bytype,slowest,n-mosttime,n-mostfrequent,n-slowestaverage \ -report hourly.html=overall,hourly \ -report errors.html=overall,n-mostfrequenterrors \ -format html-with-graphs
pgFouine can read from stdin using - instead of -file so we can use the following command line:
$ gunzip -c your_log_file.gz | pgfouine.php - -report overall,bytype > your_report.html
pgFouine can also analyze Apache logs by using the following CustomLog directive:
CustomLog /var/log/httpd/pgfouine.log "%{%b %e %H:%M:%S}t apache postgres[%P]: [%{%s}t%B-1] \
LOG: duration: %D us statement: %U 'vhost: %V' 'qs: %q'"