Created
October 21, 2012 09:35
-
-
Save martinrusev/3926494 to your computer and use it in GitHub Desktop.
PostgreSQL 9.1 slow queries logging
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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