Scripts
Identify Running PostgreSQL Autovacuum Worker Sessions
May 24, 2026 / · 7 min read · pg_stat_activity pg_stat_progress_vacuum autovacuum backend_type vacuum administration pg_stat_user_tables ·Identify Running PostgreSQL Autovacuum Worker Sessions Autovacuum lag is a slow accumulation. Every UPDATE rewrites the row and creates a new HOT chain, the launcher falls behind during write spikes, and over weeks a busy OLTP cluster ends up with three workers stuck on a handful of huge tables while smaller ones wait …
Read MoreMonitor PostgreSQL WAL Archiver Status with pg_stat_archiver
Monitor PostgreSQL WAL Archiver Status with pg_stat_archiver pg_stat_archiver is the canonical place to check whether PostgreSQL's continuous archiving is keeping up — a single-row view that exposes last_archived_wal, last_failed_wal, and the rolling failure count without parsing log files. On a healthy cluster the row …
Read MoreMonitor PostgreSQL Replication Lag with pg_stat_replication
May 22, 2026 / · 7 min read · pg_stat_replication replication wal standby monitoring administration ·Monitor PostgreSQL Replication Lag with pg_stat_replication A standby lagging more than a few seconds is rarely a transient hiccup — it is a query backlog on the standby, a network ceiling between the nodes, a misconfigured hot_standby_feedback, or a single-threaded apply storm. pg_stat_replication joined to …
Read MoreTune PostgreSQL Background Writer with pg_stat_bgwriter
May 21, 2026 / · 7 min read · pg_stat_bgwriter pg_stat_checkpointer background writer checkpointer performance administration ·Tune PostgreSQL Background Writer with pg_stat_bgwriter Where pg_stat_statements does query-level aggregation and pgBadger does after-the-fact log analysis, pg_stat_bgwriter operates at the buffer-cache layer — answering whether the bgwriter and checkpointer are keeping shared_buffers clean enough that foreground …
Read MoreMonitor PostgreSQL Wait Events Using pg_stat_activity
May 17, 2026 / · 4 min read · pg_stat_activity wait events performance monitoring session monitoring administration ·Understanding PostgreSQL Wait Events for Performance Analysis Every active PostgreSQL backend is either executing work or waiting. When a session waits, PostgreSQL records the reason in pg_stat_activity using two columns: wait_event_type and wait_event. Aggregating these across all sessions gives a clear picture of …
Read MoreMonitor PostgreSQL Vacuum Progress with pg_stat_progress_vacuum
May 16, 2026 / · 4 min read · pg_stat_progress_vacuum vacuum autovacuum performance monitoring administration pg_stat_activity pg_stat_user_tables ·Tracking Active Vacuum and Autovacuum Workers in PostgreSQL PostgreSQL vacuum is the maintenance process that removes dead tuples left behind by updates and deletes, reclaims storage, and prevents transaction ID wraparound. On active databases, autovacuum runs continuously in the background, but knowing whether it is …
Read MorePostgreSQL Physical Backup Guide with pg_basebackup
May 15, 2026 / · 9 min read · pg_basebackup backup physical backup replication recovery pg_stat_progress_basebackup ·PostgreSQL Physical Backups with pg_basebackup Seeding a new streaming standby and starting a point-in-time recovery chain are the same job at the first step: copy the whole cluster, consistently, while it keeps serving traffic. pg_basebackup does that over a normal replication connection, with no downtime and no …
Read MoreMonitor PostgreSQL Table Cache Hit Ratio with SQL
May 14, 2026 / · 4 min read · pg_statio_user_tables cache performance shared_buffers administration pg_statio_user_indexes ·Measuring PostgreSQL Table Cache Efficiency with pg_statio_user_tables PostgreSQL keeps frequently accessed data pages in shared_buffers to avoid hitting disk. When a backend reads a data block, PostgreSQL first checks shared_buffers; if the block is there, it counts as a heap hit. If it is not, PostgreSQL reads from …
Read MorePostgreSQL Replica Identity for Logical Replication
Check Replica Identity Settings in PostgreSQL Logical replication in PostgreSQL requires each replicated table to have a replica identity. The replica identity tells PostgreSQL which columns to include in the WAL record for UPDATE and DELETE operations so the subscriber can identify the row being changed. If replica …
Read MoreList PostgreSQL Collations with pg_collation and ICU
List Collations Available in PostgreSQL pg_collation is the system catalog that holds every collation a database can use — the sort-and-compare rules behind ORDER BY, DISTINCT, comparison operators and text indexes. One query against it shows each collation's name, the library that implements it, and the locale it maps …
Read More