Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import FunctionDescription from '@site/src/components/FunctionDescription';

<FunctionDescription description="Introduced or updated: v1.2.743"/>

Creates a workload group with specified quota settings.
Creates a workload group with specified quota settings. Workload groups control resource allocation and query concurrency by binding to users. When a user submits queries, the workload group limits are applied based on the user's assigned group.

## Syntax

Expand All @@ -26,7 +26,64 @@ CREATE WORKLOAD GROUP [IF NOT EXISTS] <group_name>

## Examples

### Basic Example

```sql
CREATE WORKLOAD GROUP analytics WITH cpu_quota = '20%', query_timeout = '10m';
-- Create workload groups
CREATE WORKLOAD GROUP IF NOT EXISTS interactive_queries
WITH cpu_quota = '30%', memory_quota = '20%', max_concurrency = 2;

CREATE WORKLOAD GROUP IF NOT EXISTS batch_processing
WITH cpu_quota = '70%', memory_quota = '80%', max_concurrency = 10;
```

### User Assignment

Users must be assigned to workload groups to enable resource limiting. When users execute queries, the system applies the workload group's restrictions automatically.

```sql
-- Create and assign user
CREATE USER analytics_user IDENTIFIED BY 'password123';
ALTER USER analytics_user WITH SET WORKLOAD GROUP = 'interactive_queries';

-- Reassign to different workload group
ALTER USER analytics_user WITH SET WORKLOAD GROUP = 'batch_processing';

-- Remove from workload group (user will use default unlimited resources)
ALTER USER analytics_user WITH UNSET WORKLOAD GROUP;

-- Check user's workload group
DESC USER analytics_user;
```

## Resource Quota Normalization

### Quota Limits
- Each workload group's `cpu_quota` and `memory_quota` can be set up to `100%` (1.0)
- The total sum of all quotas across workload groups can exceed 100%
- Actual resource allocation is **normalized** based on relative proportions

### How Quota Normalization Works

Resources are allocated proportionally based on each group's quota relative to the total:

```
Actual Allocation = (Group Quota) / (Sum of All Group Quotas) × 100%
```

**Example 1: Total quotas = 100%**
- Group A: 30% quota → Gets 30% of resources (30/100)
- Group B: 70% quota → Gets 70% of resources (70/100)

**Example 2: Total quotas > 100%**
- Group A: 60% quota → Gets 40% of resources (60/150)
- Group B: 90% quota → Gets 60% of resources (90/150)
- Total quotas: 150%

**Example 3: Total quotas < 100%**
- Group A: 20% quota → Gets 67% of resources (20/30)
- Group B: 10% quota → Gets 33% of resources (10/30)
- Total quotas: 30%

**Special Case:** When only one workload group exists, it gets 100% of warehouse resources regardless of its configured quota.

Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ DROP WORKLOAD GROUP [IF EXISTS] <workload_group_name>
This example removes the `test_workload_group` workload group:

```sql
DROP WORKLOAD GROUP test_warehouse;
DROP WORKLOAD GROUP test_workload_group;
```
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,40 @@
title: Workload Group
---

This page provides a comprehensive overview of Workload Group operations in Databend, organized by functionality for easy reference.
Workload groups enable resource management and query concurrency control in Databend by allocating CPU, memory quotas and limiting concurrent queries for different user groups.

## Workload Group Management
## How It Works

1. **Create workload groups** with specific resource quotas (CPU, memory, concurrency limits)
2. **Assign users** to workload groups using `ALTER USER`
3. **Query execution** automatically applies the workload group's resource limits based on the user

## Quick Example

```sql
-- Create workload group
CREATE WORKLOAD GROUP analytics WITH cpu_quota = '50%', memory_quota = '30%', max_concurrency = 5;

-- Assign user to workload group
CREATE USER analyst IDENTIFIED BY 'password';
ALTER USER analyst WITH SET WORKLOAD GROUP = 'analytics';
```

## Command Reference

### Management
| Command | Description |
|---------|-------------|
| [CREATE WORKLOAD GROUP](create-workload-group.md) | Creates a new workload group for resource management |
| [ALTER WORKLOAD GROUP](alter-workload-group.md) | Modifies an existing workload group configuration |
| [CREATE WORKLOAD GROUP](create-workload-group.md) | Creates a new workload group with resource quotas |
| [ALTER WORKLOAD GROUP](alter-workload-group.md) | Modifies workload group configuration |
| [DROP WORKLOAD GROUP](drop-workload-group.md) | Removes a workload group |
| [RENAME WORKLOAD GROUP](rename-workload-group.md) | Changes the name of a workload group |

## Workload Group Information
| [RENAME WORKLOAD GROUP](rename-workload-group.md) | Renames a workload group |

### Information
| Command | Description |
|---------|-------------|
| [SHOW WORKLOAD GROUPS](show-workload-groups.md) | Lists all workload groups and their configurations |
| [SHOW WORKLOAD GROUPS](show-workload-groups.md) | Lists all workload groups and their settings |

:::note
Workload groups in Databend allow you to manage and prioritize resource allocation for different types of queries and users, helping optimize performance and resource utilization.
:::tip
Resource quotas are normalized across all workload groups in a warehouse. For example, if two groups have 60% and 40% CPU quotas, they get 60% and 40% of actual resources respectively.
:::
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ RENAME WORKLOAD GROUP <current_name> TO <new_name>
This example renames `test_workload_group_1` to `test_workload_group`:

```sql
RENAME WAREHOUSE test_workload_group_1 TO test_workload_group;
RENAME WORKLOAD GROUP test_workload_group_1 TO test_workload_group;
```

Loading