Skip to content

Instantly share code, notes, and snippets.

@keepitsimple
Created January 29, 2020 15:20
Show Gist options
  • Save keepitsimple/2fbd4875e70114db599a3c1eed78982b to your computer and use it in GitHub Desktop.
Save keepitsimple/2fbd4875e70114db599a3c1eed78982b to your computer and use it in GitHub Desktop.
PostgreSQL connections count
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