Skip to content

Instantly share code, notes, and snippets.

@troyk
Created January 5, 2013 18:18
Show Gist options
  • Star 23 You must be signed in to star a gist
  • Fork 11 You must be signed in to fork a gist
  • Save troyk/4462899 to your computer and use it in GitHub Desktop.
Save troyk/4462899 to your computer and use it in GitHub Desktop.
enable postgres pg_stat_statements
1) see re: increasing shmmax http://stackoverflow.com/a/10629164/1283020
2) add to postgresql.conf:
shared_preload_libraries = 'pg_stat_statements' # (change requires restart)
136 pg_stat_statements.max = 1000
137 pg_stat_statements.track = all
3) restart postgres
4) check it out in psql
psql: CREATE EXTENSION pg_stat_statements;
psql: \x
psql: SELECT query, calls, total_time, rows, 100.0 * shared_blks_hit / nullif(shared_blks_hit + shared_blks_read, 0) AS hit_percent FROM pg_stat_statements ORDER BY total_time DESC LIMIT 5;
@rxw1
Copy link

rxw1 commented Feb 18, 2015

thaaanks!

@jasongoodwin
Copy link

ty! helpful

@jsonzilla
Copy link

thanks

@Wyntuition
Copy link

This got me unstuck, thanks!

@LevAysan
Copy link

LevAysan commented Feb 8, 2018

thanks

@saclin
Copy link

saclin commented May 22, 2018

hey,I met a problem as follows,can anyone help?
only thing I should do first is to change postgresql.conf??
after the following change:
shared_preload_libraries = 'pg_pathman,pg_stat_statements'

systemctl restart postgresql-10
Job for postgresql-10.service failed because the control process exited with error code. See "systemctl status postgresql-10.service" and "journalctl -xe" for details.

and it restart successfully after I change it to
shared_preload_libraries = 'pg_pathman'

thanks in advance.

Copy link

ghost commented Sep 25, 2018

I had a similar issue. make sure to install postgresql-contrib package beforehand

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment