Last active
July 27, 2021 06:12
-
-
Save StevenJL/1c62d1a3679aa017f66d64606fd6c148 to your computer and use it in GitHub Desktop.
See postgres connections
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 state, COUNT(*) FROM pg_stat_activity | |
WHERE pid <> pg_backend_pid() | |
GROUP BY 1; | |
# state | count | |
# ---------------------+------- | |
# active | 7 | |
# idle | 569 | |
# idle in transaction | 2 | |
# | 9 | |
# (4 rows) | |
SELECT application_name, COUNT(*) FROM pg_stat_activity | |
WHERE pid <> pg_backend_pid() | |
GROUP BY 1 ORDER BY 1; | |
# application_name | count | |
# ------------------------------------------------------------+------- | |
# web_server | 63 | |
# cron_job | 1 | |
# psql | 4 | |
# background_job | 15 | |
# (4 rows) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment