Skip to content

Instantly share code, notes, and snippets.

@martinrusev
Created October 21, 2012 09:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save martinrusev/3926494 to your computer and use it in GitHub Desktop.
Save martinrusev/3926494 to your computer and use it in GitHub Desktop.
PostgreSQL 9.1 slow queries logging
sudo apt-get install postgresql-contrib
# in /etc/postgresql/9.1/main/postgresql.conf
shared_preload_libraries = 'pg_stat_statements'
custom_variable_classes = 'pg_stat_statements'
pg_stat_statements.max = 100
pg_stat_statements.track = top
pg_stat_statements.save = off
sudo service postgresql restart
# In pqsl
CREATE EXTENSION pg_stat_statements;
# Result
SELECT query, calls, total_time FROM pg_stat_statements ORDER BY total_time DESC LIMIT 5;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment