When multiple workloads share an AnalyticDB for MySQL cluster, you can direct each query to a specific resource group to isolate compute resources. This page describes the available methods and their priority order for each cluster edition and query submission path.
How it works
Each cluster has two default resource groups:
`user_default` (Interactive resource group) — receives XIHE queries when no other resource group is specified
`serverless` (Job resource group) — receives Spark application queries when no other resource group is specified; requires v3.2.2.8 or later
To isolate resources for different workloads, create additional resource groups and assign them at query time using one of the methods below.
Methods
Enterprise Edition, Basic Edition, or Data Lakehouse Edition
XIHE SQL
XIHE SQL submitted via Java Database Connectivity (JDBC) supports three ways to specify a resource group, applied in the following priority order (highest to lowest):
Hint — append
/*+resource_group=resourceGroupName*/to the query statement.Attached resource group — attach a resource group to a database account; the account's attached resource group applies to all queries from that account.
Default — if neither of the above is specified, the query runs in
user_default.
Spark SQL and Spark applications
The method for specifying a resource group depends on how you submit the job:
| Submission method | How to specify a resource group |
|---|---|
| Job developer page in the console | Select a resource group in the console UI. Hints and account-level attached resource groups do not apply for this submission path. |
| spark-submit CLI | Specify the resource group in the spark-submit command. |
| Java SDK | Specify the resource group when submitting a Spark application via the Java SDK. |
| Python SDK | Specify the resource group when submitting a Spark application via the Python SDK. |
| Jupyter interactive job | Specify the resource group when setting up a Jupyter interactive job. |
| OpenAPI | Set the ResourceGroupName parameter in the SubmitSparkApp operation. |
Data Warehouse Edition
Data Warehouse Edition supports the same three methods as XIHE SQL, applied in the same priority order (highest to lowest):
Hint — append
/*+resource_group=resourceGroupName*/to the query statement.Attached resource group — attach a resource group to a database account.
Default — if neither of the above is specified, the query runs in
user_default.