ApsaraDB RDS for PostgreSQL provides the SQL throttling feature. You can use the feature to limit the maximum number of concurrent SQL queries on an ApsaraDB RDS for PostgreSQL instance and resolve the issues that are caused by resource-intensive SQL statements. This feature ensures that your database system runs stably and helps meet your business requirements.
Background information
SQL throttling is an important technique to manage databases. SQL throttling can be used to limit the maximum number of concurrent SQL statements to prevent excessive database loads, ensure database stability and reliability, and improve database performance and efficiency.
Scenarios
SQL throttling is suitable for high-concurrency access scenarios and the following scenarios:
Attack prevention
You can use the SQL throttling feature to limit the maximum number of concurrent SQL statements by type to prevent attacks including denial-of-service (DoS) attacks. This helps ensure database security.
Resource usage control
You can use the SQL throttling feature to limit the maximum number of concurrent SQL statements by type to control the usage of database resources. This prevents database failures or performance degradation that is caused by resource exhaustion.
For example, when you execute SQL statements to back up, restore, or monitor databases, you can use the SQL throttling feature to manage the execution speed of SQL statements and prevent negative impacts on database performance.
Prerequisites
The major and minor engine versions of your RDS instance meet the requirements in the following table:
Major engine version
Minor engine version
PostgreSQL 16 and PostgreSQL 17
All minor engine versions
PostgreSQL 14 and PostgreSQL 15
20230330 or later
PostgreSQL 13
20250430 or later
NoteFor more information about how to update the minor engine version of an RDS instance, see Update the minor engine version of an ApsaraDB RDS for PostgreSQL instance.
Before you use the rds_ccl extension, make sure that the following parameter settings are used. For more information about how to configure instance parameters, see Modify the parameters of an ApsaraDB RDS for PostgreSQL instance.
rds_enable_ccl:
on
compute_query_id:
auto
oron
Limits
None
Impacts
If SQL throttling is not properly configured, your workloads may be affected. We recommend that you configure SQL throttling based on your workloads.
For example, the RDS instance is heavily loaded due to a spike in access requests. You can use the SQL throttling feature to limit the maximum number of concurrent SQL statements by type to reduce the load on the RDS instance. However, if you set the number of concurrent SQL statements to a small value, your workloads may also be affected.
Usage notes
SQL throttling rules must be manually loaded in scenarios such as instance restart and primary/secondary switchovers. For more information, see Load an SQL throttling rule.
Billing
The extension is free of charge.
Create and delete the extension
Create and delete the extension in the console
Go to the Instances page. Select the region of the instance from the top navigation bar. Then, click the ID of the instance for which you want to create or delete the extension.
In the left-side navigation pane, click Plug-ins.
On the Extension Marketplace page, find the rds_ccl extension and click Install.
You can also search for the rds_ccl extension on the Extension Management page, and click Install in the Actions column.
In the dialog box that appears, select the database and the priviledged account, and then click OK.
When the instance status changes from Maintaining Instance to Running, the extension is created.
You can perform the following operations to delete the extension: Select the Installed Extensions tab on the Extension Management page. Then, click Uninstall in the Actions column corresponding to rds_ccl.
Create and delete the extension by running SQL commands
Use the privileged account to run the following commands.
Create the extension.
CREATE EXTENSION rds_ccl;
Delete the extension.
DROP EXTENSION rds_ccl;
Examples
Use the privileged account to run the commands in this section.
When you create a SQL throttling rule using the SQL throttling feature provided by Database Autonomy Service (DAS), the extension is created in the information_schema of the database by default. Therefore, when you execute SQL commands in this section, explicitly specify information_schema in the command (such as
SELECT information_schema.rds_add_ccl_rule()
) or add information_schema to search_path.