Updated on 2023-12-13 GMT+08:00

SQL Statement Concurrency Control

SQL statement concurrency control restricts the execution of SQL statements based on specified rules when there are SQL statements that cannot be optimized timely or a resource (for example, vCPU) bottleneck occurs.

Precautions

  • RDS for MariaDB using only the engine version 10.5.16.230600 or higher support Concurrency Control.
  • The new Concurrency Control rule takes effect only for the current DB instance.
  • If a SQL statement matches multiple concurrency control rules, only the latest rule takes effect.
  • SQL statements that have been executed before a concurrency control rule is added are not counted.
  • Keywords in a concurrency control rule are sorted in a specific order, and the system will match them from first to last. For example, if one rule contains the keyword a~and~b, the system only matches xxx a>1 and b>2.
  • If the replication delay is too long, adding or deleting a concurrency control rule for a read replica does not take effect immediately.
  • Empty characters before and after each keyword will be ignored, for example, spaces, \n, \r, and \t.
  • SQL statement concurrency control does not limit concurrency for:
    • System tables
    • SQL statements used to query data, for example, SELECT sleep(xxx)
    • Account root
    • SQL statements in stored procedures, triggers, and functions

Procedure

  1. Log in to the management console.
  2. Click in the upper left corner and select a region and project.
  3. Click in the upper left corner, and under Databases, click Data Admin Service.
  4. In the navigation pane, choose Intelligent O&M > Instance List.

    Alternatively, on the Overview page, click Go to Intelligent O&M.

  5. In the upper right corner of the Instance List page, search for instances by engine type, instance name, or instance IP.

    Figure 1 Searching for instances

  6. Locate the box containing your target instance and click Details.
  7. Choose SQL > SQL Statement Concurrency Control.
  8. On the displayed page, toggle on Concurrency Control.

    Figure 2 Enabling SQL statement concurrency control

  9. Click Add Concurrency Control Rule. In the displayed dialog box, select a SQL statement type, enter keywords, and specify the maximum number of concurrent SQL statements.

    Figure 3 Adding a concurrency control rule and entering keywords
    Table 1 Parameters

    Parameter

    Remarks

    SQL Type

    The options are SELECT, UPDATE, and DELETE.

    Keyword

    A maximum of 128 case-insensitive keywords are supported. You can specify keywords in either of the following ways:

    • Enter keywords. Take select~a as an example. select and a are two keywords contained in a concurrency control rule. The keywords are separated by a tilde (~). In this example, the rule restricts the execution of only the SQL statements containing keywords select and a.
    • Generate keywords from a SQL statement. You can enter an SQL statement to the text box and click Generate Keyword. Keywords generated from an original SQL statement are only for reference.

    Max. Concurrency

    SQL statements that meet the specified SQL type and keyword and exceed the value of Max. Concurrency will not be executed.

    Kill existing sessions that match this rule

    If this option is selected, the connection sessions of user root will not be killed.

  10. Confirm the settings and click OK.

    If a SQL statement concurrency control rule is no longer needed, click Delete in the Operation column.