---
title: Query Management
slug: SXjf-query-management
description: The Query Management page explains how to monitor, control, and optimize queries running in Ocient. 
docTags: 
createdAt: Tue Nov 25 2025 20:15:42 GMT+0000 (Coordinated Universal Time)
updatedAt: Wed Apr 22 2026 21:14:34 GMT+0000 (Coordinated Universal Time)
---

Query management statements let you monitor and control running queries in an Ocient® System. For information about system tables containing query data, see [Monitoring](<././System Catalog Reference/System Catalog.md>).

## CANCEL

Cancels a running query based on its specific query identifier.&#x20;

The system cancels query execution at the next available pause point, such as between batches of data processing. If the execution of the `CANCEL` SQL statement fails, you can force the query to terminate immediately by using the [KILL](<./Query Analysis.md>) SQL statement.&#x20;

To view active queries and their identifiers, see the [sys.queries](<././System Catalog Reference/System Catalog.md>) table.

A `CANCEL` statement can return these statuses.&#x20;

| **Status Message**    | **Description**                                                                                                                                                      |
| --------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `OK`                  | The system successfully terminated the query and restored the resources assigned to its execution.                                                                   |
| `ID_NOT_FOUND`        | The specified query identifier does not exist in the system. The missing identifier can indicate that the query finished execution before the system could abort it. |
| `NOT_AUTHORIZED`      | The user does not have `UPDATE` privilege for the system level to terminate queries.                                                                                 |
| `NO_CONNECTION`       | The system lost connection to the database while trying to terminate the query.                                                                                      |
| `NETWORK_COMMS_ERROR` | Cannot communicate across the distributed system to terminate the query.                                                                                             |
| `INTERNAL_ERROR`      | The system encountered an unexpected error.                                                                                                                          |

**Required Privileges**

Users must have system-level `UPDATE` privileges to cancel queries.

**Syntax**

```sql
CANCEL query_id
```

| **Parameter** | **Type** | **Description**                                                                                                         |
| ------------- | -------- | ----------------------------------------------------------------------------------------------------------------------- |
| `query_id`    | string   | The Universally Unique IDentifier (UUID) of the query to cancel. Must be a valid UUID string enclosed in single quotes. |

**Examples**

Cancel a specific query with the `9a9eb7e3-3440-4814-871f-7f0584ac2fd8` identifier.

```sql
CANCEL '9a9eb7e3-3440-4814-871f-7f0584ac2fd8';
```

## KILL

Kills a running query identified by its UUID. This SQL statement performs a forceful termination of the query, aborting execution regardless of its current stage.&#x20;

If you want to attempt a more gradual query termination that stops processing at the next pause point, use the [CANCEL](<./Query Analysis.md>) SQL statement.&#x20;

To view active queries and their identifiers, see the [sys.queries](<././System Catalog Reference/System Catalog.md>) table.

| **Status Message**    | **Description**                                                                                                                                                     |
| --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `OK`                  | The system successfully terminated the query and restored the resources assigned to its execution.                                                                  |
| `ID_NOT_FOUND`        | The provided query identifier does not exist in the system. The missing identifier can indicate that the query finished execution before the system could abort it. |
| `NOT_AUTHORIZED`      | The user does not have `UPDATE` privilege for the system level to terminate queries.                                                                                |
| `NO_CONNECTION`       | The system lost connection to the database while trying to terminate the query.                                                                                     |
| `NETWORK_COMMS_ERROR` | Cannot communicate across the distributed system to terminate the query.                                                                                            |
| `INTERNAL_ERROR`      | The system encountered an unexpected error.                                                                                                                         |

**Required Privileges**

Users must have system-level `UPDATE` privileges to kill queries.

**Syntax**

```sql
KILL query_id
```

**Arguments**

| **Parameter** | **Type** | **Description**                                                                       |
| ------------- | -------- | ------------------------------------------------------------------------------------- |
| `query_id`    | String   | The UUID of the query to kill. Must be a valid UUID string enclosed in single quotes. |

**Example**

Kill a specific query based on the UUID `9a9eb7e3-3440-4814-871f-7f0584ac2fd8`.&#x20;

```sql
KILL '9a9eb7e3-3440-4814-871f-7f0584ac2fd8';
```

## Related Links

[System Catalog](<././System Catalog Reference/System Catalog.md>)&#x20;

[General SQL Syntax](<./././Query Ocient/General SQL Syntax.md>)&#x20;

