Created
August 22, 2025 22:03
-
-
Save akramarev/b8a3cd48caaf1268bd1e046a5fb12033 to your computer and use it in GitHub Desktop.
[Active connections in Postgres]
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 | |
usename, | |
application_name, | |
client_addr, | |
COUNT(*) as connection_count, | |
MIN(backend_start) as first_connection, | |
MAX(backend_start) as latest_connection | |
FROM pg_stat_activity | |
GROUP BY usename, application_name, client_addr | |
ORDER BY connection_count DESC; | |
SELECT | |
COUNT(*) as connection_count | |
FROM pg_stat_activity; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment