The rds_ccl extension lets you cap the concurrency of specific SQL statements on ApsaraDB RDS for PostgreSQL. When a burst of identical queries—or a single resource-heavy statement—threatens database stability, throttling rules queue excess executions instead of letting them pile up or crash the instance. Common use cases include controlling backup and monitoring queries during peak hours and blocking runaway queries caused by application bugs or malicious traffic.
Prerequisites
Before you begin, make sure your instance meets the following requirements:
Engine version: To upgrade your minor engine version, see Update the minor engine version.
Major engine version Minimum minor engine version PostgreSQL 16 and 17 All minor versions PostgreSQL 14 and 15 20230330 PostgreSQL 13 20250430 Parameters configured (see Modify parameters):
rds_enable_ccl=oncompute_query_id=autooron
A privileged account on the instance.
Billing
This feature is free of charge.
Limitations
Rules are not persisted in memory across restarts. After an instance restart or a primary/secondary failover, reload your throttling rules manually.
A misconfigured rule—such as setting
max_concurrencytoo low—can block legitimate traffic. Understand your workload patterns before creating rules.Throttling rules are created on the primary instance. To throttle a read-only instance, set the rule's
node_tagto include read-only nodes, then load the rule on the read-only instance separately.When DAS SQL Throttling creates a rule, it installs the plugin in
information_schema. That rule cannot be invoked through SQL commands and only works through the DAS console.
Install and uninstall the extension
Install using the console
Go to the Instances page. In the top navigation bar, select a region, then click the target instance ID.
In the left navigation pane, click Plug-ins.
On the Extension Marketplace page, find the
rds_cclplugin and click Install. Alternatively, go to Extension Management, search forrds_ccl, and click Install in the Actions column.
In the dialog box, select the target database and a privileged account, then click Install.
The instance status changes from Maintaining Instance to Running when installation is complete.
To uninstall, go to Extension Management > Installed Extensions, find the plugin, and click Uninstall in the Actions column.
Install using SQL
Run the following commands as a privileged account.
-- Install the extension
CREATE EXTENSION rds_ccl;
-- Uninstall the extension
DROP EXTENSION rds_ccl;How it works
rds_ccl throttles SQL by matching incoming statements against stored rules. Matching is based on a query_id—a special identifier computed from the normalized form of an SQL statement. Statements that differ only in literal values (such as WHERE id = 1 vs. WHERE id = 2) share the same query_id and are controlled by the same rule.
Key properties of query_id:
The
query_idis derived from the object identifiers (oid) of tables and functions referenced in the query. Tables with the same name in different databases or schemas are different objects, so identical SQL can have differentquery_idvalues when run in different contexts.Global objects—such as the
pg_databasesystem catalog or thepg_sleepfunction—produce the samequery_idregardless of which database executes the query.Adding or removing a
FROMclause, or changing a parameter type, produces a differentquery_id.
To get the query_id for a specific SQL statement, use rds_get_query_id:
SELECT rds_get_query_id($$SELECT * FROM pg_database;$$);Example output:
rds_get_query_id
----------------------
-8733244708994363681
(1 row)Manage throttling rules
Run all commands below as a privileged account.
All throttling rule functions are available only on the primary instance, except rds_load_ccl_rule, rds_unload_ccl_rule, rds_enabled_ccl_rule (view), and rds_show_current_db_ccl_rule(), which can also run on read-only instances.