Skip to content

Instantly share code, notes, and snippets.

@rbreslow
Created November 15, 2021 17:02
Show Gist options
  • Save rbreslow/2974ab7cb2e4634e115275a5ab4800e6 to your computer and use it in GitHub Desktop.
Save rbreslow/2974ab7cb2e4634e115275a5ab4800e6 to your computer and use it in GitHub Desktop.
SELECT
client_addr,
query_start,
state_change,
wait_event,
state,
EXTRACT(epoch FROM (state_change - query_start)) AS execution_duration,
EXTRACT(epoch FROM (CURRENT_TIMESTAMP - query_start)) AS total_duration,
query
FROM
pg_stat_activity
WHERE
wait_event IS NOT NULL
AND application_name = ''
AND client_addr NOT IN ('10.0.0.247', '127.0.0.1')
AND backend_type = 'client backend';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment