Last active
April 16, 2024 20:15
-
-
Save romuald/f73aa7af4d32a4fe8866ca377d623d13 to your computer and use it in GitHub Desktop.
Show PostgreSQL current (running) process list;
This file contains 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 user, pid, client_addr, waiting, 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; |
I also don’t have a “waiting” in 13.4 interpretation
SELECT user, pid, client_addr, query, query_start, NOW() - query_start AS elapsed
FROM pg_stat_activity
WHERE query != ''
-- AND EXTRACT(EPOCH FROM (NOW() - query_start)) > 1
ORDER BY elapsed DESC;
I add the update, since the result is visible in google
Improve formatting
SELECT user, pid, client_addr, query, query_start, NOW() - query_start AS elapsed
FROM pg_stat_activity
WHERE query != ''
-- 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
I needed to remove
, waiting
in PG 14 to make it work because that column wasn't found.