PostgreSQL için vacuum-aware izleme

pg_stat_statements ile sorgu deposu, autovacuum / bloat / dead tuple analizi, replication slots ile WAL birikimi, logical replication subscriber takibi ve RLS politikalarının kapsam denetimi.

Beta durumu: Provider canlı, üretim PoC kapsamında çalışıyor. SQL Server'daki 160+ async DBA action derinliğine paritetik eşitleme 2026-Q3'te hedefleniyor. Detaylar için yol haritamızı inceleyin.
PostgreSQL 12 13 / 14 / 15 / 16 Amazon Aurora Cloud SQL Azure DB for PG Citus
35+İzleme Metodu
pg_statNative istatistik
RLSRow Level Security audit
PG 12+Tam uyumluluk

pg_stat_statements, EXPLAIN ANALYZE entegrasyonu

Top Sorgular

pg_stat_statements TOP-N

queryid bazlı sıralama, total/mean exec time, rows, shared blks, temp blks. Resource scoring + sınıflandırma (read-heavy, cpu-heavy, etc.).

  • get_top_queries
  • get_pg_statements
  • get_query_details
  • get_query_history
EXPLAIN

Plan inceleme

EXPLAIN (ANALYZE, BUFFERS, FORMAT JSON) ile yürütme planı, node bazlı maliyet, gerçek satır sayısı, buffer hit/read, JIT istatistikleri.

  • get_execution_plan
  • Plan tree görselleştirme
  • Buffer hit/read
  • JIT compilation stats
Wait Events

Wait event & aktif sorgular

pg_stat_activity'den aktif sorgular, wait_event_type, wait_event, backend state. Lock wait analizi.

  • get_wait_events
  • get_active_queries
  • get_active_sessions
  • get_live_query_monitor
Index

Index kullanımı & eksik index

pg_stat_user_indexes ile index scan vs sequential scan dağılımı, idx_scan = 0 olan ölü index'ler, missing index önerileri.

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

Connection & backend stats

Aktif backend sayısı, idle in transaction, max_connections kullanım oranı, connection pool davranışı, kullanıcı / DB başına dağılım.

  • get_connection_stats
  • Idle in transaction
  • max_connections kullanımı
  • Per-DB / per-user dağılım
Settings

pg_settings & konfigürasyon

Tüm GUC parametreleri, değer kaynağı (default/configfile/environment), restart gerektirenler, performance ayarları (work_mem, shared_buffers).

  • get_pg_settings
  • GUC source tracking
  • Restart-required ayarlar
  • Memory ayarları analizi

Autovacuum sağlığı ve bloat tespiti

Vacuum Stats

Vacuum & analyze tarihçesi

pg_stat_user_tables üzerinden last_vacuum, last_autovacuum, last_analyze, n_dead_tup oranı, autovacuum_count. Hangi tablo geç kalmış, hangisi sık çalıştırılmış?

  • get_vacuum_stats
  • get_table_stats
  • Dead tuple oranı
  • Autovacuum frekansı
Bloat

Tablo & index bloat

İstatistik tabanlı bloat tahmini: gerçek boyut vs olması gereken boyut, % bloat, en şişkin tablolar / index'ler. VACUUM FULL veya pg_repack adayları.

  • get_bloat_stats
  • Table bloat %
  • Index bloat %
  • VACUUM FULL adayları
Long Tx

Uzun transaction tespiti

Uzun süreli transaction'lar autovacuum'u bloklar. Eşik dakika geçen tx'ler tespit edilir, idle in transaction (aborted) olanlar uyarılır.

  • get_long_running_transactions
  • Idle in transaction
  • Idle in transaction (aborted)
  • Vacuum bloklayıcılar
BG Writer

Background writer & checkpoint

Background writer ve checkpoint istatistikleri, buffers_checkpoint vs buffers_clean oranı, checkpoint_warning, max_wal_size davranışı.

  • get_bgwriter_stats
  • Checkpoint frekansı
  • Buffers written
  • Stats reset zamanı
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). Senkron replikasyon davranışı.

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

Replication slot lag

pg_replication_slots: aktif olmayan slot'larda biriken WAL byte miktarı, retained_wal, restart_lsn. Disk dolma riskinin erken tespiti.

  • 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 sağlığı.

  • get_logical_replication
  • Publication tabloları
  • Subscription state
  • Apply worker durumu
WAL Archiver

WAL archive durumu

pg_stat_archiver: archived_count, failed_count, last_archived_wal, last_archived_time. Arşiv gecikmesi PITR için kritik.

  • get_wal_archiver_status
  • Archive lag (saat)
  • Failed count
  • archive_command kontrolü

RLS politikaları, pg_hba ve roller

Security Checks

Güvenlik denetimleri

SUPERUSER hesap sayısı, public schema yetkileri, password authentication, ssl bağlantı durumu, log_statement = 'all' uyarısı.

  • get_security_checks
  • SUPERUSER aşırılığı
  • Public schema grants
  • SSL bağlantı zorunluluğu
RLS

Row Level Security audit

Hangi tablolarda RLS aktif, FORCE RLS uygulanmış mı, policy expressions, etkilenen rol listesi. RLS bypass eden bypassrls hesapları.

  • get_row_level_security
  • RLS aktif tablolar
  • FORCE RLS tablolar
  • BYPASSRLS hesapları
Sequences

Sequence health

Tükenmek üzere olan sequence'lar (max_value'ya yaklaşma %), bigint vs integer kullanım kontrolü, identity column geçişleri.

  • get_sequence_health
  • Tükenme yüzdesi
  • integer vs bigint
  • Identity columns
Extensions

Extensions & FDW

Yüklü extension'lar (versiyon + namespace), eski sürüm uyarıları (default_version > installed_version), Foreign Data Wrapper yapılandırması.

  • get_extensions
  • Outdated extension uyarısı
  • get_foreign_data_wrappers
  • Server + user mappings

DB sizes, temp files, latency

DB Sizes

Veritabanı boyutları

Cluster içindeki tüm veritabanlarının disk üzerinde kaplaması, en büyük tablolar, schema bazlı dağılım, growth trend.

  • get_db_sizes
  • pg_database_size
  • Top tablolar
  • Schema dağılımı
Temp Files

Temp file usage

Spilling sorgular: work_mem yetmediği için diske yazılan geçici dosyalar. temp_files / temp_bytes ile work_mem ayarı analizi.

  • get_temp_workspace_metrics
  • get_temp_file_stats
  • work_mem yetersizliği
  • Spill query tespiti
Disk Volumes

Disk & tablespaces

Tablespace başına disk kullanımı, base + pg_tblspc, sürücü dolma uyarıları (warning %, critical %).

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

I/O metrics

pg_stat_database üzerinden blks_read, blks_hit, hit ratio, deadlocks, conflicts. PG 14+ pg_stat_io ile detay.

  • get_io_latency(hours)
  • get_io_stats(hours)
  • Buffer cache hit ratio
  • pg_stat_io (PG 14+)

PostgreSQL provider izleme & denetim metodları

Yetenek Açıklama PG Object
Performance & Query
Top sorgularpg_stat_statements TOP-Npg_stat_statements
Plan analiziEXPLAIN (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 kullanımıpg_stat_activity
pg_settingsGUC parametre listesipg_settings
Vacuum & Bloat
Vacuum statslast_vacuum, dead_tup oranıpg_stat_user_tables
Bloat estimateTablo + index bloat %pgstattuple / istatistik
Long txIdle in tx + autovacuum bloklamapg_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 SecurityAktif policy'ler, FORCE RLSpg_policies
Sequence healthTükenme % uyarısıpg_sequences
ExtensionsOutdated tespitipg_extension
FDWServer + user mappingpg_foreign_server
Storage & I/O
DB sizesTüm veritabanlarıpg_database_size
Temp filesSpilling sorgularpg_stat_database
Disk volumesTablespace usagepg_tablespace
I/O statsblks_read / hit ratiopg_stat_database

PostgreSQL ortamınızı vacuum-aware izleyin

PG 12'den 16'ya, Aurora'dan Cloud SQL'e — tek platform, derin metric kapsaması.