Pg_terminate_backend
Cancel vs Terminate PostgreSQL Backends Explained
Apr 14, 2026 / · 4 min read · postgresql administration database performance pg_stat_activity pg_backend_pid pg_cancel_backend pg_terminate_backend ·Cancel vs Terminate PostgreSQL Backends: What Every DBA Should Know PostgreSQL gives you two tools for dealing with problem backends: pg_cancel_backend() and pg_terminate_backend(). They sound similar but behave very differently. Using the wrong one can disrupt users unnecessarily, or leave a problematic connection in …
Read MoreFind Idle in Transaction Sessions in PostgreSQL
Mar 28, 2026 / · 4 min read · postgresql administration monitoring troubleshooting database pg_locks pg_stat_activity pg_cancel_backend pg_terminate_backend ·How to Find Idle in Transaction Sessions in PostgreSQL An idle-in-transaction session is a database connection that has started a transaction but is not currently running a query. It is just sitting there, holding the transaction open. This is different from a regular idle connection, which has no open transaction. …
Read MoreKill Idle PostgreSQL Sessions with SQL
Mar 24, 2026 / · 9 min read · postgresql database administration sql queries connection management performance tuning pg_stat_activity postgres dba pg_backend_pid pg_cancel_backend pg_terminate_backend ·Kill Idle PostgreSQL Sessions with SQL The connection count sits at max_connections, new clients are being refused, and pg_stat_activity is full of sessions that have run nothing for hours. Freeing the slots takes one statement, pg_terminate_backend(), but the choices around it decide whether the cleanup is safe: which …
Read More