DMCDMC Bilgi Teknolojileri

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.

Beta status: Provider is live and operates in production PoC scope. The 160+ async DBA action depth shipped for SQL Server is being progressively brought to PostgreSQL/MySQL/MongoDB. GA milestone: 2026-Q3.
PostgreSQL 12 13 / 14 / 15 / 16 Amazon Aurora Cloud SQL Azure DB for PG Citus
35+Monitoring Method
pg_statNative statistics
RLSRow Level Security audit
PG 12+Full compatibility

pg_stat_statements, EXPLAIN ANALYZE integration

Top Sorgular

pg_stat_statements TOP-N

Ranking by queryid, total/mean exec time, rows, shared blks, temp blks. Resource scoring + classification (read-heavy, cpu-heavy, etc.).

  • get_top_queries
  • get_pg_statements
  • get_query_details
  • get_query_history
EXPLAIN

Plan inspection

Execution plan via EXPLAIN (ANALYZE, BUFFERS, FORMAT JSON), per-node cost, actual row count, buffer hit/read, JIT statistics.

  • get_execution_plan
  • Plan tree visualization
  • Buffer hit/read
  • JIT compilation stats
Wait Events

Wait events & active queries

Active queries from pg_stat_activity, wait_event_type, wait_event, backend state. Lock wait analysis.

  • get_wait_events
  • get_active_queries
  • get_active_sessions
  • get_live_query_monitor
Index

Index usage & missing indexes

Index scan vs sequential scan distribution from pg_stat_user_indexes, dead indexes with idx_scan = 0, missing index suggestions.

  • get_index_usage_stats
  • get_missing_index_recommendations
  • Dead index detection
  • Index bloat
Connections

Connection & backend stats

Active backend count, idle in transaction, max_connections usage ratio, connection pool behavior, per-user / per-DB distribution.

  • get_connection_stats
  • Idle in transaction
  • max_connections usage
  • Per-DB / per-user distribution
Settings

pg_settings & configuration

All GUC parameters, value source (default/configfile/environment), restart-required flags, performance settings (work_mem, shared_buffers).

  • get_pg_settings
  • GUC source tracking
  • Restart-required settings
  • Memory settings analysis

Autovacuum health and bloat detection

Vacuum Stats

Vacuum & analyze history

last_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_stats
  • get_table_stats
  • Dead tuple ratio
  • Autovacuum frequency
Bloat

Table & index bloat

Statistics-based bloat estimate: actual size vs expected size, % bloat, most bloated tables / indexes. VACUUM FULL or pg_repack candidates.

  • get_bloat_stats
  • Table bloat %
  • Index bloat %
  • VACUUM FULL candidates
Long Tx

Long transaction detection

Long-running transactions block autovacuum. Transactions exceeding the threshold (minutes) are detected; idle in transaction (aborted) ones are flagged.

  • get_long_running_transactions
  • Idle in transaction
  • Idle in transaction (aborted)
  • Vacuum blockers
BG Writer

Background writer & checkpoint

Background writer and checkpoint statistics, buffers_checkpoint vs buffers_clean ratio, checkpoint_warning, max_wal_size behavior.

  • get_bgwriter_stats
  • Checkpoint frequency
  • Buffers written
  • Stats reset time
providers/postgresql.py SQL
-- 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;

Streaming, logical, slot lag, WAL archiver

Streaming

Streaming replication

pg_stat_replication: client_addr, state, sync_state, write_lag, flush_lag, replay_lag (interval). Synchronous replication behavior.

  • get_replication_status
  • Write / flush / replay lag
  • Sync vs async replicas
  • Wal sender state
Slots

Replication slot lag

pg_replication_slots: WAL bytes accumulating in inactive slots, retained_wal, restart_lsn. Early detection of disk-fill risk.

  • get_replication_slots
  • Retained WAL bytes
  • Active vs inactive
  • Confirmed flush LSN
Logical

Logical replication

Publications, subscriptions, subscription state, last_msg_send_time, last_msg_receipt_time, latest_end_lsn. Logical decoding health.

  • get_logical_replication
  • Publication tables
  • Subscription state
  • Apply worker status
WAL Archiver

WAL archive status

pg_stat_archiver: archived_count, failed_count, last_archived_wal, last_archived_time. Archive lag is critical for PITR.

  • get_wal_archiver_status
  • Archive lag (hours)
  • Failed count
  • archive_command check

RLS policies, pg_hba and roles

Security Checks

Security audits

SUPERUSER account count, public schema permissions, password authentication, ssl connection status, log_statement = 'all' warning.

  • get_security_checks
  • SUPERUSER excess
  • Public schema grants
  • SSL connection requirement
RLS

Row Level Security audit

Which tables have RLS enabled, is FORCE RLS applied, policy expressions, affected role list. bypassrls accounts that bypass RLS.

  • get_row_level_security
  • RLS-enabled tables
  • FORCE RLS tables
  • BYPASSRLS accounts
Sequences

Sequence health

Sequences nearing exhaustion (% approach to max_value), bigint vs integer usage check, identity column migrations.

  • get_sequence_health
  • Exhaustion percentage
  • integer vs bigint
  • Identity columns
Extensions

Extensions & FDW

Installed extensions (version + namespace), out-of-date warnings (default_version > installed_version), Foreign Data Wrapper configuration.

  • get_extensions
  • Outdated extension warning
  • get_foreign_data_wrappers
  • Server + user mappings

DB sizes, temp files, latency

DB Sizes

Database sizes

Disk footprint of all databases in the cluster, largest tables, schema-based distribution, growth trend.

  • get_db_sizes
  • pg_database_size
  • Top tables
  • Schema distribution
Temp Files

Temp file usage

Spilling queries: temporary files written to disk because work_mem was insufficient. work_mem tuning analysis via temp_files / temp_bytes.

  • get_temp_workspace_metrics
  • get_temp_file_stats
  • work_mem insufficient
  • Spill query detection
Disk Volumes

Disk & tablespaces

Per-tablespace disk usage, base + pg_tblspc, drive-fullness alerts (warning %, critical %).

  • get_disk_volumes
  • get_database_files
  • Tablespace usage
  • Warning / critical %
I/O Latency

I/O metrics

blks_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)
  • Buffer cache hit ratio
  • pg_stat_io (PG 14+)

PostgreSQL provider monitoring & audit methods

Capability Description PG Object
Performance & Query
Top queriespg_stat_statements TOP-Npg_stat_statements
Plan analysisEXPLAIN (ANALYZE, BUFFERS, JSON)EXPLAIN
Wait eventsBackend wait_event_typepg_stat_activity
Active sessionsLive query monitorpg_stat_activity
Index usageIdx scan vs seq scanpg_stat_user_indexes
Missing indexHeuristic + sequential scan
Connection statsmax_connections usagepg_stat_activity
pg_settingsGUC parameter listpg_settings
Vacuum & Bloat
Vacuum statslast_vacuum, dead_tup ratiopg_stat_user_tables
Bloat estimateTable + index bloat %pgstattuple / istatistik
Long txIdle in tx + autovacuum blockingpg_stat_activity
BG writerBuffers_checkpoint vs buffers_cleanpg_stat_bgwriter
Table statsn_live_tup, n_dead_tuppg_stat_user_tables
Replication & WAL
Streaming replicationReplica lag (write/flush/replay)pg_stat_replication
Replication slotsRetained WAL bytespg_replication_slots
Logical replicationPublication / subscriptionpg_publication / pg_subscription
WAL archiverArchive lag, failed countpg_stat_archiver
Security
Security checksSuperuser, public grants, SSLpg_authid + checks
Row Level SecurityActive policies, FORCE RLSpg_policies
Sequence healthExhaustion % warningpg_sequences
ExtensionsOutdated detectionpg_extension
FDWServer + user mappingpg_foreign_server
Storage & I/O
DB sizesAll databasespg_database_size
Temp filesSpilling queriespg_stat_database
Disk volumesTablespace usagepg_tablespace
I/O statsblks_read / hit ratiopg_stat_database

Monitor your PostgreSQL environment with vacuum awareness

From PG 12 to 16, Aurora to Cloud SQL — one platform, deep metric coverage.