Show active and idle connections grouped by state and client address for all the databases in the server:
SELECT count(datid), state, client_addr FROM pg_stat_activity group by state, client_addr;
Show active and idle connections grouped by state and client address for all the databases in the server:
SELECT count(datid), state, client_addr FROM pg_stat_activity group by state, client_addr;