Skip to content

Instantly share code, notes, and snippets.

@jeffersonsouza
Created August 30, 2018 22:40
Show Gist options
  • Save jeffersonsouza/8cfbef0d04c3ea51feae14300d6a6008 to your computer and use it in GitHub Desktop.
Save jeffersonsouza/8cfbef0d04c3ea51feae14300d6a6008 to your computer and use it in GitHub Desktop.
-- Get active queries with duration greater than 1 sec
SELECT (now() - query_start) as duracao, pid, query, usename, datname
FROM pg_stat_activity
WHERE state = 'active'
AND query_start < now() - '1 seconds'::interval
AND pid <> pg_backend_pid()
ORDER BY query_start ASC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment