Method: PgHero::Methods::Connections#connection_states

Defined in:
lib/pghero/methods/connections.rb

#connection_statesObject



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/pghero/methods/connections.rb', line 43

def connection_states
  states = select_all <<~SQL
    SELECT
      state,
      COUNT(*) AS connections
    FROM
      pg_stat_activity
    GROUP BY
      1
    ORDER BY
      2 DESC, 1
  SQL

  states.to_h { |s| [s[:state], s[:connections]] }
end