<@U0A71G31CDV> how to users and their resource gro...
# questions-and-troubleshooting
z
@Rocky how to users and their resource groups?
r
In StarRocks, you associate users with resource groups primarily through Classifiers. A classifier defines conditions (like username or role) that automatically route a query to a specific resource group. 1. Assign a User when Creating a Resource Group You can specify the user(s) in the
TO
clause when creating the group:
Copy code
sql
CREATE RESOURCE GROUP rg1
TO 
    (user='alice'),               -- Matches user 'alice'
    (role='analyst')              -- Matches any user with the 'analyst' role
WITH (
    'cpu_weight' = '10',
    'mem_limit' = '20%'
);
2. Add or Remove Users from an Existing Group If the resource group already exists, use
ALTER RESOURCE GROUP
to manage its classifiers: * Add a user:
Copy code
sql
    ALTER RESOURCE GROUP rg1 ADD (user='bob');
* Remove a user: First, find the
classifier_id
using
SHOW RESOURCE GROUP rg1;
, then drop it:
Copy code
sql
    ALTER RESOURCE GROUP rg1 DROP (10001);
3. Manual Override (Session Level) A user can also manually switch to a specific resource group for their current session or a specific query: * Session level:
Copy code
sql
    SET resource_group = 'rg1';
* Query level (Hint):
Copy code
sql
    SELECT /_+ SET_VAR(resource_group = 'rg1') _/ * FROM table_name;
4. Verify Assignments To see which users and conditions are mapped to which resource groups, use:
Copy code
sql
-- View all resource groups and their classifiers (users/roles/IPs)
SHOW RESOURCE GROUPS ALL;

-- View the resource group used by a specific query
-- Check the 'ResourceGroup' column in the FE audit log or run:
EXPLAIN VERBOSE <your_query>;
How Matching Works If a user matches multiple resource groups, StarRocks uses a matching degree system: * An exact
user
match is generally high priority. * If multiple classifiers match (e.g., one by
user
and one by
role
), the one with the most specific conditions (the highest matching degree) is chosen. Referencesadministration/management/resource_management/resource_group.mdfaq/resource_isolation_faq.md
z
@Rocky NO I want to know which user belongs which resource group
r
To see which users are mapped to which resource groups, you can use the following commands: 1. View all mappings (All users and groups) Run this command to see a full list of resource groups and the "classifiers" (rules) that link them to users, roles, or databases:
Copy code
sql
SHOW RESOURCE GROUPS ALL;
How to read the output: Look at the
classifiers
column. It lists the conditions that route a user to that group. For example: *
(id=15016, weight=1.0, user=alice)
means user alice is mapped to this group. *
(id=15017, weight=1.0, role=analyst)
means anyone with the analyst role is mapped here. 2. View mappings for your current user To see which resource group you (the logged-in user) are currently hitting based on the existing rules:
Copy code
sql
SHOW RESOURCE GROUPS;
3. Check a specific group If you want to see who is assigned to a specific group (e.g.,
rg1
):
Copy code
sql
SHOW RESOURCE GROUP rg1;
Important Note on "Belonging" In StarRocks, a user doesn't strictly "belong" to one group. Instead, queries are matched to groups based on classifiers. * If a user matches multiple groups, the one with the highest weight (the most specific match) is used. * If no specific match is found, the user falls into the
default_wg
(default resource group). Referencesadministration/management/resource_management/resource_group.mdsql-reference/sql-statements/cluster-management/resource_group/SHOW_RESOURCE_GROUP.md Referencesadministration/management/resource_management/resource_group.mdsql-reference/sql-statements/cluster-management/resource_group/SHOW_RESOURCE_GROUP.mdfaq/resource_isolation_faq.md