All Products
Search
Document Center

AnalyticDB:Specify a resource group to execute a query

Last Updated:Mar 28, 2026

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):

  1. Hint — append /*+resource_group=resourceGroupName*/ to the query statement.

  2. Attached resource groupattach a resource group to a database account; the account's attached resource group applies to all queries from that account.

  3. 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 methodHow to specify a resource group
Job developer page in the consoleSelect a resource group in the console UI. Hints and account-level attached resource groups do not apply for this submission path.
spark-submit CLISpecify the resource group in the spark-submit command.
Java SDKSpecify the resource group when submitting a Spark application via the Java SDK.
Python SDKSpecify the resource group when submitting a Spark application via the Python SDK.
Jupyter interactive jobSpecify the resource group when setting up a Jupyter interactive job.
OpenAPISet 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):

  1. Hint — append /*+resource_group=resourceGroupName*/ to the query statement.

  2. Attached resource groupattach a resource group to a database account.

  3. Default — if neither of the above is specified, the query runs in user_default.