How to Kill a Running Query in Redshift
Last updated July 25, 2026 · By the SaturnSQL team
Find the process id in STV_RECENTS or STV_INFLIGHT, then run PG_TERMINATE_BACKEND(pid) to kill the session, or CANCEL pid to cancel just the query and keep the connection alive.
Find running queries
SELECT pid, duration / 1000000 AS seconds, user_name, LEFT(query, 80) AS query
FROM stv_recents
WHERE status = 'Running'
ORDER BY duration DESC;Cancel or terminate
CANCEL 12345; -- cancel the query only
SELECT PG_TERMINATE_BACKEND(12345); -- kill the whole sessionSTV_INFLIGHT shows only queries actually executing on the compute nodes, which helps when STV_RECENTS is noisy. If a terminated query's transaction will not release its locks, PG_TERMINATE_BACKEND on the session is the reliable fix.
Run this in SaturnSQL
SaturnSQL is a browser-based SQL editor for teams: shared query library, schema-aware autocomplete, and scheduled exports to Google Sheets and Slack.
Try it free