Query Killer in PostgreSQL

PHOTO EMBED

Wed Aug 23 2023 08:07:52 GMT+0000 (Coordinated Universal Time)

Saved by @ClemensBerteld #sql

-- Kill all running queries
SELECT pg_cancel_backend(pid) FROM pg_stat_activity WHERE state = 'active' and pid <> pg_backend_pid();

-- Kill specific query
SELECT * FROM pg_stat_activity WHERE state = 'active';
SELECT pg_terminate_backend(<PID>);
content_copyCOPY