Which of the following two is more accurate?
select numbackends from pg_stat_database; select count(*) from pg_stat_activity;
Aggregation of all postgres sessions per their status (how many are idle, how many doing something...)
select state, count(*) from pg_stat_activity where pid <> pg_backend_pid() group by 1 order by 1;