Skip to content

Instantly share code, notes, and snippets.

@waltton
Created March 13, 2018 21:53
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 waltton/fdc485ff62a8b24be183a15e2624f4a7 to your computer and use it in GitHub Desktop.
Save waltton/fdc485ff62a8b24be183a15e2624f4a7 to your computer and use it in GitHub Desktop.
watch -n 5 'psql -U postgres -h HOST DATABASE -c "select pg_class.relname, count(*), SUM(now() - pg_stat_activity.query_start) from pg_catalog.pg_locks JOIN pg_catalog.pg_stat_activity ON pg_stat_activity.pid = pg_locks.pid JOIN pg_class ON pg_class.oid = pg_locks.relation GROUP BY pg_class.relname ORDER BY SUM(now() - pg_stat_activity.query_start) DESC;"'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment