Close all connections from a Postgres database
✓ Published0🌍 Public
LLuisSevillano
Last edited Dec 6, 2018
Created on Dec 6, 2018
This example shows how to forcibly terminate every active connection to a named Postgres database except the current session. The SQL query selects all rows from `pg_stat_activity` and calls `pg_terminate_backend(pid)` for each matching process ID, filtering by `datname = 'database'` and excluding the backend’s own PID. The query returns the full activity listing alongside the termination result for each row. The visualization relies solely on the Postgres system catalog function, with no external charting libraries or rendering pipeline.
AI-generated description