All Products
Search
Document Center

ApsaraDB RDS:Use transaction splitting

Last Updated:Mar 28, 2026

When autocommit is disabled (for example, via SET autocommit=0), the database proxy routes all queries — including reads — through the primary instance, concentrating load there. Transaction splitting offloads read requests that occur before the first write in a transaction to read-only instances automatically, without requiring application code or configuration changes.

Prerequisites

Before you begin, ensure that you have:

How it works

By default, the database proxy sends all requests in a transaction to the primary instance to preserve accuracy. When autocommit is disabled, every query runs inside an implicit transaction, which concentrates all load on the primary instance.

image.png

Transaction splitting changes this behavior: the proxy starts a transaction on the primary instance only when a write operation occurs. All read requests before the first write are routed to read-only instances through a load balancer. If the default isolation level READ COMMITTED is used and the autocommit mode of transactions is disabled, the system starts a transaction only for write operations.

Note

Support for explicit transactions (started with BEGIN TRANSACTION or START TRANSACTION) depends on when your instance was created:

  • Created on or after July 31, 2024: both explicit and implicit transactions can be split.

  • Created before July 31, 2024: only implicit transactions can be split.

Routing rules

Routed to read-only instances:

  • SELECT statements that occur before the first write in a transaction

Routed to the primary instance:

  • The first write request in a transaction (this is when the transaction starts on the primary)

  • All subsequent requests in an open write transaction (SELECT, UPDATE, INSERT, DELETE, COMMIT)

The following table shows the routing sequence for a typical transaction with autocommit disabled and an implicitly started transaction:

SQL statementRouted toRemarks
SELECTRead-only RDS instanceRead request before the first write
SELECTRead-only RDS instanceRead request before the first write
UPDATE, INSERT, or DELETEPrimary RDS instanceFirst write — transaction starts here
SELECTPrimary RDS instanceRead request after the first write
UPDATE, INSERT, or DELETEPrimary RDS instanceWrite request
SELECTPrimary RDS instanceRead request after the first write
COMMITPrimary RDS instanceTransaction commit

Enable or disable transaction splitting

Important

Transaction splitting does not guarantee global consistency. Verify that your workload can tolerate this trade-off before enabling the feature.

  1. Go to the Instances page. In the top navigation bar, select the region where your RDS instance resides, then click the instance ID.

  2. In the left-side navigation pane, click Database Proxy.

  3. In the Connection Information section, find the proxy endpoint to modify and click Modify Configuration in the Actions column.

  4. In the dialog box, click Enable or Disable next to Transaction Splitting.

Note

The new setting applies only to new connections.

API reference

OperationDescription
DescribeDBProxyQueries database proxy details
DescribeDBProxyEndpointQueries database proxy endpoint information
ModifyDBProxyEndpointModifies database proxy endpoint settings