Updated on 2026-10-26 GMT+08:00

Creating a SQL Throttling Rule

Scenarios

SQL throttling allows you to create rules to control concurrent execution of SQL statements by specifying SQL type, keywords, and maximum concurrency. To maintain better performance at high concurrency, SQL statements that meet the specified SQL type and keyword and exceed the maximum concurrency will not be executed.

High SQL concurrency can be caused by the following factors:

  • A sharp increase in requests: Concurrent SQL statements of a certain type surge due to cache penetration and abnormal calls.
  • Slow query accumulation: If a large number of SQL statements without indexes are called, many slow SQL statements will be generated, affecting workloads.

Version Constraints

SQL throttling is available to only the versions listed in Table 1. For details about how to query the instance version, see Query the RDS Instance Version.

For instances with kernel versions earlier than 5.6.51.4, 5.7.33.5, or 8.0.25.220700, SQL throttling rules apply to all user types. You are advised to include table names in keywords when configuring throttling rules. Configuring only the SELECT keyword may affect system functionality.

Table 1 Version constraints on SQL throttling by instance type

Major Version

Minor Version (Primary Instance)

Minor Version (Read Replica)

Setting Rules for Read Replicas Separately

Versions Supporting INSERT Throttling Rules

Versions That Support Setting Validity Periods for Throttling Rules

8.4

≥ 8.4.7.251200

≥ 8.4.7.251200

Not supported

≥ 8.4.7.251200

≥ 8.4.7.251200

8.0

≥ 8.0.25.1

≥ 8.0.25.1

Not supported

≥ 8.0.32.240100

≥ 8.0.28.230700

5.7

5.6

≥ 5.7.31.4

≥ 5.6.50.3

≥ 5.7.37.1

≥ 5.6.51.6

≥ 5.7.38.221000

Not supported

≥ 5.7.44.240100

Not supported

≥ 5.7.41.230700

≥ 5.6.51.230700

Table 2 lists the version constraints on built-in users and user root.

Table 2 Version constraints on users

Major Version

Minor Version

Built-in User

Root User

8.0

≥ 8.0.28.231000

Not affected by throttling rules

Subject to throttling rules

8.0.25.1 ≤ Version < 8.0.28.231000

Not affected by throttling rules

Not affected by throttling rules

< 8.0.25.1

Subject to throttling rules

Subject to throttling rules

5.7

≥ 5.7.43.231000

Not affected by throttling rules

Subject to throttling rules

5.7.33.1 ≤ Version < 5.7.43.231000

Not affected by throttling rules

Not affected by throttling rules

< 5.7.33.1

Subject to throttling rules

Subject to throttling rules

5.6

≥ 5.6.51.4

Not affected by throttling rules

Not affected by throttling rules

< 5.6.51.4

Subject to throttling rules

Subject to throttling rules

For instances running MySQL 5.7 (5.7.43.231000 or later), MySQL 8.0 (8.0.28.231000 or later), and MySQL 8.4, SQL throttling applies to the root user. If you want to exclude the root user from throttling, submit a service ticket.

To achieve better performance at high concurrency, you are advised to upgrade your DB instance to the latest minor version. For details about how to upgrade a minor version, see Upgrading the Minor Version.

Constraints

  • A maximum of 100 SQL throttling rules can be configured.
  • Only SELECT, UPDATE, DELETE, and INSERT statements are supported for SQL throttling.
  • If a SQL statement matches multiple SQL throttling rules, only the most recently added rule is applied.
  • SQL statements that have been executed before a SQL throttling rule is added are not counted.
  • If the replication delay is too long, adding or deleting a SQL throttling rule for a read replica does not take effect immediately.
  • SQL throttling rules are not applied to system tables.
  • SQL throttling rules are not applied to SQL statements not used for data query, such as select sleep(***);.
  • SQL throttling rules cannot be applied to event schedulers, stored procedures, triggers, or functions.
  • You can run the following SQL statement through DAS to view the execution of SQL throttling rules: select * from information_schema.rds_sql_filter_info;
  • Too many SQL throttling rules affect the database performance. Delete unnecessary rules after using them.
  • SQL throttling rules are not applied to system databases.

Checking Recommended Rules

Check recommended rules first. The system analyzes ongoing sessions based on your selected recommendation factor and lists recommended SQL throttling rules for top sessions. You can then add SQL throttling rules by referring to these recommended rules.

  1. Log in to the RDS console.
  2. Click in the upper left corner and select a region.
  3. On the Instances page, click the target instance name to go to the Summary page.
  4. In the navigation pane, choose SQL Analysis and Tuning under DBA Assistant.
  5. Click the SQL Throttling tab.
  6. Click Recommended Rule. In the displayed dialog box, set Query By to All, Avg. Duration, Max. Duration, or Executions. The system will retrieve top sessions, group them with the same keywords, and list recommended rules for top SQL statements.

    Figure 1 Recommended rules

    The system retrieves the top 1,000 sessions based on the recommendation factor and filters for SELECT statements only. It extracts keywords from each session and groups sessions with identical keywords. Recommendation rules are generated based on the following strategies:

    • All: Session groups are sorted in descending order by average execution duration (Avg. Duration), maximum execution duration (Max. Duration), and execution count (Executions). The system then generates recommended rules for the top N groups in each category.
    • Avg. Duration: Session groups are sorted in descending order by average execution duration. The system then generates recommended rules for the top N groups.
    • Max. Duration: Session groups are sorted in descending order by maximum execution duration. The system then generates recommended rules for the top N groups.
    • Executions: Session groups are sorted in descending order by execution count. The system then generates recommended rules for the top N groups.

Adding a SQL Throttling Rule

  1. Log in to the RDS console.
  2. Click in the upper left corner and select a region.
  3. On the Instances page, click the target instance name to go to the Summary page.
  4. In the navigation pane, choose SQL Analysis and Tuning under DBA Assistant.
  5. Click the SQL Throttling tab.
  6. Toggle on the SQL throttling switch . SQL throttling rules take effect only after SQL throttling is enabled.
  7. Click Add Rule. Configure the parameters listed in Table 3.

    Figure 2 Adding a rule (entering keywords)
    Figure 3 Adding a rule (generating keywords from a SQL statement)
    Table 3 Parameter description

    Parameter

    Description

    SQL Type

    There are four options: SELECT, UPDATE, DELETE, and INSERT.

    Keyword Generation

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

    • Manually: Take select~a as an example. select and a are two keywords contained in a SQL throttling 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. For details about matching rules, see Keyword Matching Rules.
    • Using SQL statements: You can enter a SQL statement and then click Generate Keyword. The generated keywords are for reference only. Exercise caution when using them.

    Empty characters before and after each keyword will be ignored, for example, spaces, '\n', '\r', and '\t'.

    For details about keyword validation rules, see Keyword Matching Rules.

    Max. Concurrent Requests

    If the number of concurrent SQL statements matching the keyword exceeds this limit, the SQL statements will not be executed. The value ranges from 0 to 1,000,000,000.

    Kill existing sessions that match this rule

    If this option is selected, all sessions generated by users subject to this SQL throttling rule will be killed.

    For details about the versions where user root is not subject to SQL throttling rules, see Version Constraints.

    Rule Validity Period

    Select Permanent or Limited.

    • Permanent: The rule is always valid.
    • Limited: There may be a delay of up to 1 minute before the rule expires. Once the limited SQL throttling rule expires, it will be automatically deleted.

  8. Confirm the settings and click OK.

Keyword Matching Rules

A throttling rule consists of a sequence of keywords separated by tildes (~). Throttling rules match keywords in plaintext order. Keywords are case-insensitive. When multiple keywords are configured, a SQL statement must contain all of the keywords in the exact configured order to match the throttling rule. Any content (or no content at all) is allowed between these keywords.

  • Example 1: matching with intervening content or exact order

    Throttling rule format:

    key_word1~key_word2~key_word3 

    This rule is matched only when key_word1, key_word2, and key_word3 are contained in a SQL statement in that exact order.

    • The rule can be matched if there is intervening content between the keywords:
      SELECT key_word1 xxx  FROM table_name WHERE key_word2 xxx key_word3; 
    • The rule can be matched if there is no intervening content between the keywords:
      SELECT key_word1key_word2key_word3 FROM table_name; 
    • The rule cannot be matched if the keywords appear in a different order:
      SELECT key_word1 xxx key_word3 xxx key_word2 FROM table_name; 
  • Example 2: plaintext matching

    Keyword matching is executed based on raw plaintext and is unaware of SQL keywords. For example, in the following throttling rule, keyword matching only checks whether SELECT and JOIN appear in sequence, regardless of whether it is INNER JOIN or LEFT JOIN.

    Throttling rule format:

    SELECT~JOIN 

    The rule can be matched if the keywords appear as follows:

    SELECT * FROM orders INNER JOIN users ON orders.user_id = users.id; 

    The rule can also be matched if the keywords appear as follows:

    SELECT * FROM orders LEFT JOIN users ON orders.user_id = users.id; 

Follow-up Operations

To delete a SQL throttling rule, locate it in the rule list and click Delete in the Operation column. In the displayed dialog box, click OK.

Figure 4 Deleting a rule