postgresql kill query pg_stat_activity code example
Example: postgres kill running query
--Stop the query normally
SELECT pg_cancel_backend(pid);
--Terminate immediately
SELECT pg_terminate_backend(pid);
--Stop the query normally
SELECT pg_cancel_backend(pid);
--Terminate immediately
SELECT pg_terminate_backend(pid);