Skip to content

Instantly share code, notes, and snippets.

@mccun934
Created October 25, 2016 16:00
Show Gist options
  • Save mccun934/51b52548b829ebf2ed54502230e6db48 to your computer and use it in GitHub Desktop.
Save mccun934/51b52548b829ebf2ed54502230e6db48 to your computer and use it in GitHub Desktop.
1) Edit /var/lib/pgsql/data/postgresql.conf
2) Change log_min_duration_statement to 500:
log_min_duration_statement = 500 # -1 is disabled, 0 logs all statements
# and their durations, > 0 logs only
# statements running at least this number
# of milliseconds
This will log any query that runs longer than .5 seconds
3) Reload configurations:
echo "SELECT pg_reload_conf();" | sudo -u postgres psql
4) Now in /var/lib/pgsql/data/pg_log you can tail today's logfile, eg:
# tail -f postgresql-Tue.log
2016-10-25 11:58:06 EDT LOG: received SIGHUP, reloading configuration files
2016-10-25 11:58:17 EDT LOG: received SIGHUP, reloading configuration files
2016-10-25 11:58:17 EDT LOG: parameter "log_min_duration_statement" changed to "500"
and should start to see queries that take more than .5 seconds show up
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment