PostgreSQL - Aborting a Query

If necessary, you can contact the DSA sysadmin for assistance in the Jupyter_environment channel on Teams. Or you can try the following:

  1. On the same server that the problem query was run on, open a new notebook or terminal
  2. Connect and run: SELECT pid, usename, query_start, query FROM pg_stat_activity WHERE state = 'active' and pid <> pg_backend_pid(); This will list the active sessions with the query that was run, excluding this query itself.
  3. Get the pid of the session for the query you want to abort.
  4. Run: SELECT pg_cancel_backend(pid); with the pid from step 3.

Need more information or help? Reach out to us at 📧 jcwdw@missouri.edu