NikolayS / postgres_dba

The missing set of useful tools for Postgres DBAs and all engineers
BSD 3-Clause "New" or "Revised" License
1.03k stars 113 forks source link

Better connection monitoring #29

Open NikolayS opened 5 years ago

NikolayS commented 5 years ago

example:

select
  state,
  count(*) "Total count",
  count(*) filter (where now() - state_change <= '1 second') as "Fresh (<1 sec)",
  count(*) filter (where now() - state_change > '1 second') as "Old (1+ sec)"
from pg_stat_activity
group by cube(state);

+ per host (clent_addr) + per app