Project: StarRocks (App Definition and Development / Database)
File: CREATE_RESOURCE_GROUP.md

displayed_sidebar: "English" Creates a resource group. For more information, see . :::tip This operation requires the SYSTEM-level CREATE RESOURCE GROUP privilege. You can follow the instructions in to grant this privilege. ::: ```SQL CREATE RESOURCE GROUP resourcegroupname TO CLASSIFIER1, CLASSIFIER2, ... WITH resource_limit ``` `resourcegroupname`: The name of the resource group to be created. `CLASSIFIER`: Classifiers used to filter the queries on which resource limits are imposed. You must specify a classifier using `"key"="value"` pairs. You can set multiple classifiers for a resource group. Parameters for classifiers are listed below: | Parameter | Required | Description | | - | | | | user | No | The name of user. | | role | No | The role of user. | | querytype | No | The type of query. `SELECT` and `INSERT` (from v2.5) are supported. When INSERT tasks hit a resource group with `querytype` as `insert`, the BE node reserves the specified CPU resources for the tasks. | | source_ip | No | The CIDR block from which the query is initiated. | | db | No | The database which the query accesses. It can be specified by strings separated by commas (,). | | plancpucost_range | No | The estimated CPU cost range of the query. The format is `(DOUBLE, DOUBLE]`. The default value is NULL, indicating no such restriction. This parameter is supported from v3.1.4 onwards. | | planmemcost_range | No | The estimated memory cost range of the query. The format is `(DOUBLE, DOUBLE]`. The default value is NULL, indicating no such restriction. This parameter is supported from v3.1.4 onwards. | `resource_limit`: Resource limits to be imposed on the resource group. You must specify resource limits using `"key"="value"` pairs. You can set multiple resource limits for a resource group. Parameters for resource limits are listed below: | Parameter | Required | Description | | -- | | | | cpucorelimit | No | The soft limit for the number of CPU cores that can be allocated to the resource group on the

In actual business scenarios, CPU cores that are allocated to the resource group proportionally scale based on the availability of CPU cores on the BE. Valid values: any non-zero positive integer. | | mem_limit | No | The percentage of memory that can be used for queries in the total memory that is provided by the BE. Unit: %. Valid values: (0, 1). | | concurrency_limit | No | The upper limit of concurrent queries in a resource group. It is used to avoid system overload caused by too many concurrent queries. | | maxcpucores | No | The CPU core limit for this resource group on a single BE node. It takes effect only when it is set to greater than `0`. Range: [0, `avgbecpucores`], where `avgbecpucores` represents the average number of CPU cores across all BE nodes. Default: 0. | | bigquerycpusecondlimit | No | The upper time limit of CPU occupation for a big query. Concurrent queries add up the time. The unit is second. | | bigqueryscanrowslimit | No | The upper limit of row counts that can be scanned by a big query. | | bigquerymem_limit | No | The upper limit of memory usage of a big query. The unit is byte. | | type | No | The type of resource group. Valid values: <br />`shortquery`: When queries from the `shortquery` resource group are running, the BE node reserves the CPU cores defined in `shortquery.cpucorelimit`. CPU cores for all `normal` resource groups are limited to "the total CPU cores - `shortquery.cpucorelimit`". <br />`normal`: When no query from the `shortquery` resource group is running, the CPU core limit above is not imposed on the `normal` resource groups. <br />Note that you can create only ONE `shortquery` resource group in a cluster. | Example 1: Creates the resource group `rg1` based on multiple classifiers. ```SQL CREATE RESOURCE GROUP rg1 TO (user='rg1user1', role='rg1role1', querytype in ('select'), sourceip='192.168.x.x/24'), (user='rg1user2', querytype in ('select'), source_ip='192.168.x.x/24'), (user='rg1user3', sourceip='192.168.x.x/24'), (user='rg1_user4'), (db='db1') WITH ('cpucorelimit' = '10', 'mem_limit' = '20%', 'type' = 'normal', 'bigquerycpusecondlimit' = '100', 'bigqueryscanrowslimit' = '100000', 'bigquerymem_limit' = '1073741824' ); ```