Created
January 29, 2020 15:20
-
-
Save keepitsimple/2fbd4875e70114db599a3c1eed78982b to your computer and use it in GitHub Desktop.
PostgreSQL connections count
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 max_conn,used,res_for_super,max_conn-used-res_for_super res_for_normal | |
from | |
(select count(*) used from pg_stat_activity) t1, | |
(select setting::int res_for_super from pg_settings where name=$$superuser_reserved_connections$$) t2, | |
(select setting::int max_conn from pg_settings where name=$$max_connections$$) t3; | |
select * from pg_stat_activity; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment