All Products
Search
Document Center

Database Autonomy Service:SQL throttling

Last Updated:Apr 18, 2025

Database Autonomy Service (DAS) provides the SQL throttling feature. You can use SQL throttling to control database request access and SQL concurrency to ensure service availability. This topic describes how to use the SQL throttling feature.

Prerequisites

The following database engines are supported:

  • RDS MySQL 5.6, 5.7, and 8.0.

  • RDS PostgreSQL 14 and later.

  • PolarDB MySQL 5.6, 5.7, and 8.0.

  • PolarDB-X 2.0.

Scenarios

Scenario

Description

Sudden increase in concurrency of a specific type of SQL statement

For example, cache penetration or abnormal calls may cause a sudden increase in SQL concurrency.

SQL statements with data skew

For example, frequent queries for certain hot spot data during promotions may cause the entire system to be busy.

No index table created

For example, many SQL calls without an index table may cause the entire system to be busy.

Throttling modes

Mode

Description

Supported databases

Keyword Throttling

Matches keywords in SQL statements for throttling.

Note

Throttling for a specific SQL statement is not supported.

  • RDS MySQL

  • PolarDB MySQL

  • PolarDB-X 2.0

SQL Template Throttling

Enter an SQL sample, which is then templated to obtain the corresponding SQL template for throttling this type of SQL statement.

  • RDS MySQL 8.0 with minor engine version 20230630 or later.

  • RDS PostgreSQL 14 or later with minor engine version 20230330 or later

  • PolarDB MySQL:

    • 8.0.1 with minor engine version 8.0.1.1.31 or later.

    • 8.0.2 with minor engine version 8.0.2.2.12 or later.

Matches SQL template IDs for throttling. SQL template IDs can be obtained from SQL logs, sessions, and EXPLAIN execution results.

Note

An SQL template ID is an 8-character hexadecimal string.

PolarDB-X 2.0 Enterprise Edition

Running Time Throttling

Throttles SQL statements based on their execution time. After you create a rule for this throttling mode, when the execution time of a specified type of SQL statement exceeds the threshold, the template ID of this type of SQL statement is automatically added to the throttling rule, and the SQL statement is executed according to the concurrency specified in the rule.

Note

You can also set a maximum number of throttled SQL template IDs. When this limit is reached, no more throttling rules are automatically created for other SQL statements.

PolarDB-X 2.0 Enterprise Edition

Procedure

  1. Log on to the DAS console.

  2. In the left-side navigation pane, choose Intelligent O&M Center > Instance Monitoring.

  3. On the page that appears, find the database instance that you want to manage and click the instance ID. The instance details page appears.

  4. In the left-side navigation pane, click Instance Sessions.

  5. On the Session Management page, click SQL Throttling.

  6. In the dialog box that appears, click Create Throttling Rule.

  7. In the Create Throttling Rule dialog box, configure the following parameters based on the database engine.

  8. RDS MySQL

    Parameter

    Description

    Throttling Mode

    Select a throttling mode as needed.

    SQL Type

    Select an SQL type. Valid values: SELECT, UPDATE, DELETE, and INSERT.

    Note
    • This parameter is required when Throttling Mode is set to Keyword Throttling.

    • Only the following database engines support throttling the INSERT type:

      • RDS MySQL 8.0

      • PolarDB MySQL 5.7 and 8.0

      • PolarDB-X 2.0

    • Throttling for INSERT...SELECT... SQL statements is not supported.

    Database

    The database for SQL throttling.

    Note

    This parameter is required when Throttling Mode is set to SQL Template Throttling.

    Maximum Concurrency

    The maximum concurrency of SQL statements. The minimum value is 0.

    Note

    When SQL statements that meet the throttling policy are executed simultaneously and reach the maximum concurrency, SQL throttling is triggered.

    Throttling Duration

    The effective time of SQL throttling.

    Important

    SQL throttling is an emergency measure. We recommend that you set the throttling duration based on your actual needs and disable it promptly after use.

    SQL Keywords

    The SQL keywords to be throttled.

    Note
    • This parameter is required when Throttling Mode is set to Keyword throttling.

    • If you set multiple keywords, the SQL statement must contain all of these keywords to trigger the throttling rule. Multiple keywords are separated by tildes (~) and have no order restriction.

      For example, if the original statement is: SELECT min(id), max(id) FROM task_event WHERE gmt_modified < '2020-06-21' AND begin_time > '2020-07-09' AND source IN (527) AND id >= 15673 AND id <= 8015673 .

      The corresponding throttling keywords are: SELECT~min~id~max~id~FROM~task_event~WHERE~gmt_modified~AND~begin_time~AND~source~IN~AND~id~AND~id.

    • Setting only SELECT, INSERT, UPDATE, DELETE as throttling keywords is not supported, and keywords are case-sensitive (some earlier instance versions are not case-sensitive).

    SQL Sample

    The sample SQL statement to be throttled.

    Note
    • This parameter is required when Throttling Mode is set to SQL template throttling.

    • For complex SQL statements, DAS will template the SQL sample while ensuring the SQL template remains unchanged. The transformation will not affect the throttling effect.

      For example, if the input is: select name from das where name = `das` and age = 21 limit 20.

      It is templated as: select name from das where name = ? and age = ? limit ?.

      It is rewritten as: select name from das where name = `param0` and age = `param1` limit 20.

    RDS PostgreSQL

    Parameter

    Description

    Throttling Mode

    RDS PostgreSQL only supports SQL template throttling.

    Database

    The database for SQL throttling.

    Search Path

    The search path for SQL throttling.

    Note

    Multiple paths are separated by commas ,. The default is information_schema,public.

    Maximum Concurrency

    The maximum concurrency of SQL statements. The minimum value is 0.

    Note

    When SQL statements that meet the throttling policy are executed simultaneously and reach the maximum concurrency, SQL throttling is triggered.

    Maximum Waiting Count

    The maximum number of waiting SQL statements.

    Throttling Duration

    The effective time of SQL throttling.

    Important

    SQL throttling is an emergency measure. We recommend that you set the throttling duration based on your actual needs and disable it promptly after use.

    SQL Sample

    The sample SQL statement to be throttled.

    Note
    • This parameter is required when Throttling Mode is set to SQL Template Throttling.

    • For complex SQL statements, DAS will template the SQL sample while ensuring the SQL template remains unchanged. The transformation will not affect the throttling effect.

      For example, if the input is: select name from das where name = "das" and age = 21 limit 20.

      It is templated as: select name from das where name = ? and age = ? limit ?.

      It is rewritten as: select name from das where name = "param0" and age = "param1" limit 20.

    PolarDB MySQL

    Parameter

    Description

    Throttling Mode

    Select a throttling mode as needed.

    SQL Type

    Select an SQL type. Valid values: SELECT, UPDATE, DELETE, INSERT.

    Note
    • Currently, only the following database engines support throttling the INSERT type:

      • RDS MySQL 8.0

      • PolarDB MySQL 5.7 and 8.0

      • PolarDB-X 2.0

    • Throttling for INSERT...SELECT... SQL statements is not supported.

    Maximum Concurrency

    The maximum concurrency of SQL statements. The minimum value is 0.

    Note

    When SQL statements that meet the throttling policy are executed simultaneously and reach the maximum concurrency, SQL throttling is triggered.

    Database

    The database for SQL throttling.

    Note

    This parameter is required when Throttling Mode is set to SQL Template Throttling.

    Throttling Duration

    The effective time of SQL throttling.

    Important

    SQL throttling is an emergency measure. We recommend that you set the throttling duration based on your actual needs and disable it promptly after use.

    SQL Keywords

    The SQL keywords to be throttled.

    Note
    • This parameter is required when Throttling Mode is set to Keyword Throttling.

    • If you set multiple keywords, the SQL statement must contain all of these keywords to trigger the throttling rule. Multiple keywords are separated by tildes (~) and have no order restriction.

      For example, if the original statement is: SELECT min(id), max(id) FROM task_event WHERE gmt_modified < '2020-06-21' AND begin_time > '2020-07-09' AND source IN (527) AND id >= 15673 AND id <= 8015673 .

      The corresponding throttling keywords are: SELECT~min~id~max~id~FROM~task_event~WHERE~gmt_modified~AND~begin_time~AND~source~IN~AND~id~AND~id.

    • Setting only SELECT, INSERT, UPDATE, DELETE as throttling keywords is not supported, and keywords are case-sensitive (some earlier instance versions are not case-sensitive).

    SQL Sample

    The sample SQL statement to be throttled.

    Note
    • This parameter is required when Throttling Mode is set to SQL Template Throttling.

    • For complex SQL statements, DAS will template the SQL sample while ensuring the SQL template remains unchanged. The transformation will not affect the throttling effect.

      For example, if the input is: select name from das where name = "das" and age = 21 limit 20.

      It is templated as: select name from das where name = ? and age = ? limit ?.

      It is rewritten as: select name from das where name = "param0" and age = "param1" limit 20.

    PolarDB-X 2.0

    Parameter

    Description

    Throttling Mode

    Select a throttling mode as needed.

    SQL Type

    Select an SQL type. Valid values: SELECT, UPDATE, DELETE, INSERT.

    Note
    • Currently, only the following database engines support throttling the INSERT type:

      • RDS MySQL 8.0

      • PolarDB MySQL 5.7 and 8.0

      • PolarDB-X 2.0

    • Throttling for INSERT...SELECT... SQL statements is not supported.

    Maximum Concurrency

    The maximum concurrency of SQL statements. The minimum value is 0.

    Note

    When SQL statements that meet the throttling policy are executed simultaneously and reach the maximum concurrency, SQL throttling is triggered.

    Throttling Duration

    The effective time of SQL throttling.

    Important

    SQL throttling is an emergency measure. We recommend that you set the throttling duration based on your actual needs and disable it promptly after use.

    SQL Keywords

    The SQL keywords to be throttled.

    Note
    • This parameter is required when Throttling Mode is set to Keyword Throttling.

    • If you set multiple keywords, the SQL statement must contain all of these keywords to trigger the throttling rule. Multiple keywords are separated by tildes (~) and have no order restriction.

      For example, if the original statement is: SELECT min(id), max(id) FROM task_event WHERE gmt_modified < '2020-06-21' AND begin_time > '2020-07-09' AND source IN (527) AND id >= 15673 AND id <= 8015673 .

      The corresponding throttling keywords are: SELECT~min~id~max~id~FROM~task_event~WHERE~gmt_modified~AND~begin_time~AND~source~IN~AND~id~AND~id.

    • Setting only SELECT, INSERT, UPDATE, DELETE as throttling keywords is not supported, and keywords are case-sensitive (some earlier instance versions are not case-sensitive).

    SQL Template ID

    The SQL template IDs to be throttled. An SQL template ID is an 8-character hexadecimal string. Multiple SQL template IDs are separated by commas ,.

    Note

    This parameter is required when PolarDB-X is Enterprise Edition and Throttling Mode is set to SQL Template Throttling.

    Minimum SQL Execution Time

    The threshold for SQL execution time. When the execution time of an SQL statement exceeds this threshold, the system adds the SQL template ID of this type of SQL statement to the throttling rule.

    Note

    This parameter is required when PolarDB-X is Enterprise Edition and Throttling Mode is set to Running Time Throttling.

    Maximum Number Of Throttled SQL IDs

    The maximum number of SQL template IDs that can be throttled based on execution time. When this limit is reached, the system stops creating throttling rules for other SQL statements whose execution time exceeds the threshold.

    Note

    This parameter is required when PolarDB-X is Enterprise Edition and Throttling Mode is set to Running Time Throttling.

    Database Account Of Throttled SQL

    The database account to which the throttled SQL statements belong.

    Note

    This parameter is required when Throttling Mode is set to Keyword Throttling or SQL Template Throttling.

    Note

    After the target SQL throttling rule is created, if the application uses an SQL statement that contains all the keywords, the system performs the following operations:

    • RDS MySQL 5.6, RDS MySQL 5.7 instances and PolarDB MySQL 5.6 clusters will return error 1317 (query execution was interrupted).

    • RDS MySQL 8.0 instances, PolarDB MySQL 5.7 and PolarDB MySQL 8.0 clusters will put the relevant SQL statements in the Concurrency control waiting state until the number of waiting statements exceeds the value of the ccl_max_waiting_count parameter (if the instance version supports this parameter). Then, an error code and error description Concurrency control waiting count exceed max waiting count will be returned. The error codes are:

      • RDS MySQL 8.0: ERROR 7534 (HY000).

      • PolarDB MySQL 5.7: ERROR 3277 (HY000).

      • PolarDB MySQL 8.0: ERROR 7533 (HY000).

      If the ccl_max_waiting_count parameter is set to the default value 0, all throttled SQL statements will remain in the Concurrency control waiting state without returning an error. When throttling through DAS, if this parameter is 0, DAS will set it to the DAS default value (currently 10). If the user has set it to a value greater than 0, DAS will not change the parameter and will use the user's setting.

  9. Click Submit to complete the creation.

    After the SQL throttling rule is created, you can view the rule information on the Running tab. The parameters in the list are as follows:

    Note

    The parameters in the list may vary slightly depending on the database engine and throttling mode.

    Parameter

    Description

    Throttling Mode

    The mode you selected.

    Throttling Rule

    • Keyword Throttling: The throttling keyword configuration information.

    • SQL Template Throttling: The template ID information corresponding to the throttling sample.

    • Running Time Throttling: The execution time threshold/number of throttled template SQL statements configured.

    Maximum Concurrency

    The maximum concurrency of SQL statements.

    Maximum Waiting Count

    The maximum waiting count configured in the throttling rule.

    Note

    This parameter is displayed when the database instance is RDS PostgreSQL and Throttling Mode is set to SQL Template Throttling.

    Throttling Duration (Minutes)

    The effective time of SQL throttling.

    Start Time

    The time when the throttling rule was configured (effective time).

    Remaining Time

    The remaining time before the throttling rule expires.

    Throttling SQL Sample

    The throttling SQL sample configuration.

    Note

    This parameter is displayed when Throttling Mode is set to SQL Template Throttling.

    Throttling Template ID

    The template ID corresponding to the throttling SQL sample.

    Note

    This parameter is displayed when Throttling Mode is set to SQL Template Throttling.

    Status

    Rules that are running are in the enabled state.

    Database

    The database for SQL throttling.

    Note

    This parameter is displayed when Throttling Mode is set to SQL Template Throttling.

    Search Path

    The search path for the throttled SQL statements.

    Note

    This parameter is displayed when the database instance is RDS PostgreSQL and Throttling Mode is set to SQL Template Throttling.

    Matched SQL Count

    The number of SQL statements matched under the throttling rule configuration.

    Note

    This parameter is displayed when Throttling Mode is set to SQL Template Throttling.

    Waiting SQL Count

    The number of SQL statements currently waiting under the throttling rule configuration.

    Note

    This parameter is displayed when Throttling Mode is set to SQL Template Throttling.

    Operation

    The Disable or Modify buttons for the throttling rule.

References

Automatic SQL throttling

Related API operations

API

Description

EnableSqlConcurrencyControl

Enables SQL throttling.

DisableSqlConcurrencyControl

Disables a specified throttling rule.

DisableAllSqlConcurrencyControlRules

Disables all running throttling rules.

GetRunningSqlConcurrencyControlRules

Obtains running throttling rules.

GetSqlConcurrencyControlRulesHistory

Obtains throttling rules that are running or have been triggered.

GetSqlConcurrencyControlKeywordsFromSqlText

Generates throttling keywords based on an SQL statement.