> ## Documentation Index
> Fetch the complete documentation index at: /documents/llms.txt
> Use this file to discover all available pages before exploring further.

# Query Management

> Configure per-user query properties in the database: connection limits, query timeouts, and resource allocation using ALTER USER SET PROPERTIES.

## Number of user connections

`Property` is set for user granularity. To set the maximum number of connections between Client and FE, use the following command.

```sql theme={null}
ALTER USER '<username>' SET PROPERTIES ("key"="value", ...)
```

User properties include the resources assigned to the user. The properties set here are for the user, not `user_identity`. That is, if two users `jack'@'%` and `jack'@'192.%` are created by the `CREATE USER` statement, then the `ALTER USER SET PROPERTIES` statement can work on the user `jack`, not `jack'@'%` or `jack'@'192.%`.

Example 1:

```sql theme={null}
-- For the user `jack`, change the maximum number of connections to 1000
ALTER USER 'jack' SET PROPERTIES ("max_user_connections" = "1000");

-- Check the connection limit for the root user
SHOW PROPERTY FOR 'root'; 
```

## Query-related session variables

The session variables can be set by 'key' = 'value', which can limit the concurrency, memory and other query parameters in the current session. For example:

* pipeline\_dop

  The parallelism of a pipeline instance, which is used to adjust the query concurrency. The default value `0` indicates that the system automatically adjusts the parallelism. You can also set it to a value greater than 0, generally half the number of physical CPU cores of the BE. Note that `parallel_fragment_exec_instance_num` takes effect only when the pipeline engine is disabled.

* query\_mem\_limit

  Memory limit of a query on each BE node, can be adjusted when a query reports insufficient memory.

* load\_mem\_limit

  Memory limit for import, can be adjusted when an import job reports insufficient memory.

Example 2:

```sql theme={null}
set pipeline_dop  = 8; 
set query_mem_limit  = 137438953472;
```

## capacity quota of database storage

The capacity quota of database storage is unlimited by default. And you can change quota value by using `alter database`.

```sql theme={null}
ALTER DATABASE db_name SET DATA QUOTA quota;
```

The quota units are: B/K/KB/M/MB/G/GB/T/TB/P/PB

Example 3:

```sql theme={null}
ALTER DATABASE example_db SET DATA QUOTA 10T;
```

## Kill queries

To terminate a query on a particular connection with the following  command:

```sql theme={null}
kill connection_id;
```

The `connection_id` can be seen by `show processlist;` or `select connection_id();`.

```plain text theme={null}
 show processlist;
+------+------------+---------------------+-----------------+---------------+---------+------+-------+------+
| Id   | User       | Host                | Cluster         | Db            | Command | Time | State | Info |
+------+------------+---------------------+-----------------+---------------+---------+------+-------+------+
|    1 | starrocksmgr | 172.26.34.147:56208 | default_cluster | starrocks_monitor | Sleep   |    8 |       |      |
|  129 | root       | 172.26.92.139:54818 | default_cluster |               | Query   |    0 |       |      |
|  114 | test       | 172.26.34.147:57974 | default_cluster | ssb_100g      | Query   |    3 |       |      |
|    3 | starrocksmgr | 172.26.34.147:57268 | default_cluster | starrocks_monitor | Sleep   |    8 |       |      |
|  100 | root       | 172.26.34.147:58472 | default_cluster | ssb_100       | Sleep   |  637 |       |      |
|  117 | starrocksmgr | 172.26.34.147:33790 | default_cluster | starrocks_monitor | Sleep   |    8 |       |      |
|    6 | starrocksmgr | 172.26.34.147:57632 | default_cluster | starrocks_monitor | Sleep   |    8 |       |      |
|  119 | starrocksmgr | 172.26.34.147:33804 | default_cluster | starrocks_monitor | Sleep   |    8 |       |      |
|  111 | root       | 172.26.92.139:55472 | default_cluster |               | Sleep   | 2758 |       |      |
+------+------------+---------------------+-----------------+---------------+---------+------+-------+------+
9 rows in set (0.00 sec)

mysql> select connection_id();
+-----------------+
| CONNECTION_ID() |
+-----------------+
|              98 |
+-----------------+


mysql> kill 114;
Query OK, 0 rows affected (0.02 sec)

```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.