Skip to content

Instantly share code, notes, and snippets.

@akahn
Created May 15, 2012 17:05
Show Gist options
  • Select an option

  • Save akahn/2703322 to your computer and use it in GitHub Desktop.

Select an option

Save akahn/2703322 to your computer and use it in GitHub Desktop.
Currently running PostgreSQL queries sorted by duration
SELECT datname, procpid, usename, client_addr, current_query, (current_timestamp - query_start) AS duration
FROM pg_stat_activity
WHERE datname = 'your-database'
ORDER BY duration DESC;
@akahn

akahn commented May 15, 2012

Copy link
Copy Markdown
Author

From @DBNess, of course.

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