Help Center/ GaussDB/ API Reference/ APIs/ SQL Throttling/ Obtaining Recommended SQL Throttling Rules
Updated on 2026-09-24 GMT+08:00

Obtaining Recommended SQL Throttling Rules

Function

This API is used to obtain recommended SQL throttling rules based on real-time sessions. Before calling this API:

Debugging

You can debug this API in API Explorer.

Authorization Information

Each account has all the permissions required to call all APIs, but IAM users must be assigned the required permissions.

  • If you are using role/policy-based authorization, see Permissions and Supported Actions for details on the required permissions.
  • If you are using identity policy-based authorization, the permission listed below is required.

    Action

    Access Level

    Resource Type (*: required)

    Condition Key

    Alias

    Dependencies

    gaussdb:instance:listSqlLimitRecommendRules

    read

    instance

    -

    -

    -

URI

POST /v3/{project_id}/instances/{instance_id}/limit-task/recommend-rule

Table 1 Parameter description

Parameter

Mandatory

Type

Description

project_id

Yes

String

Definition

Project ID of a tenant in a region.

To obtain the value, see Obtaining a Project ID.

Constraints

N/A

Range

The value can contain 32 characters. Only letters and digits are allowed.

Default Value

N/A

instance_id

Yes

String

Definition

Instance ID, which uniquely identifies an instance. For details about how to obtain the instance ID, see Querying DB Instances.

Constraints

N/A

Range

The value can contain 36 characters. Only letters and digits are allowed.

Default Value

N/A

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

Definition

User token.

You can obtain the token by calling the IAM API used to obtain a user token.

After a response is returned, the value of X-Subject-Token in the response header is the token.

Constraints

N/A

Range

N/A

Default Value

N/A

X-Language

No

String

Definition

Language of the information returned by the API.

Constraints

N/A

Range

  • zh-cn: Chinese
  • en-us: English

Default Value

en-us

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

recommend_type

No

String

Definition

Type of recommended SQL throttling rules.

Constraints

N/A

Range

  • all
  • exec_count: number of execution times.
  • avg_exec_time: average execution duration.
  • max_exec_time: maximum execution duration.

Default Value

all

recommend_count

No

Integer

Definition

Number of recommended SQL throttling rules.

Constraints

N/A

Range

1–2,147,483,647

Default Value

5

use_ops_tunnel

No

Boolean

Definition

Emergency access channel. In high-load or full-thread-pool scenarios, the O&M commands delivered for SQL throttling tasks by the management plane through the common channel may fail or time out. In this case, the emergency access channel can be used to ensure that the O&M commands can be executed properly in special scenarios.

Constraints

N/A

Range

  • true: enabled.
  • false: disabled.

Default Value

false

Response Parameters

Table 4 Response body parameters

Parameter

Type

Description

total_count

Integer

Definition

Total number of throttling rules.

Range

N/A

recommend_rules

Array of objects

Definition

List of recommended rules. For details, see Table 5.

Table 5 RecommendRules

Parameter

Type

Description

recommend_type

String

Definition

Type of recommended SQL throttling rules.

Range

  • exec_count: number of execution times.
  • avg_exec_time: average execution duration.
  • max_exec_time: maximum execution duration.

sql_id

String

Definition

ID of a SQL throttling rule.

Range

N/A

sql_model

String

Definition

SQL template of a SQL throttling rule.

Range

N/A

sql_keyword

String

Definition

SQL keyword of a SQL throttling rule.

Range

N/A

sql_type

String

Definition

SQL type of a SQL throttling rule.

Range

  • SELECT: query
  • INSERT
  • DELETE
  • UPDATE
  • MERGE

database

String

Definition

Database that a SQL throttling rule belongs to.

Range

N/A

avg_exec_time

Double

Definition

Average execution time of a SQL throttling rule, in seconds.

Range

N/A

max_exec_time

Double

Definition

Maximum execution time of a SQL throttling rule, in seconds.

Range

N/A

exec_count

Integer

Definition

Number of times that a SQL throttling rule is executed.

Range

N/A

Example Request

https://gaussdb-opengauss.ap-southeast-1.myhuaweicloud.com/v3/0611f1bd8b00d5d32f17c017f15b599f/instances/3d39c18788b54a919bab633874c159dfin14/limit-task/recommend-rule
{
  "recommend_type": "all",   
   "recommend_count": 1,   
   "use_ops_tunnel": false
}

Example Response

{
    "recommend_rules": [
        {
            "recommend_type": "exec_count",
            "sql_id": "3811675404",
            "sql_model": "insert into t1 select generate_series($1,$2),md5(random()::text), md5(random()::text);",
            "sql_keyword": "t1,generate_series,md5,random,text",
            "sql_type": "INSERT",
            "database": "test",
            "avg_exec_time": 2232.495,
            "max_exec_time": 2232.495,
            "exec_count": 1
        },
        {
            "recommend_type": "avg_exec_time",
            "sql_id": "3811675404",
            "sql_model": "insert into t1 select generate_series($1,$2),md5(random()::text), md5(random()::text);",
            "sql_keyword": "t1,generate_series,md5,random,text",
            "sql_type": "INSERT",
            "database": "test",
            "avg_exec_time": 2232.495,
            "max_exec_time": 2232.495,
            "exec_count": 1
        },
        {
            "recommend_type": "max_exec_time",
            "sql_id": "3811675404",
            "sql_model": "insert into t1 select generate_series($1,$2),md5(random()::text), md5(random()::text);",
            "sql_keyword": "t1,generate_series,md5,random,text",
            "sql_type": "INSERT",
            "database": "test",
            "avg_exec_time": 2232.495,
            "max_exec_time": 2232.495,
            "exec_count": 1
        }
    ],
    "total_count": 3
}

Status Codes

Error Codes

For details, see Error Codes.