Terminate (kill) specific session on a server

Redshift provides function to terminate specific session on a server.

Find session ID (process)

First we will identify the session we want to end. We do it by listing all sessions on the server with this query:

select * from stv_sessions;

Result

Result shows active sessions on server.

sample results

Kill session

Now we will use process ID (process) to kill the session (323 in our example):

select pg_terminate_backend(323);

Result

Redshift ends session and rolls back all transactions that are associated with it. sample results