Killing Sessions
Killing Queries and Sessions
Killing Queries and Sessions
To terminate long running queries and blocking sessions...
SELECT pid
FROM pg_stat_activity;
To cancel the query without disconnecting the connection (preferred)...
SELECT pg_cancel_backend(pid);
To terminate the connection and cancel all other queries in that connection (only if absolutely necessary)...
SELECT pg_terminate_backend(pid);