skip to Main Content

My serverless redshift has thousands of running queries. I think it is stuck. I’m not sure how to cancel all queries and start fresh. Is there a way to do it?

2

Answers


  1. From CANCEL – Amazon Redshift:

    Cancels a database query that is currently running.

    CANCEL process_id [ 'message' ]
    

    The CANCEL command requires the process ID of the running query and displays a confirmation message to verify that the query was cancelled.

    To cancel a currently running query, first retrieve the process ID for the query that you want to cancel. To determine the process IDs for all currently running queries, type the following command:

    select pid, starttime, duration,
    trim(user_name) as user,
    trim (query) as querytxt
    from stv_recents
    where status = 'Running';
    

    See also:

    Login or Signup to reply.
  2. Since STV_RECENTS is not available in serverless endpoint, you can get all the running queries with

    SELECT * FROM SYS_QUERY_HISTORY WHERE status = 'running'
    

    , the session_id is the PID

    Then you can cancel them with

    CANCEL <session_id>
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search