replace simplistic backend count with pg_stat_activity analysis