KILL QUERY statement
Kills a running SQL query. If the targeted query is not in running status then the kill statement will not be successful.
BNF diagrams
Syntax
KILL QUERY 'request_id';
Arguments
Argument | Description | Required? | Additional information |
---|---|---|---|
request_id | Request ID of the query to be killed. Value must be enclosed in single quote. | Yes | List running queries |
Additional information
List currently running queries
Query the fb_exec_requests
system table to obtain the request_id
:
SELECT request_id, status, start_time, sql
FROM fb_exec_requests
WHERE status='running';
Query status
The status column represents the execution status of the query, possible values are:
Status | Description |
---|---|
running | Query execution is in progress |
complete | Query execution completed |
cancelled | Query cancelled by user |
error | Query execution stopped after error |
timedout | Query execution stopped after exceeding execution time limit |
Responses to killed queries
- A killed query is set to
cancelled
in thefb_exec_requests
system table - An error is returned on any client application that submitted the query that is killed, for example:
Error: [0:0] request '571f25ac-1d8c-49b8-a53d-111408964632' killed by user
Examples
Kill a query to terminate unnecessary processing
Query the fb_exec_requests
system table to obtain a list of running queries:
select request_id, status, start_time, sql
from fb_exec_requests
where status='running';
Results:
request_id | status | start_time | sql |
---|---|---|---|
571f25ac-1d8c-49b8-a53d-111408964632 | running | 2023-05-12T16:13:39.342617-04:00 | select high_card_attribute, sum(measurement) from large_data_set where status=’active’ group by high_card_attribute |
11b511a7-efcf-44f3-8fdc-3eb864873b48 | running | 2023-05-12T16:20:08.560989-04:00 | select request_id, status, start_time, sql from fb_exec_requests where status=’running’ |
This statement kills the first query from above:
KILL QUERY '571f25ac-1d8c-49b8-a53d-111408964632';
Output:
result | status |
---|---|
Kill request submitted | pending |