lib/postgres/vacuum/monitor/query.rb in postgres-vacuum-monitor-0.10.1 vs lib/postgres/vacuum/monitor/query.rb in postgres-vacuum-monitor-0.11.0

- old
+ new

@@ -1,16 +1,18 @@ +# frozen_string_literal: true + module Postgres module Vacuum module Monitor module Query extend self STATES = ["'idle in transaction'", "'active'"].freeze - THRESHOLD_SETTING = "'autovacuum_vacuum_threshold'".freeze - SCALE_FACTOR_SETTING = "'autovacuum_vacuum_scale_factor'".freeze - MAX_AGE_SETTING = "'autovacuum_freeze_max_age'".freeze - PG_CATALOG = "'pg_catalog'".freeze + THRESHOLD_SETTING = "'autovacuum_vacuum_threshold'" + SCALE_FACTOR_SETTING = "'autovacuum_vacuum_scale_factor'" + MAX_AGE_SETTING = "'autovacuum_freeze_max_age'" + PG_CATALOG = "'pg_catalog'" def long_running_transactions <<-SQL SELECT * FROM ( @@ -79,11 +81,11 @@ blocking_activity.query AS current_statement_in_blocking_process, blocked_activity.application_name AS blocked_application, blocking_activity.application_name AS blocking_application FROM pg_catalog.pg_locks blocked_locks JOIN pg_catalog.pg_stat_activity blocked_activity ON blocked_activity.pid = blocked_locks.pid - JOIN pg_catalog.pg_locks blocking_locks + JOIN pg_catalog.pg_locks blocking_locks ON blocking_locks.locktype = blocked_locks.locktype AND blocking_locks.DATABASE IS NOT DISTINCT FROM blocked_locks.DATABASE AND blocking_locks.relation IS NOT DISTINCT FROM blocked_locks.relation AND blocking_locks.page IS NOT DISTINCT FROM blocked_locks.page AND blocking_locks.tuple IS NOT DISTINCT FROM blocked_locks.tuple @@ -98,13 +100,13 @@ SQL end def connection_state <<-SQL - SELECT - state, count(*) as connection_count - FROM pg_stat_activity - GROUP BY state + SELECT + state, count(*) as connection_count + FROM pg_stat_activity + GROUP BY state ORDER BY connection_count DESC; SQL end def connection_idle_time