Skip to content

Instantly share code, notes, and snippets.

@BrianMehrman
Created December 12, 2024 15:36
Show Gist options
  • Save BrianMehrman/8a8ee839baf69588c8a0fee8922e2a10 to your computer and use it in GitHub Desktop.
Save BrianMehrman/8a8ee839baf69588c8a0fee8922e2a10 to your computer and use it in GitHub Desktop.
Get the current running postgres processes
SELECT user, pid, client_addr, wait_event, query, query_start, NOW() - query_start AS elapsed
FROM pg_stat_activity
WHERE query != '<IDLE>'
-- AND EXTRACT(EPOCH FROM (NOW() - query_start)) > 1
ORDER BY elapsed DESC;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment