Use Data Transmission Service (DTS) to set up a continuous data pipeline from ApsaraDB RDS for PostgreSQL to AnalyticDB for PostgreSQL. DTS handles both the initial full load and ongoing incremental change data capture (CDC) over logical replication, so your analytics database stays in sync as source data changes.
Prerequisites
Before you begin, ensure that you have:
An AnalyticDB for PostgreSQL instance with available storage larger than the total data size in the source RDS for PostgreSQL instance. See Create an instance.
A database created in the destination AnalyticDB for PostgreSQL instance to receive the synchronized data. See the CREATE DATABASE section in SQL syntax.
A privileged account on the source RDS for PostgreSQL instance that owns the database. See Create an account and Create a database.
A database account on the destination AnalyticDB for PostgreSQL instance with read and write permissions. An initial account or an account with the RDS_SUPERUSER permission also works. See Create a database account and Manage users and permissions.
Billing
| Synchronization type | Fee |
|---|---|
| Schema synchronization and full data synchronization | Free |
| Incremental data synchronization | Charged. See Billing overview. |
Supported SQL operations for incremental synchronization
| Operation type | SQL statements |
|---|---|
| DML | INSERT, UPDATE, DELETE |
| DDL | CREATE TABLE, DROP TABLE, TRUNCATE TABLE (source self-managed PostgreSQL database 11+), CREATE INDEX ON TABLE, and ALTER TABLE operations including RENAME TABLE, ADD COLUMN, ADD COLUMN DEFAULT, ALTER COLUMN TYPE, DROP COLUMN, ADD CONSTRAINT, ADD CONSTRAINT CHECK, and ALTER COLUMN DROP DEFAULT |
DDL synchronization requirements:
DDL synchronization is only available for tasks created after October 1, 2020.
For tasks created before May 12, 2023, set up triggers and functions in the source database before configuring the task. See Use triggers and functions to implement incremental DDL migration for PostgreSQL databases.
DDL synchronization requires a privileged database account on the source instance and minor engine version 20210228 or later. See Update the minor engine version.
You cannot synchronize data of the BIT type during incremental data synchronization.
The following DDL operations are not synchronized:
DDL statements that include additional modifiers such as CASCADE or RESTRICT
DDL statements from sessions that execute
SET session_replication_role = replicaDDL statements invoked through functions
DDL statements committed in the same transaction as DML statements
DDL statements on objects not included in the synchronization scope
Limitations
Table and schema requirements
Tables must have a PRIMARY KEY or UNIQUE constraint with all fields unique. Without this, the destination database may contain duplicate records.
NoteIf you create a destination table outside of DTS (without selecting Schema Synchronization for Synchronization Types), make sure the destination table has the same PRIMARY KEY or NOT NULL UNIQUE constraints as the source table.
Only tables can be selected as synchronization objects — not views, functions, or other object types.
A task can synchronize data from only one database. To synchronize multiple databases, create a separate task for each.
Tables with inheritance relationships across schemas cannot be synchronized.
The destination table cannot be an append-optimized (AO) table.
DTS does not synchronize the following data types: VARBIT, GEOMETRY, UUID, TSQUERY, TSVECTOR, and TXID_SNAPSHOT.
Column mapping and schema differences
If you use column mapping for non-full-table synchronization, or if the source and destination table schemas differ, data in columns that exist in the source but not in the destination will be lost.
If you rename tables or columns in the destination database using the object name mapping feature, synchronizing more than 5,000 tables in a single task causes a request error. For tables exceeding 5,000, configure multiple tasks or synchronize entire databases instead.
WAL log requirements
The source database must meet these write-ahead logging (WAL) requirements:
Set
wal_leveltological.For incremental-only synchronization: retain WAL logs for more than 24 hours.
For full plus incremental synchronization: retain WAL logs for at least 7 days. After full synchronization completes, you can set the retention period to more than 24 hours.
Failing to meet these requirements may cause DTS to fail to obtain WAL logs, resulting in task failure or, in exceptional cases, data inconsistency or loss.
Runtime constraints
Do not execute DDL statements during schema synchronization or full data synchronization. Doing so fails the task.
If you add a table to a synchronized schema or rename a table using RENAME, execute
ALTER TABLE schema.table REPLICA IDENTITY FULL;before writing data to the table. This prevents data inconsistency. Perform this operation during off-peak hours to avoid deadlocks.NoteReplace
schemaandtablewith the actual schema name and table name.Do not delete the temporary tables that DTS creates in the source database:
public.dts_pg_class,public.dts_pg_attribute,public.dts_pg_type,public.dts_pg_enum,public.dts_postgres_heartbeat,public.dts_ddl_command,public.dts_args_session, andpublic.aliyun_dts_instance. DTS automatically deletes these tables when the instance is released.Long-running transactions in the source database may cause WAL log accumulation and exhaust disk space.
If the source database undergoes a major version upgrade while the task is running, the task fails and cannot be recovered. Reconfigure the task.
A single incremental data change must not exceed 256 MB. If it does, the task fails and cannot be recovered. Reconfigure the task.
Replication slots
DTS creates a replication slot prefixed with dts_sync_ in the source database. This slot retains incremental logs from the last 15 minutes.

The replication slot is automatically deleted when the DTS instance is released. If you change the source database password or remove DTS IP addresses from the whitelist, the slot cannot be auto-deleted — delete it manually to prevent accumulation.
If the task is released or fails, DTS automatically deletes the replication slot. After a primary/secondary switchover on the source PostgreSQL database, log in to the secondary database to delete the replication slot manually.
DTS also adds a heartbeat table named dts_postgres_heartbeat to the source database to track synchronization latency.
Source-specific constraints
ApsaraDB RDS for PostgreSQL:
Do not modify the endpoint or zone of the source RDS for PostgreSQL instance while the task is running. Doing so fails the task.
To perform a primary/secondary switchover on the source instance, enable the Logical Replication Slot Failover feature first. See Logical Replication Slot Failover.
Self-managed PostgreSQL:
Set
max_wal_sendersandmax_replication_slotsto values greater than the sum of existing replication slots and the number of DTS instances to be created.A primary/secondary switchover on a self-managed PostgreSQL database fails the task.
Google Cloud SQL for PostgreSQL:
Set the Database Account parameter to an account with the
cloudsqlsuperuserpermission. When selecting objects to synchronize, only select objects the account is authorized to manage, or grant the OWNER permission on those objects to the account.NoteAn account with the
cloudsqlsuperuserpermission cannot manage data owned by other accounts with the same permission.
Data consistency
Evaluate the impact on source and destination database performance before starting the task. Run the task during off-peak hours.
During full data synchronization, concurrent INSERT operations create table fragmentation in the destination database, so the destination tablespace may be larger than the source after full synchronization completes.
Data inconsistency occurs if data from sources other than DTS is written to the destination database during synchronization. If you use Data Management (DMS) to perform online DDL operations while other sources write to the destination, data loss may occur.
If you use only DTS to write data to the destination, use DMS to perform online DDL operations on source tables during synchronization. See Change schemas without locking tables.
Task recovery
If a DTS task fails, DTS technical support attempts recovery within 8 hours. During recovery, the task may be restarted and task parameters (not database parameters) may be modified. For details on which parameters may change, see the Modify instance parameters section of Modify the parameters of a DTS instance.
Configure a data synchronization task
Step 1: Go to Data Synchronization Tasks
Log on to the Data Management (DMS) console.
In the top navigation bar, click Data + AI.
In the left-side navigation pane, choose DTS (DTS) > Data Synchronization.
NoteNavigation may vary based on the DMS console mode and layout. See Simple mode and Customize the layout and style of the DMS console.
You can also go directly to the Data Synchronization Tasks page of the new DTS console.
Step 2: Create a task
On the right side of Data Synchronization Tasks, select the region where the synchronization instance will reside.
NoteIn the new DTS console, select the region in the top navigation bar.
Click Create Task.
(Optional) Click New Configuration Page in the upper-right corner.
NoteSkip this step if Back to Previous Version is displayed instead.
Use the new configuration page — some parameters differ between versions.
Step 3: Configure source and destination databases
Configure the following parameters:
Task name
| Parameter | Description |
|---|---|
| Task Name | A name for the DTS task. DTS generates a default name — specify a descriptive name to identify the task easily. The name does not need to be unique. |
Source database
| Parameter | Description |
|---|---|
| Select a DMS database instance. | Select an existing registered database to auto-populate the settings, or leave blank and configure manually. To register a database, see Register an Alibaba Cloud database instance or Register a database hosted on a third-party cloud service or a self-managed database. For DTS console registration, see Manage database connections. |
| Database Type | Select PostgreSQL. |
| Access Method | Select Alibaba Cloud Instance. |
| Instance Region | The region of the source RDS for PostgreSQL instance. |
| Replicate Data Across Alibaba Cloud Accounts | Select No to use a database in the current account. |
| Instance ID | The ID of the source RDS for PostgreSQL instance. |
| Database Name | The name of the source database containing the data to synchronize. |
| Database Account | The privileged account for the source instance. |
| Database Password | The password for the database account. |
| Encryption | Select Non-encrypted for a standard connection, or SSL-encrypted for an encrypted connection. For SSL, upload CA Certificate, and optionally Client Certificate and Private Key of Client Certificate, then set Private Key Password of Client Certificate. See SSL encryption. |
Destination database
| Parameter | Description |
|---|---|
| Select a DMS database instance. | Select an existing registered database to auto-populate the settings, or configure manually. |
| Database Type | Select AnalyticDB for PostgreSQL. |
| Access Method | Select Alibaba Cloud Instance. |
| Instance Region | The region of the destination AnalyticDB for PostgreSQL instance. |
| Instance ID | The ID of the destination AnalyticDB for PostgreSQL instance. |
| Database Name | The name of the destination database. |
| Database Account | The account for the destination instance, with read and write permissions. |
| Database Password | The password for the database account. |
Step 4: Test connectivity
Click Test Connectivity and Proceed.
DTS automatically adds its server CIDR blocks to the whitelists of Alibaba Cloud database instances and the security group rules of ECS-hosted databases. For self-managed databases in data centers or on third-party cloud platforms, manually add the DTS server CIDR blocks to the database whitelist. See CIDR blocks of DTS servers.
Adding DTS CIDR blocks to whitelists or security groups carries security risks. Before proceeding, take preventive measures such as enforcing strong credentials, limiting exposed ports, authenticating API calls, auditing whitelist rules regularly, and using Express Connect, VPN Gateway, or Smart Access Gateway to connect the database to DTS.
Step 5: Configure synchronization objects
Choose synchronization types
Select the synchronization types that match your use case:
| Synchronization type | When to select |
|---|---|
| Schema Synchronization | Select to have DTS create destination tables automatically. Required when you also select Full Data Synchronization. |
| Full Data Synchronization | Select to copy all existing data from the source to the destination before incremental sync starts. Required for initial setup. |
| Incremental Data Synchronization | Selected by default. Keeps the destination in sync with ongoing changes in the source using logical replication. Required for continuous synchronization. |
For most setups, select all three: schema synchronization creates the tables, full data synchronization copies historical data, and incremental data synchronization keeps the destination current.
Configure objects and conflict handling
| Parameter | Description |
|---|---|
| DDL and DML Operations to Be Synchronized | The SQL operations to synchronize. To configure per-table, right-click an object in Selected Objects and select the operations. See SQL operations that support incremental synchronization. |
| Processing Mode of Conflicting Tables | Precheck and Report Errors: fails the precheck if destination tables share names with source tables. Use object name mapping to resolve conflicts. Ignore Errors and Proceed: skips the name conflict check. During full sync, existing destination records with matching primary or unique keys are retained; during incremental sync, they are overwritten. If schemas differ, initialization may partially fail. |
| Capitalization of Object Names in Destination Instance | How DTS handles the case of database, table, and column names in the destination. Default is DTS default policy. See Specify the capitalization of object names in the destination instance. |
| Source Objects | Select objects from this section and click |
| Selected Objects | Right-click a table to rename it, set data filters, or configure per-table SQL operations. To rename multiple objects at once, click Batch Edit. See Map object names and Set filter conditions. |
Renaming an object using object name mapping may cause dependent objects to fail synchronization.
Configure advanced settings
Click Next: Advanced Settings and configure the following parameters:
| Parameter | Description |
|---|---|
| Dedicated Cluster for Task Scheduling | DTS uses a shared cluster by default. Purchase a dedicated cluster for higher stability. See What is a DTS dedicated cluster. |
| Retry Time for Failed Connections | How long DTS retries failed connections after the task starts. Range: 10–1440 minutes. Default: 720 minutes. Set to more than 30 minutes. If DTS reconnects within this period, the task resumes; otherwise, the task fails. The shortest value across tasks sharing the same source or destination takes effect. |
| Retry Time for Other Issues | How long DTS retries failed DDL or DML operations. Range: 1–1440 minutes. Default: 10 minutes. Set to more than 10 minutes, and keep it lower than Retry Time for Failed Connections. |
| Enable Throttling for Full Data Synchronization | Limits the read/write load on source and destination databases during full synchronization. Configure Queries per second (QPS) to the source database, RPS of Full Data Migration, and Data migration speed for full migration (MB/s). Available only when Full Data Synchronization is selected. |
| Enable Throttling for Incremental Data Synchronization | Limits the load during incremental synchronization. Configure RPS of Incremental Data Synchronization and Data synchronization speed for incremental synchronization (MB/s). |
| Environment Tag | An optional tag to identify the DTS instance by environment. |
| Configure ETL | Set to Yes to enable extract, transform, and load (ETL) processing and enter data transformation statements. Set to No to skip. See What is ETL? and Configure ETL in a data migration or data synchronization task. |
| Monitoring and Alerting | Set to Yes to receive alerts when the task fails or synchronization latency exceeds a threshold. Configure the alert threshold and notification settings. See Configure monitoring and alerting. |
Configure data verification
Click Next Step: Data Verification to set up data verification. See Configure a data verification task.
(Optional) Configure database and table fields
Click Next: Configure Database and Table Fields to set the table structure in the destination AnalyticDB for PostgreSQL instance:
| Parameter | Description |
|---|---|
| Type | The table type in the destination instance. |
| Primary Key Column | The primary key column or columns. Multiple columns form a composite primary key. |
| Distribution Key | The distribution key for the table. Must be one of the primary key columns. See Manage tables and Define table distribution. |
This step is only available when Schema Synchronization is selected. Set Definition Status to All to view and modify all tables.
Step 6: Save settings and run a precheck
Click Next: Save Task Settings and Precheck.
To preview the API parameters for this task configuration, hover over the button and click Preview OpenAPI parameters.
DTS runs a precheck before starting the task. The task starts only after the precheck passes.
If the precheck fails, click View Details next to each failed item, resolve the issues, and click Precheck Again.
If an alert is triggered: if it cannot be ignored, resolve the issue and rerun the precheck. If it can be ignored, click Confirm Alert Details, then Ignore, then OK, then Precheck Again. Ignoring alerts may cause data inconsistency.
Step 7: Purchase and start the instance
Wait until Success Rate reaches 100%, then click Next: Purchase Instance.
On the purchase page, configure the following:
| Parameter | Description |
|---|---|
| Billing Method | Subscription: pay upfront for a fixed term, more cost-effective for long-term use. Pay-as-you-go: billed hourly, suitable for short-term use. Release the instance when no longer needed to stop charges. |
| Resource Group Settings | The resource group for the instance. Default: default resource group. See What is Resource Management? |
| Instance Class | The synchronization speed tier. See Instance classes of data synchronization instances. |
| Subscription Duration | Available only for the subscription billing method. Options: 1–9 months, 1 year, 2 years, 3 years, or 5 years. |
Read and select Data Transmission Service (Pay-as-you-go) Service Terms, then click Buy and Start. In the confirmation dialog, click OK.
The task appears in the task list. You can monitor its progress there.
What's next
Logical Replication Slot Failover — enable this on the source RDS instance if you plan to perform primary/secondary switchovers.
Map object names — rename objects in the destination without changing source objects.
Modify the parameters of a DTS instance — adjust task parameters after the task starts.
Configure a data verification task — verify data consistency between source and destination.