Too Long; Didn't Read
Postgres: Idle queries and pg_locks are easy to find when it seems to “hang” or be super slow on queries. You can simply kill the offending query with a single SQL statement. The easiest way to do this, is to run your query that seems to hang forever. Then run this query: SELECT * FROM pg_lock WHERE NOT GRANTED;. (PID from previous query) Then kill the query that is running (granted = true) Just take the PID from the query above and cancel it.