postgresql how to kill pid code example
Example 1: postgres kill running query
--Stop the query normally
SELECT pg_cancel_backend(pid);
--Terminate immediately
SELECT pg_terminate_backend(pid);
Example 2: psql kill pid
select pg_terminate_backend(pid)
from pg_stat_activity
where pid = '18765';