Created
February 7, 2025 05:30
-
-
Save sumitsahoo/1871855c6bdcb76d6765c165e41db55a to your computer and use it in GitHub Desktop.
Kill a db transaction in PostgreSQL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Find in progress transactions | |
SELECT * | |
FROM pg_stat_activity | |
WHERE state = 'idle in transaction' | |
AND pid <> pg_backend_pid() | |
AND query LIKE '%<table_name>%'; | |
-- Kill process | |
SELECT pg_terminate_backend(<pid>); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment