# Workload scheduling (/docs/concepts/workload-scheduling)



Workload scheduling [#workload-scheduling]

Workloads and resources are RawTree database objects inherited from ClickHouse.
SQL statements such as `CREATE WORKLOAD` and `CREATE RESOURCE` define them.
RawTree schedules work according to those definitions. RawTree Cloud and
RawTree BYOC expose supported statements through the Query API.

Workloads form a tree. A parent can hold a broad budget while child workloads
separate interactive queries from batch work. Resources name the thread or
disk pools that a workload may schedule. Use the
[`workload`](/docs/reference/sql/settings/session#workload) setting in a
`SETTINGS` clause, or use a settings profile attached to the role.

A hierarchy, not a list [#a-hierarchy-not-a-list]

A typical tree has `all` at the root, `default` for queries without an explicit
choice, then `interactive` and `batch` below it. The tree gives the scheduler
context for sharing resources:

* `weight` controls a branch's relative share when siblings compete.
* Lower `priority` values have higher priority under priority scheduling.
* `max_concurrent_threads` caps the threads a workload can use.

These controls shape scheduling; they do not grant database access. CPU limits
apply per server, not as one cluster-wide budget.

Selecting and enforcing a workload [#selecting-and-enforcing-a-workload]

Use the [`workload`](/docs/reference/sql/settings/session#workload) setting in
a query's `SETTINGS` clause when the caller can choose a workload.
A settings profile can set the default for a database role. Mark the setting
`CONST` when the role must not switch workloads. Use `READONLY` to make the
setting read-only for the role.

[`throw_on_unknown_workload`](/docs/reference/sql/settings/server#throw_on_unknown_workload)
makes an unknown workload name an error.
[`use_concurrency_control`](/docs/reference/sql/settings/session#use_concurrency_control)
enables concurrency control for a query. A profile can set this value and lock
it with `CONST`.

Storage and operators [#storage-and-operators]

RawTree Cloud manages the workload storage configuration. In RawTree BYOC,
that configuration belongs to the operators responsible for the deployment. When workload storage is local,
apply cluster DDL with `ON CLUSTER 'default'`. Keeper-backed storage stores
definitions in Keeper and rejects that clause. Check the target cluster before
you choose the form.

Next steps [#next-steps]

* [Isolate interactive and batch workloads](/docs/guides/operate/isolate-workloads)
* [Lock a role to a workload](/docs/guides/operate/settings-profiles)
* [Workload statements](/docs/reference/sql/statements/workload)
* [Storage and compute](/docs/concepts/storage-and-compute)
* [Queries and results](/docs/concepts/queries-and-results)
