Log long-running statements in PostgreSQL
12 Sep 2015
See http://www.postgresql.org/docs/9.4/static/runtime-config-logging.html for more details, but the quick solution is to set this in your postgresql.conf:
log_min_duration_statement = 2000 # log statements running longer than 2000ms (2 seconds)