Postgres TOAST: A Practical Storage Checklist

Postgres moves any row value over roughly 2KB (TOAST_TUPLE_THRESHOLD) out of the main table and into a hidden pg_toast table, compressing or splitting it along the way. That's TOAST — The Oversized-Attribute Storage Technique — and it's why a table full of jsonb or text columns can behave very differently from a table of integers, …

Read more

Postgres Row-Level Security: A Multi-Tenant Playbook

What Postgres Row-Level Security Actually Does Row-level security (RLS) lets Postgres filter and check rows per query, per role, based on a policy you define in SQL. Instead of adding WHERE tenant_id = :current_tenant to every query in every service, you write the rule once and the database enforces it — on your API, your …

Read more

Fix “No pg_hba.conf Entry for Host” in Postgres

"No pg_hba.conf Entry for Host": What the Error Actually Means and How to Fix It If Postgres just handed you FATAL: no pg_hba.conf entry for host "10.0.2.15", user "app", database "orders", SSL off, here's the short version: your connection reached the server, but no line in pg_hba.conf matched the client address, database, user, and encryption …

Read more

Postgres Wait Events: A Practical Triage Guide

Your query is slow. Postgres already told you why. The usual sequence when something goes sideways: someone pastes a slow query into Slack, someone else runs EXPLAIN, a third person SSHes into the box and stares at top. Forty minutes later you know the plan is fine and the CPU is at 30% and you …

Read more

Postgres Replication Lag Is Four Numbers, Not One

Postgres Replication Lag Is Four Numbers, Not One The page comes in at 03:14: "replica is lagging." That sentence tells you nothing useful. Lagging where? Postgres doesn't have a lag counter. It has a pipeline with four measurable checkpoints, and the primary exposes all four side by side in pg_stat_replication. Know which gap is growing …

Read more

How to Increase max_connections in Postgres Safely

To increase max_connections in Postgres, run ALTER SYSTEM SET max_connections = N; (or edit postgresql.conf) and restart the server — a reload alone won't apply it, because max_connections is a postmaster-context parameter read once at startup. That's the easy part. The part that bites you three days later is sizing that number against real RAM, …

Read more

PostgreSQL Transaction ID Wraparound: Cause and Fix

PostgreSQL transaction ID wraparound happens when the 32-bit XID counter runs out of safe room and the database stops accepting new writes to protect committed data from silently disappearing. It's not corruption — it's a deliberate safety interlock. Here's the mechanism, the exact diagnostic queries, and the recovery path that actually works. 📖 Read the …

Read more