Finding and Killing Sessions in Amazon Redshift

The first step in killing a session in an Amazon Redshift database is to find the session to kill. Please be sure to connect to Redshift as a user that has the privileges necessary to run queries to find sessions and execute commands to kill sessions. To find the currently active sessions in Redshift, execute the following query:

SELECT procpid, datname, usename, current_query, query_start FROM pg_catalog.pg_stat_activity;

The above query will return the running sessions. After determining which session to kill, get the pid from the above query results and execute the following command to kill the session. The below example assumes the id is 9556:

SELECT pg_terminate_backend(9556);