OceanBase logo

OceanBase

A unified distributed database ready for your transactional, analytical, and AI workloads.

Product Overview
DEPLOY YOUR WAY

OceanBase Cloud

The best way to deploy and scale OceanBase

OceanBase Enterprise

Run and manage OceanBase on your infra

TRY OPEN SOURCE

OceanBase Community Edition

The free, open-source distributed database

OceanBase seekdb

Open source AI native search database

Customer Stories

Real-world success stories from enterprises across diverse industries.

View All
BY USE CASES

Mission-Critical Transactions

Global & Multicloud Application

Elastic Scaling for Peak Traffic

Real-time Analytics

Active Geo-redundancy

Database Consolidation

Resources

Comprehensive knowledge hub for OceanBase.

Blog

Live Demos

Training & Certification

Documentation

Official technical guides, tutorials, API references, and manuals for all OceanBase products.

View All
PRODUCTS

OceanBase Cloud

OceanBase Database

Tools

Connectors and Middleware

QUICK START

OceanBase Cloud

OceanBase Database

BEST PRACTICES

Practical guides for utilizing OceanBase more effectively and conveniently

Company

Learn more about OceanBase – our company, partnerships, and trust and security initiatives.

About OceanBase

Partner

Trust Center

Contact Us

International - English
中国站 - 简体中文
日本 - 日本語
Sign In
Start on Cloud

OceanBase

A unified distributed database ready for your transactional, analytical, and AI workloads.

Product Overview
DEPLOY YOUR WAY

OceanBase Cloud

The best way to deploy and scale OceanBase

OceanBase Enterprise

Run and manage OceanBase on your infra

TRY OPEN SOURCE

OceanBase Community Edition

The free, open-source distributed database

OceanBase seekdb

Open source AI native search database

Customer Stories

Real-world success stories from enterprises across diverse industries.

View All
BY USE CASES

Mission-Critical Transactions

Global & Multicloud Application

Elastic Scaling for Peak Traffic

Real-time Analytics

Active Geo-redundancy

Database Consolidation

Comprehensive knowledge hub for OceanBase.

Blog

Live Demos

Training & Certification

Documentation

Official technical guides, tutorials, API references, and manuals for all OceanBase products.

View All
PRODUCTS
OceanBase CloudOceanBase Database
ToolsConnectors and Middleware
QUICK START
OceanBase CloudOceanBase Database
BEST PRACTICES

Practical guides for utilizing OceanBase more effectively and conveniently

Learn more about OceanBase – our company, partnerships, and trust and security initiatives.

About OceanBase

Partner

Trust Center

Contact Us

Start on Cloud
编组
All Products
    • Databases
    • iconOceanBase Database
    • iconOceanBase Cloud
    • iconOceanBase Tugraph
    • iconInteractive Tutorials
    • iconOceanBase Best Practices
    • Tools
    • iconOceanBase Cloud Platform
    • iconOceanBase Migration Service
    • iconOceanBase Developer Center
    • iconOceanBase Migration Assessment
    • iconOceanBase Admin Tool
    • iconOceanBase Loader and Dumper
    • iconOceanBase Deployer
    • iconKubernetes operator for OceanBase
    • iconOceanBase Diagnostic Tool
    • iconOceanBase Binlog Service
    • Connectors and Middleware
    • iconOceanBase Database Proxy
    • iconEmbedded SQL in C for OceanBase
    • iconOceanBase Call Interface
    • iconOceanBase Connector/C
    • iconOceanBase Connector/J
    • iconOceanBase Connector/ODBC
    • iconOceanBase Connector/NET
icon

OceanBase Database

SQL - V4.3.0

    Download PDF

    OceanBase logo

    The Unified Distributed Database for the AI Era.

    Follow Us
    Products
    OceanBase CloudOceanBase EnterpriseOceanBase Community EditionOceanBase seekdb
    Resources
    DocsBlogLive DemosTraining & CertificationTicket
    Company
    About OceanBaseTrust CenterLegalPartnerContact Us
    Follow Us

    © OceanBase 2026. All rights reserved

    Cloud Service AgreementPrivacy PolicySecurity
    Contact Us
    Document Feedback
    1. Documentation Center
    2. OceanBase Database
    3. SQL
    4. V4.3.0
    iconOceanBase Database
    SQL - V 4.3.0
    SQL
    KV
    • V 4.6.0
    • V 4.4.2
    • V 4.3.5
    • V 4.3.3
    • V 4.3.1
    • V 4.3.0
    • V 4.2.5
    • V 4.2.2
    • V 4.2.1
    • V 4.2.0
    • V 4.1.0
    • V 4.0.0
    • V 3.1.4 and earlier

    Configure SQL statement-level resource isolation

    Last Updated:2026-04-15 08:30:00  Updated
    share
    What is on this page
    Prerequisites
    Procedure
    Considerations
    Impact on performance
    References

    folded

    share

    You can bind the SQL statements that meet a specified condition to a specified resource group to implement SQL statement-level resource isolation. This topic describes how to configure SQL statement-level resource isolation in MySQL mode.

    Prerequisites

    • Before you configure SQL statement-level resource isolation, we recommend that you learn about basic concepts such as resource group, resource management plan, and resource management plan config. For more information, see Overview.

    • If you need to implement isolation of CPU resources, make sure that the control group (cgroup) directory is configured and the cgroup feature is enabled. This is because the isolation of CPU resources depends on cgroups. For more information, see Configure cgroups.

      If you need to implement only isolation of input/output operations per second (IOPS) resources, you do not need to configure cgroups.

    • Before you perform IOPS resource isolation, you must calibrate the disk performance. For more information about how to perform disk performance calibration, see Calibrate the disk performance.

      If you need to only perform CPU resource isolation, you do not need to calibrate the disk performance.

    • The user, database, table, and column for which resource isolation is to be implemented have been created.

    Procedure

    The following example shows how to bind different SQL conditions to the interactive_group and batch_group resource groups, and control the CPU and IOPS resources available for different SQL statements by using the daytime resource management plan.

    1. Log on to a MySQL tenant of the cluster as the administrator of the tenant.

    2. Call the CREATE_CONSUMER_GROUP subprogram in the DBMS_RESOURCE_MANAGER package to create two resource groups.

      obclient [test]> CALL DBMS_RESOURCE_MANAGER.CREATE_CONSUMER_GROUP(
      CONSUMER_GROUP => 'interactive_group' ,
      COMMENT => 'TP'
      );
      
      obclient [test]> CALL DBMS_RESOURCE_MANAGER.CREATE_CONSUMER_GROUP(
      CONSUMER_GROUP => 'batch_group' ,
      COMMENT => 'AP'
      );
      

      The parameters are described as follows:

      • CONSUMER_GROUP: the name of the resource group.

      • COMMENT: the comments on the resource group.

      You can query the oceanbase.DBA_RSRC_CONSUMER_GROUPS view to verify whether the resource groups are created. For more information about the oceanbase.DBA_RSRC_CONSUMER_GROUPS view, see oceanbase.DBA_RSRC_CONSUMER_GROUPS.

    3. Call the CREATE_PLAN subprogram in the DBMS_RESOURCE_MANAGER package to create a resource management plan.

      obclient [test]> CALL DBMS_RESOURCE_MANAGER.CREATE_PLAN(
      PLAN => 'daytime',
      COMMENT => 'TP preferred');
      

      The parameters are described as follows:

      • PLAN: the name of the resource management plan.

      • COMMENT: the comments on the resource management plan.

      You can query the oceanbase.DBA_RSRC_PLANS view to verify whether the resource management plan is created. For more information about the oceanbase.DBA_RSRC_PLANS view, see oceanbase.DBA_RSRC_PLANS.

    4. Call the CREATE_PLAN_DIRECTIVE subprogram in the DBMS_RESOURCE_MANAGER package to create a resource management plan config. to limit the CPU and IOPS resources available for the resource group when the resource management plan is enabled.

      obclient [test]> CALL DBMS_RESOURCE_MANAGER.CREATE_PLAN_DIRECTIVE(
      PLAN => 'daytime',
      GROUP_OR_SUBPLAN => 'interactive_group' ,
      COMMENT  => '',
      MGMT_P1 => 30,
      UTILIZATION_LIMIT =>80,
      MIN_IOPS => 30,
      MAX_IOPS => 90,
      WEIGHT_IOPS => 80);
      
      obclient [test]> CALL DBMS_RESOURCE_MANAGER.CREATE_PLAN_DIRECTIVE(
      PLAN => 'daytime',
      GROUP_OR_SUBPLAN => 'batch_group' ,
      COMMENT  => '',
      MGMT_P1 => 50,
      UTILIZATION_LIMIT => 40,
      MIN_IOPS => 40,
      MAX_IOPS => 80,
      WEIGHT_IOPS => 70);
      

      The parameters are described as follows:

      • PLAN: the name of the resource management plan.

      • GROUP_OR_SUBPLAN: the resource group.

      • COMMENT: the comments on the resource management plan config. Default value: NULL.

      • MGMT_P1: the percentage of CPU resources available for the resource group when the system runs at full load. Default value: 100.

      • UTILIZATION_LIMIT: the upper limit on the CPU resources available for the resource group. The default value is 100. The value range is [0, 100]. The value 100 indicates that all CPU resources of the tenant are available for the resource group. The value 70 indicates that at most 70% of the CPU resources of the tenant are available for the resource group.

      • MIN_IOPS: the IOPS resources reserved for the resource group in the case of I/O resource contention. The sum of MIN_IOPS values of all resource groups cannot exceed 100. Default value: 0.

      • MAX_IOPS: the maximum IOPS resources available for the resource group. The sum of MAX_IOPS values of all resource groups can exceed 100. Default value: 100.

      • WEIGHT_IOPS: the weight for IOPS resources. The sum of WEIGHT_IOPS values of all resource groups can exceed 100. Default value: 0.

      You can query the oceanbase.DBA_RSRC_PLAN_DIRECTIVES or oceanbase.DBA_OB_RSRC_IO_DIRECTIVES view to verify whether the resource management plan config is created.

      For more information about the oceanbase.DBA_RSRC_PLAN_DIRECTIVES view, see oceanbase.DBA_RSRC_PLAN_DIRECTIVES.

      For more information about the oceanbase.DBA_OB_RSRC_IO_DIRECTIVES view, see oceanbase.DBA_OB_RSRC_IO_DIRECTIVES.

    5. Call the SET_CONSUMER_GROUP_MAPPING subprogram in the DBMS_RESOURCE_MANAGER package to create a matching rule for resource isolation.

      obclient [test]> CALL DBMS_RESOURCE_MANAGER.SET_CONSUMER_GROUP_MAPPING(
      ATTRIBUTE => 'column',
      VALUE => 'test.t.c3=3 for tp_user',
      CONSUMER_GROUP => 'batch_group');
      
      obclient [test]> CALL DBMS_RESOURCE_MANAGER.SET_CONSUMER_GROUP_MAPPING(
      ATTRIBUTE => 'column',
      VALUE => 't.c3=5',
      CONSUMER_GROUP => 'interactive_group');
      

      The parameters are described as follows:

      • ATTRIBUTE: the attribute type. The value column indicates SQL statement-level resource isolation. The value user indicates user-level user-based resource isolation. The value function indicates user-level function-based resource isolation. The attribute name is case-insensitive.

      • VALUE: the attribute value, which includes the database name, table name, column name, constant value, and username.

        Take note of the following items:

        • The database name and username are optional. The default database name is the name of the current database. If no username is specified, the settings take effect for all users, including those created later in the current tenant.

        • The table name, column name, and constant value are required, and each of them can have only one value. The constant value must be a number or string.

        • When you specify the table name, column name, and username, the specified table, column, and user must exist.

      • CONSUMER_GROUP: the resource group to bind. When an SQL statement hits the matching rule specified by the VALUE parameter, this statement is bound to the specified resource group for execution. At present, an SQL statement can be bound to only one resource group.

      In this example, after the preceding matching rule for resource isolation is added, when the tp_user user executes an SQL statement with a WHERE clause that contains test.t.c3 = 3, this SQL statement will be bound to the resource group named batch_group for execution.

      Notice

      An SQL statement can be bound to the batch_group resource group provided that c3 is parsed into test.t.c3 but the statement does not necessarily need to contain test.t.. For example, the statement SELECT * FROM test.t WHERE c3 = 1; will be bound to the `batch_group` resource group.

      You can query the oceanbase.DBA_RSRC_GROUP_MAPPINGS view to verify whether the matching rule is created. For more information about oceanbase.DBA_RSRC_GROUP_MAPPINGS, see oceanbase.DBA_RSRC_GROUP_MAPPINGS.

    6. Enable a proper resource management plan for a resource group.

      The resources available for a resource group vary based on the resource management plan. Therefore, you must enable a proper resource management plan for a resource group.

      obclient [test]> SET GLOBAL resource_manager_plan = 'daytime';
      

      Note

      If resource usage does not need to be limited, you can execute the SET GLOBAL resource_manager_plan = ''; statement to disable all resource management plans.

    Considerations

    • After a matching rule for user-level resource isolation is added, if you delete the user and create the user again, this matching rule still applies.

    • A matching rule for resource isolation does not take effect immediately after being added, but is expected to take effect within 10 seconds. The time may vary based on the actual environment.

    • SQL statement-level resource isolation has a higher priority than user-level resource isolation.

    • After a matching rule for resource isolation is added, it takes effect only in the SELECT, INSERT, UPDATE, and DELETE statements, and does not take effect in data definition language (DDL), data control language (DCL), or procedural language (PL) statements. It can take effect in prepared statements.

    Impact on performance

    The impact of SQL statement-level resource isolation on performance is caused by retries. In user-level resource isolation, the resource group used for executing an SQL statement is determined before the SQL statement is parsed. However, in SQL statement-level resource isolation, the resource group used for executing an SQL statement is determined when the SQL statement is parsed or hits the plan cache. If the system detects that the resource group being used is not the determined resource group, the system will perform a retry to use the resources in the resource group determined based on the matching rule to execute this SQL statement.

    The impact of SQL statement-level resource isolation falls into three cases:

    1. If an SQL statement does not hit any matching rule, SQL statement-level resource isolation has no impact on the performance.

    2. If an SQL statement hits a matching rule that specifies to use the batch_group resource group, this SQL statement is executed by using resources in the batch_group resource group. The next SQL statement is also preferentially executed by using resources in this resource group. When the system detects that the matching rule hit by another SQL statement is bound to a different resource group, it will perform a retry to use resources in the new resource group to execute this statement. To continuously execute a batch of SQL statements that are bound to the same resource group, you can use this strategy so that the system needs to retry only the first SQL statement. This reduces the number of retries and causes slight impacts on the performance.

    3. If the expected resource group of each SQL statement is different from that of the previous statement, the system must retry for each SQL statement. This greatly affects the performance.

    References

    Configure user-level resource isolation

    Previous topic

    Configure user-level resource isolation
    Last

    Next topic

    Update a resource management plan config
    Next
    What is on this page
    Prerequisites
    Procedure
    Considerations
    Impact on performance
    References