Skip to content

Instantly share code, notes, and snippets.

@source-c
Last active June 9, 2023 10:41
Show Gist options
  • Save source-c/93268d8880974eecae59c188bfc8d7b8 to your computer and use it in GitHub Desktop.
Save source-c/93268d8880974eecae59c188bfc8d7b8 to your computer and use it in GitHub Desktop.
PG list queries that running longer than 1 minute
SELECT
pid,
user,
pg_stat_activity.query_start,
now() - pg_stat_activity.query_start AS query_time,
query,
state,
wait_event_type,
wait_event
FROM pg_stat_activity
WHERE (now() - pg_stat_activity.query_start) > interval '1 minutes';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment