Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive
On this page

Show all

SQL Statement Concurrency Control Function

Updated on 2024-05-07 GMT+08:00
  • gs_add_workload_rule(rule_type, rule_name, databases, start_time, end_time, max_workload, option_val)

    Description: Only users with the sysadmin permission can create an SQL statement concurrency control rule.

    Parameters: For details, see Table 1.

    Return type: int8

    Table 1 gs_add_workload_rule parameters

    Parameter

    Type

    Description

    Value Range

    rule_type

    text

    Type of the concurrency control rule, which is case insensitive.

    "sqlid": Concurrency control is based on the unique SQL ID.

    "select", "insert", "update", "delete", and "merge": Concurrency control is based on the query type and keyword.

    "resource": Instance-level concurrency control is based on the system resource usage.

    rule_name

    name

    Name of a concurrency control rule, which is used to search for the concurrency control rule.

    Any character string or NULL.

    databases

    name[]

    Array of database names for which the concurrency control rule takes effect. The value is case-sensitive.

    List of names of created databases. The value can be NULL, indicating that the configuration takes effect in all databases.

    Currently, the database list takes effect only when rule_type is set to a query type because a unique SQL ID is bound to a database and belongs to only one database. The concurrency control rules based on resource usage take effect for instances, that is, all databases.

    start_time

    timestamptz

    Start time of a concurrency control rule.

    The value can be NULL, indicating that it takes effect from now on.

    end_time

    timestamptz

    End time of a concurrency control rule.

    The value can be NULL, indicating that the rule is always effective.

    max_workload

    int8

    Maximum number of concurrent requests set in a concurrency control rule.

    -

    option_val

    text[]

    Supplementary information about the concurrency control rule.

    It matches rule_type. The matching relationship is as follows:

    • "sqlid": specifies the unique ID of the SQL statement whose concurrency is to be controlled and slow SQL control rule. The format is '{id=1234, time_limit=100, max_execute_time=500, max_iops=1}', in which id indicates the unique SQL ID and is mandatory. You can obtain it from the dbe_perf.statement or pg_stat_activity view. Others are optional. For details about their meanings, see section "Hint for Setting Slow SQL Control Rules."
    • "select", "insert", "update", "delete", and "merge": specifies the keyword sequence for concurrency control, which is case insensitive and can be NULL.
    • "resource": specifies the resource threshold for triggering instance-level concurrency control. The value is in the format of '{cpu-80, memory-70}', indicating the OS resource threshold for triggering instance-level concurrency control. The value can be NULL, indicating that concurrency control is performed regardless of the resource usage.

    Example:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    gaussdb=#  select gs_add_workload_rule('sqlid', 'rule for one query', '', now(), '', 20, '{id=32413214}');
     gs_add_workload_rule 
    ----------------------
                       1
    (1 row)
    gaussdb=#  create database db1;
    gaussdb=#  create database db2;
    gaussdb=#  select gs_add_workload_rule('select', 'rule for select', '{db1, db2}', '', '', 100, '{tb1, tb2}');
     gs_add_workload_rule 
    ----------------------
                       2
    (1 row)
    gaussdb=#  select gs_add_workload_rule('resource', 'rule for resource', '{}', '', '', 20, '{cpu-80}');
     gs_add_workload_rule 
    ----------------------
                       3
    (1 row)
    
  • gs_update_workload_rule(rule_id, rule_name, databases, start_time, end_time, max_workload, option_val)

    Description: To update an SQL statement concurrency control rule, users need to reset all parameters instead of only some parameters. Users must have the sysadmin permission.

    Parameters: For details, see Table 2.

    Return type: Boolean

    Table 2 gs_update_workload_rule parameters

    Parameter

    Type

    Description

    Value Range

    rule_id

    int8

    ID of the concurrency control rule to be updated.

    -

    rule_name

    name

    Name of a concurrency control rule, which is used to search for the concurrency control rule.

    Any character string or NULL.

    databases

    name[]

    Array of database names for which the concurrency control rule takes effect. The value is case-sensitive.

    List of names of created databases. The value can be NULL, indicating that the configuration takes effect in all databases.

    Currently, the database list takes effect only when rule_type is set to a query type because a unique SQL ID is bound to a database and belongs to only one database. The concurrency control rules based on resource usage take effect for instances, that is, all databases.

    start_time

    timestamptz

    Start time of a concurrency control rule.

    The value can be NULL, indicating that it takes effect from now on.

    end_time

    timestamptz

    End time of a concurrency control rule.

    The value can be NULL, indicating that the rule is always effective.

    max_workload

    int8

    Maximum number of concurrent requests set in a concurrency control rule.

    -

    option_val

    text[]

    Supplementary information about the concurrency control rule.

    It matches rule_type. The matching relationship is as follows:

    • "sqlid": specifies the unique ID of the SQL statement whose concurrency is to be controlled and slow SQL control rule. The format is '{id=1234, time_limit=100, max_execute_time=500, max_iops=1}', in which id indicates the unique SQL ID and is mandatory. You can obtain it from the dbe_perf.statement or pg_stat_activity view. Others are optional. For details about their meanings, see section "Hint for Setting Slow SQL Control Rules."
    • "select", "insert", "update", "delete", and "merge": specifies the keyword sequence for concurrency control, which is case insensitive and can be NULL.
    • "resource": specifies the resource threshold for triggering instance-level concurrency control. The value is in the format of '{cpu-80, memory-70}', indicating the OS resource threshold for triggering instance-level concurrency control. The value can be NULL, indicating that concurrency control is performed regardless of the resource usage.

    Example:

    1
    2
    3
    4
    5
    6
    gaussdb=#  create database db1;
    gaussdb=#  select gs_update_workload_rule(2, 'rule for select 2', '{db1}', now(), '', 50, '{tb1}');
     gs_update_workload_rule 
    -------------------------
     t
    (1 row)
    
  • gs_delete_workload_rule(rule_id int8)

    Description: Only users with the sysadmin permission can delete an SQL statement concurrency control rule.

    Parameter: rule_id indicates the ID of the concurrency control rule to be updated. The type is int8.

    Return type: Boolean

    Example:

    1
    2
    3
    4
    5
    gaussdb=#  select gs_delete_workload_rule(3);
     gs_delete_workload_rule 
    -------------------------
     t
    (1 row)
    
  • gs_get_workload_rule_stat(rule_id)

    Description: Only users with the sysadmin permission can query the number of SQL statements blocked by an SQL statement concurrency control rule.

    Parameter: rule_id indicates the ID of the concurrency control rule to be queried. The type is int8. You can set rule_id to –1, indicating that all SQL statement concurrency control rules are queried.

    Return type:

    Name

    Type

    Description

    rule_id

    int8

    ID of the SQL statement concurrency control rule.

    validate_count

    int8

    Number of SQL statements intercepted by the SQL statement concurrency control rule.

    Example:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    gaussdb=#  select * from gs_get_workload_rule_stat(1);
     rule_id | validate_count 
    ---------+----------------
           1 |              0
    (1 row)
    gaussdb=#  select * from gs_get_workload_rule_stat(-1);
     rule_id | validate_count 
    ---------+----------------
           1 |              0
           2 |              0
    (2 rows)
    

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback