Last active
January 23, 2021 07:53
-
-
Save StevenJL/9fad854f29c7a3868670bc5b69580c36 to your computer and use it in GitHub Desktop.
Psql Oldest Running Query
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT application_name, | |
pid, | |
state, | |
age(clock_timestamp(), query_start), /* How long has the query has been running in h:m:s */ | |
usename, | |
query /* The query text */ | |
FROM pg_stat_activity | |
WHERE state != 'idle' | |
AND query NOT ILIKE '%pg_stat_activity%' | |
ORDER BY query_start asc; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment