Introduction
If a warehouse query is running for too long in Kleene, you can find it directly in your data warehouse and cancel it there. This article explains how to identify and stop running queries in Snowflake and Redshift.
Why cancelling a running query is important
Cancelling an unnecessary or stuck query can help free up warehouse resources, reduce costs, and restore normal processing times for other workloads.
Find and cancel a running query in Snowflake
Use Snowflake query history to find the running query, then cancel it with the query ID.
Run the following query to find currently running queries:
SELECT * FROM TABLE(information_schema.query_history()) WHERE execution_status = 'RUNNING'Locate the query you want to stop and copy its query ID.
Cancel the query using the query ID:
SELECT SYSTEM$CANCEL_QUERY( '<query_id>' );
Find and cancel a running query in Redshift
Use Redshift system tables to identify the running query, then cancel it with the process ID.
Run the following query to find currently running queries:
SELECT * FROM stv_inflight;Locate the query you want to stop and copy its process ID, or pid.
Cancel the query using the pid:
CANCEL <insert pid here>
Summary
In Snowflake, use query history to find the running query and SYSTEM$CANCEL_QUERY to stop it. In Redshift, use stv_inflight to find the running query and CANCEL with the relevant pid.
Additional information
If you do not have permission to view query history or cancel queries, contact your warehouse administrator or Kleene support.