Skip to content

Instantly share code, notes, and snippets.

@steklopod
Last active February 13, 2019 13:44
Show Gist options
  • Save steklopod/a29a979de0f08a98e6befd96443a3a00 to your computer and use it in GitHub Desktop.
Save steklopod/a29a979de0f08a98e6befd96443a3a00 to your computer and use it in GitHub Desktop.
Kill SQL process
SELECT *
FROM pg_stat_activity
WHERE state = 'active';
SELECT pg_terminate_backend(pid)
FROM pg_stat_activity
WHERE datname = 'payhub'
AND pid <> pg_backend_pid()
AND state in ('active');
############################
SELECT * FROM pg_stat_activity WHERE state = 'active';
Find the process you want to kill, then type:
SELECT pg_cancel_backend(<pid of the process>)
If the process cannot be killed, try:
SELECT pg_terminate_backend(<pid of the process>)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment