Skip to content

Instantly share code, notes, and snippets.

@jayzeng
Last active October 30, 2016 23:32
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 jayzeng/496575b4f87d9b56e96a292b90548fc8 to your computer and use it in GitHub Desktop.
Save jayzeng/496575b4f87d9b56e96a292b90548fc8 to your computer and use it in GitHub Desktop.

Slow queries:

SELECT (SELECT datname FROM pg_database WHERE dbid = oid), query, calls,  (total_time / 1000 / 60) as total_minutes, (total_time/calls) as average_time FROM pg_stat_statements ORDER BY total_time DESC limit 5;

Missing indexes

SELECT relname, seq_scan, seq_tup_read, idx_scan, seq_tup_read / seq_scan as ratio from pg_stat_user_tables where seq_scan > 0 order by seq_tup_read desc limit 10;

more details: http://www.craigkerstiens.com/2013/01/10/more-on-postgres-performance/

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