Skip to content

Instantly share code, notes, and snippets.

@miohtama
Created December 2, 2021 17:39
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 miohtama/1be471f03ac6ab2d55197eb678183d33 to your computer and use it in GitHub Desktop.
Save miohtama/1be471f03ac6ab2d55197eb678183d33 to your computer and use it in GitHub Desktop.
PostgreSQL find long queries
SELECT
application_name,
pid,
now() - pg_stat_activity.query_start AS duration,
query,
state
FROM pg_stat_activity
WHERE (now() - pg_stat_activity.query_start) > interval '5 minutes';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment