Skip to content

Instantly share code, notes, and snippets.

@blacktrub
Created September 28, 2018 08:41
Show Gist options
  • Select an option

  • Save blacktrub/96e62d245b3f72c7f73ccb86de51a4bd to your computer and use it in GitHub Desktop.

Select an option

Save blacktrub/96e62d245b3f72c7f73ccb86de51a4bd to your computer and use it in GitHub Desktop.
enable pg_stat_statements
# paste this in your postgresql.conf
# in my way it is in /etc/postgresql/9.5/main/postgresql.conf
shared_preload_libraries = 'pg_stat_statements'
track_activity_query_size = 2048
pg_stat_statements.track = all
# after this you must restart postgresql daemon
sudo service postgresql restart
# connect to your db with psql and create extension
CREATE EXTENSION pg_stat_statements;
# now you may get all queries
SELECT * FROM pg_stat_statements;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment