Workload and resource statements
Define workload trees and scheduler resources through the Query API.
Workload and resource statements
This page describes statements accepted by the Query API in RawTree Cloud and RawTree BYOC. Its restrictions apply to the API, not to all RawTree SQL. See ClickHouse compatibility and API scope.
Syntax
CREATE [IF NOT EXISTS | OR REPLACE] WORKLOAD <name>
[ON CLUSTER 'default'] [IN <parent>]
[SETTINGS <name> = <value> [FOR <resource>]]
CREATE [IF NOT EXISTS | OR REPLACE] RESOURCE <name> (<operations>)
[ON CLUSTER 'default']
DROP [IF EXISTS] WORKLOAD|RESOURCE <name> [ON CLUSTER 'default']Workloads optionally use IN <parent> and numeric SETTINGS such as
weight, priority, and max_concurrent_threads. Add FOR <resource> to
apply a setting to a resource. Resources contain comma-separated
MASTER THREAD, WORKER THREAD, READ DISK <name>, WRITE DISK <name>,
READ ANY DISK, or WRITE ANY DISK entries.
Clauses
| Clause | Meaning |
|---|---|
IN | Place a workload under a parent. |
SETTINGS | Set numeric scheduling values, optionally with FOR <resource>. |
| Resource entries | Name thread or disk resources. |
ON CLUSTER 'default' | Apply the object to the default cluster. |
Query API behavior
- Supported: Workload trees, numeric scheduling settings, and thread or disk resources.
- Not exposed by the Query API: Memory or query-slot resources, unknown settings, and
clusters other than
default. - Database storage behavior: Keeper-backed workload storage omits
ON CLUSTER; local storage uses the cluster clause to distribute DDL.
Errors
Error: Unsupported scheduling statement.
Hint:
Use CREATE [OR REPLACE] WORKLOAD/RESOURCE [IF NOT EXISTS], or DROP WORKLOAD/RESOURCE [IF EXISTS]. Only ON CLUSTER 'default' is supported. Submit one statement.Examples
Create a CPU resource.
CREATE RESOURCE analytics_cpu ON CLUSTER 'default' (MASTER THREAD, WORKER THREAD)Create a workload with a thread limit.
CREATE WORKLOAD analytics_workload ON CLUSTER 'default' IN all SETTINGS max_concurrent_threads = 2 FOR analytics_cpuDrop the workload before the resource.
DROP WORKLOAD IF EXISTS analytics_workload ON CLUSTER 'default'DROP RESOURCE IF EXISTS analytics_cpu ON CLUSTER 'default'The parser rejects memory resources.
CREATE RESOURCE memory_pool (READ ANY MEMORY)The parser rejects query-slot resources.
CREATE RESOURCE query_slots (QUERY SLOTS)The parser rejects other clusters.
CREATE WORKLOAD batch_workload ON CLUSTER 'other'