For PostgreSQL vacuum-aware monitoring
A query store with pg_stat_statements, autovacuum / bloat / dead tuple analysis, WAL accumulation through replication slots, logical replication subscriber tracking and RLS policy auditing.
A query store with pg_stat_statements, autovacuum / bloat / dead tuple analysis, WAL accumulation through replication slots, logical replication subscriber tracking and RLS policy auditing.
Ranking by queryid, total/mean exec time, rows, shared blks, temp blks. Resource scoring + classification (read-heavy, cpu-heavy, etc.).
get_top_queriesget_pg_statementsget_query_detailsget_query_historyExecution plan via EXPLAIN (ANALYZE, BUFFERS, FORMAT JSON), per-node cost, actual row count, buffer hit/read, JIT statistics.
get_execution_planActive queries from pg_stat_activity, wait_event_type, wait_event, backend state. Lock wait analysis.
get_wait_eventsget_active_queriesget_active_sessionsget_live_query_monitorIndex scan vs sequential scan distribution from pg_stat_user_indexes, dead indexes with idx_scan = 0, missing index suggestions.
get_index_usage_statsget_missing_index_recommendationsActive backend count, idle in transaction, max_connections usage ratio, connection pool behavior, per-user / per-DB distribution.
get_connection_statsAll GUC parameters, value source (default/configfile/environment), restart-required flags, performance settings (work_mem, shared_buffers).
get_pg_settingslast_vacuum, last_autovacuum, last_analyze from pg_stat_user_tables, n_dead_tup ratio, autovacuum_count. Which table is overdue, which runs too often?
get_vacuum_statsget_table_statsStatistics-based bloat estimate: actual size vs expected size, % bloat, most bloated tables / indexes. VACUUM FULL or pg_repack candidates.
get_bloat_statsLong-running transactions block autovacuum. Transactions exceeding the threshold (minutes) are detected; idle in transaction (aborted) ones are flagged.
get_long_running_transactionsBackground writer and checkpoint statistics, buffers_checkpoint vs buffers_clean ratio, checkpoint_warning, max_wal_size behavior.
get_bgwriter_stats-- Vacuum stats: en geç vacuum gören tablolar SELECT schemaname, relname, n_live_tup, n_dead_tup, round(n_dead_tup::numeric / nullif(n_live_tup,0) * 100, 2) AS dead_pct, last_vacuum, last_autovacuum, autovacuum_count FROM pg_stat_user_tables WHERE n_dead_tup > 1000 ORDER BY dead_pct DESC NULLS LAST LIMIT 50;
pg_stat_replication: client_addr, state, sync_state, write_lag, flush_lag, replay_lag (interval). Synchronous replication behavior.
get_replication_statuspg_replication_slots: WAL bytes accumulating in inactive slots, retained_wal, restart_lsn. Early detection of disk-fill risk.
get_replication_slotsPublications, subscriptions, subscription state, last_msg_send_time, last_msg_receipt_time, latest_end_lsn. Logical decoding health.
get_logical_replicationpg_stat_archiver: archived_count, failed_count, last_archived_wal, last_archived_time. Archive lag is critical for PITR.
get_wal_archiver_statusSUPERUSER account count, public schema permissions, password authentication, ssl connection status, log_statement = 'all' warning.
get_security_checksWhich tables have RLS enabled, is FORCE RLS applied, policy expressions, affected role list. bypassrls accounts that bypass RLS.
get_row_level_securitySequences nearing exhaustion (% approach to max_value), bigint vs integer usage check, identity column migrations.
get_sequence_healthInstalled extensions (version + namespace), out-of-date warnings (default_version > installed_version), Foreign Data Wrapper configuration.
get_extensionsget_foreign_data_wrappersDisk footprint of all databases in the cluster, largest tables, schema-based distribution, growth trend.
get_db_sizespg_database_sizeSpilling queries: temporary files written to disk because work_mem was insufficient. work_mem tuning analysis via temp_files / temp_bytes.
get_temp_workspace_metricsget_temp_file_statsPer-tablespace disk usage, base + pg_tblspc, drive-fullness alerts (warning %, critical %).
get_disk_volumesget_database_filesblks_read, blks_hit, hit ratio, deadlocks, conflicts from pg_stat_database. Detail via pg_stat_io for PG 14+.
get_io_latency(hours)get_io_stats(hours)| Capability | Description | PG Object |
|---|---|---|
| Performance & Query | ||
| Top queries | pg_stat_statements TOP-N | pg_stat_statements |
| Plan analysis | EXPLAIN (ANALYZE, BUFFERS, JSON) | EXPLAIN |
| Wait events | Backend wait_event_type | pg_stat_activity |
| Active sessions | Live query monitor | pg_stat_activity |
| Index usage | Idx scan vs seq scan | pg_stat_user_indexes |
| Missing index | Heuristic + sequential scan | — |
| Connection stats | max_connections usage | pg_stat_activity |
| pg_settings | GUC parameter list | pg_settings |
| Vacuum & Bloat | ||
| Vacuum stats | last_vacuum, dead_tup ratio | pg_stat_user_tables |
| Bloat estimate | Table + index bloat % | pgstattuple / istatistik |
| Long tx | Idle in tx + autovacuum blocking | pg_stat_activity |
| BG writer | Buffers_checkpoint vs buffers_clean | pg_stat_bgwriter |
| Table stats | n_live_tup, n_dead_tup | pg_stat_user_tables |
| Replication & WAL | ||
| Streaming replication | Replica lag (write/flush/replay) | pg_stat_replication |
| Replication slots | Retained WAL bytes | pg_replication_slots |
| Logical replication | Publication / subscription | pg_publication / pg_subscription |
| WAL archiver | Archive lag, failed count | pg_stat_archiver |
| Security | ||
| Security checks | Superuser, public grants, SSL | pg_authid + checks |
| Row Level Security | Active policies, FORCE RLS | pg_policies |
| Sequence health | Exhaustion % warning | pg_sequences |
| Extensions | Outdated detection | pg_extension |
| FDW | Server + user mapping | pg_foreign_server |
| Storage & I/O | ||
| DB sizes | All databases | pg_database_size |
| Temp files | Spilling queries | pg_stat_database |
| Disk volumes | Tablespace usage | pg_tablespace |
| I/O stats | blks_read / hit ratio | pg_stat_database |
From PG 12 to 16, Aurora to Cloud SQL — one platform, deep metric coverage.