Use Data Transmission Service (DTS) to migrate data from a PolarDB for PostgreSQL cluster to an AnalyticDB for PostgreSQL instance. DTS supports schema migration, full data migration, and incremental data migration—giving you the flexibility to run a one-time batch migration or a continuous, low-downtime migration.
Choose a migration strategy
Select the migration strategy that matches your scenario before configuring the task.
| Strategy | What it does | When to use |
|---|---|---|
| Schema migration + full data migration | Copies the table structure and all existing data once, then stops | Offline migration with a maintenance window that allows pausing writes to the source |
| Schema migration + full data migration + incremental data migration | Copies existing data, then continuously replicates changes | Online migration with minimal downtime |
If you select only full data migration (no incremental), do not write new data to the source instance during migration. Otherwise, data inconsistency occurs between the source and destination databases.
Prerequisites
Before you begin, ensure that you have:
-
A destination AnalyticDB for PostgreSQL instance with more disk space than the source PolarDB for PostgreSQL instance. See Create an instance.
-
The
wal_levelparameter of the source PolarDB for PostgreSQL cluster set tological. See Set cluster parameters. -
A database created in the destination AnalyticDB for PostgreSQL instance to receive migrated data. See CREATE DATABASE.
Billing
| Migration type | Link configuration fee | Data transfer fee |
|---|---|---|
| Schema migration and full data migration | Free | Free |
| Incremental data migration | Charged. See Billing overview. | — |
Database account permissions
| Database | Required permissions | How to grant |
|---|---|---|
| Source PolarDB for PostgreSQL cluster | Privileged account | Create a database account |
| Destination AnalyticDB for PostgreSQL instance | Read and write permissions on the destination database, or RDS_SUPERUSER permission | Create and manage users and Manage user permissions |
Supported SQL operations for incremental migration
DML operations
| Operation | Behavior in the destination |
|---|---|
| INSERT | Replicated as-is |
| UPDATE | Converted to REPLACE INTO. If the primary key is updated, converted to DELETE + INSERT. |
| DELETE | Replicated as-is |
DDL operations
DDL migration is available only in tasks created after October 1, 2020.
For tasks created before May 12, 2023, create a trigger and a function in the source database to capture DDL information before configuring the task. See Use triggers and functions to implement incremental DDL migration for PostgreSQL.
Supported DDL operations (requires a privileged account on the source database):
-
CREATE TABLE and DROP TABLE
-
ALTER TABLE, including: RENAME TABLE, ADD COLUMN, ADD COLUMN DEFAULT, ALTER COLUMN TYPE, DROP COLUMN, ADD CONSTRAINT, ADD CONSTRAINT CHECK, and ALTER COLUMN DROP DEFAULT
-
TRUNCATE TABLE (source PostgreSQL version must be 11 or later)
-
CREATE INDEX ON TABLE
Unsupported DDL scenarios:
-
Additional keywords such as CASCADE or RESTRICT in DDL statements
-
DDL statements in sessions where
SET session_replication_role = replicais run -
DDL statements executed by calling a FUNCTION or other methods
-
Batches that contain both DML and DDL statements (DDL is not migrated)
-
DDL statements for objects not included in the migration scope
Data of the bit type is not supported during incremental data migration.
Limitations
Review the following limitations before configuring the migration task.
Source database limitations
-
Tables to be migrated must have a primary key or a non-null unique index.
-
If the source database has long-running transactions and the task includes incremental migration, write-ahead log (WAL) generated before those transactions are committed may accumulate and exhaust disk space on the source database.
-
The PolarDB for PostgreSQL cluster must support and enable Logical Replication Slot Failover.
ImportantIf the source cluster does not support Logical Replication Slot Failover—for example, if the Database Engine is PostgreSQL 14—a high availability (HA) switchover on the source may cause the migration task to fail and become unrecoverable.
-
Do not perform DDL operations that change the database or table structure during schema migration or full data migration. Otherwise, the migration task fails.
-
A single piece of data that exceeds 256 MB after an incremental change causes the migration task to fail and become unrecoverable. Reconfigure the migration task in this case.
Scope limitations
-
A single migration task migrates only one database. Configure a separate task for each additional database.
-
DTS does not support: TimescaleDB extension tables, tables with cross-schema inheritance, or tables with unique indexes based on expressions.
-
Schemas created by installing plugins cannot be migrated and do not appear in the console during task configuration.
-
DTS does not migrate the following object types: DATATYPE, SEQUENCE, INDEX, PROCEDURE, FUNCTION, VIEW, OPERATOR, DEFAULT_CONSTRAINT, UK, PK, RULE, DOMAIN, AGGREGATE, EXTENSION, FK, and TRIGGER.
-
Destination tables do not support AO (append-optimized) tables.
-
For partitioned tables, include both the parent table and all its child tables as migration objects. In PostgreSQL, the parent table does not store data directly—all data resides in child tables. Omitting child tables causes data inconsistency.
Data consistency limitations
-
During schema migration, DTS migrates foreign keys from the source to the destination.
-
During full data migration and incremental data migration, DTS temporarily disables constraint checks and foreign key cascade operations at the session level. If cascade update or delete operations occur on the source while the task runs, data inconsistency may occur.
-
Full data migration uses concurrent INSERT operations, which causes table fragmentation in the destination. As a result, the destination table space is larger than the source after full migration.
-
If a table has a primary key, the primary key column in the destination must match the source. If a table has no primary key, the primary key column in the destination must match the distribution key.
-
The unique key (including the primary key column) of the destination table must contain all columns of the distribution key.
-
If the source and destination table schemas are inconsistent, or you use column mapping for a non-full table migration, data in columns that exist only in the source is lost.
-
DTS validates data content but does not validate metadata such as sequences. Validate metadata separately after migration.
Incremental migration requirements
Before writing data to the source database for incremental migration, run the following command on each table to be migrated:
ALTER TABLE schema.table REPLICA IDENTITY FULL;
Replace schema and table with the actual schema name and table name. Run this command during off-peak hours and avoid table lock operations during its execution.
Run this command in the following scenarios:
-
When the migration task runs for the first time.
-
When the migration object is a schema, and a new table is created in that schema or an existing table is rebuilt using RENAME.
If you skip the related precheck item, DTS automatically runs this command during instance initialization.
Post-migration sequence handling
After switching your business to the destination instance, sequences do not automatically start from the maximum value of the corresponding source sequences. Before switching, query the maximum sequence values in the source database and set them as initial values in the destination.
Run the following command on the source database to get all sequence values:
do language plpgsql $$
declare
nsp name;
rel name;
val int8;
begin
for nsp,rel in select nspname,relname from pg_class t2 , pg_namespace t3 where t2.relnamespace=t3.oid and t2.relkind='S'
loop
execute format($_$select last_value from %I.%I$_$, nsp, rel) into val;
raise notice '%',
format($_$select setval('%I.%I'::regclass, %s);$_$, nsp, rel, val+1);
end loop;
end;
$$;
The output contains SET statements for all sequences in the source database. Run only the statements relevant to your migration on the destination database.
Replication slot management
During incremental migration, DTS creates a replication slot with the prefix dts_sync_ in the source database to replicate incremental logs from the past 15 minutes. When a migration task fails or the instance is released, DTS attempts to clean up the replication slot automatically.
Manual cleanup is required in the following cases:
-
You changed the source database account password during migration.
-
You removed the DTS IP address from the source database IP address whitelist during migration.
-
A failover occurred on the source database—log on to the secondary database to clean up the slot manually.
If the replication slot is not cleaned up, it continuously accumulates and consumes disk space, which can make the source database unavailable.
Temporary tables
DTS creates the following temporary tables in the source database to obtain DDL statements, incremental table structure information, and heartbeat data. Do not delete these tables during migration—they are automatically deleted after the DTS instance is released.
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, and public.aliyun_dts_instance
Configure a migration task
Step 1: Open the migration task list
Open the migration task list using one of the following methods.
From the DTS console:
-
Log on to the DTS console.
-
In the left navigation pane, click Data Migration.
-
In the upper-left corner, select the region where the migration instance is located.
From the DMS console:
The actual steps may vary based on your DMS console mode and layout. See Simple mode console and Customize the layout and style of the DMS console.
-
Log on to the DMS console.
-
In the top menu bar, choose Data + AI > Data Transmission (DTS) > Data Migration.
-
To the right of Data Migration Tasks, select the region where the migration instance is located.
Step 2: Configure source and destination databases
Configure the following settings on the source and destination database connection page.
| Category | Parameter | Value or description |
|---|---|---|
| — | Task Name | DTS generates a name automatically. Enter a descriptive name for easy identification. The name does not need to be unique. |
| Source Database | Select Existing Connection | Select a database instance already registered in the system from the drop-down list to auto-fill the connection fields. If the instance is not registered, fill in the fields manually. In the DMS console, this field is named Select a DMS database instance. |
| Database Type | PolarDB for PostgreSQL | |
| Access Method | Alibaba Cloud Instance | |
| Instance Region | Region where the source PolarDB for PostgreSQL cluster resides | |
| Replicate Data Across Alibaba Cloud Accounts | No (same-account migration) | |
| Instance ID | ID of the source PolarDB for PostgreSQL cluster | |
| Database Name | Name of the database containing the objects to migrate | |
| Database Account | Account for the source PolarDB for PostgreSQL cluster. See Database account permissions. | |
| Database Password | Password for the database account | |
| Destination Database | Select Existing Connection | Select a registered database instance or fill in the fields manually. In the DMS console, this field is named Select a DMS database instance. |
| Database Type | AnalyticDB for PostgreSQL | |
| Access Method | Alibaba Cloud Instance | |
| Instance Region | Region where the destination AnalyticDB for PostgreSQL instance resides | |
| Instance ID | ID of the destination AnalyticDB for PostgreSQL instance | |
| Database Name | Name of the database in the destination instance that receives the migrated data | |
| Database Account | Account for the destination AnalyticDB for PostgreSQL instance. See Database account permissions. | |
| Database Password | Password for the database account |
After completing the configuration, click Test Connectivity and Proceed at the bottom of the page.
Make sure the DTS service IP address ranges are added to the security settings (whitelist) of both the source and destination databases. See Add DTS server IP addresses to a whitelist.
Step 3: Configure migration objects
On the Configure Objects page, set the following parameters.
| Parameter | Description |
|---|---|
| Migration Types | Select the migration types for your scenario. See Choose a migration strategy. If you do not select Schema Migration, make sure the destination already has the target database and tables. |
| DDL and DML Operations to Be Synchronized | Select the SQL operations for incremental migration at the instance level. To configure at the table level, right-click a migration object in the Selected Objects box and select operations in the dialog. See Supported SQL operations for incremental migration. |
| Processing Mode of Conflicting Tables | Precheck and Report Errors: Checks for tables with the same name in the destination. Reports an error and stops the task if a conflict is found. To resolve naming conflicts without deleting the destination table, use object name mapping. Ignore Errors and Proceed: Skips the conflict check. During full migration, existing destination records are kept. During incremental migration, source records overwrite destination records. If table schemas are inconsistent, migration may fail or result in partial data. Use with caution. |
| Storage Engine Type | Storage engine for destination tables. Default: Beam. Available only when the destination AnalyticDB for PostgreSQL kernel version is v7.0.6.6 or later and Schema Migration is selected. |
| Capitalization of Object Names in Destination Instance | Case sensitivity policy for migrated object names (databases, tables, columns). Default: DTS default policy. See Case sensitivity of object names in the destination database. |
| Source Objects | Click objects to migrate in the Source Objects box, then click the right arrow to move them to the Selected Objects box. Migration objects are selected at the table level. |
| Selected Objects | To rename a single object in the destination, right-click it in the Selected Objects box. See Individual table column mapping. To rename multiple objects at once, click Batch Edit in the upper-right corner. See Map multiple object names at a time. To filter rows with a WHERE clause, right-click the table and set the condition. See Set a filter condition. |
Using object name mapping may cause migration to fail for other objects that depend on the renamed object.
Step 4: Configure advanced settings
Click Next: Advanced Settings to configure the following parameters.
| Parameter | Description |
|---|---|
| Dedicated Cluster for Task Scheduling | By default, DTS schedules tasks on a shared cluster. For more stable performance, purchase a dedicated cluster to run migration tasks. |
| Retry Time for Failed Connections | Duration DTS retries the connection if the source or destination database is unreachable after the task starts. Default: 720 minutes. Range: 10–1440 minutes. Set to more than 30 minutes. If DTS reconnects within the retry period, the task resumes automatically; otherwise, the task fails. Note
For multiple DTS instances sharing the same source or destination, the retry time is determined by the most recently created task. Charges apply during the retry period. |
| Retry Time for Other Issues | Duration DTS retries if a non-connectivity error (such as a DDL or DML exception) occurs. Default: 10 minutes. Range: 1–1440 minutes. Set to more than 10 minutes. Must be less than Retry Time for Failed Connections. |
| Enable Throttling for Full Data Migration | Limit the read/write load on source and destination during full migration by setting 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 Migration is selected. Throttling can also be adjusted after the task starts. |
| Enable Throttling for Incremental Data Migration | Limit the load during incremental migration by setting RPS of Incremental Data Migration and Data migration speed for incremental migration (MB/s). Available only when Incremental Data Migration is selected. Throttling can also be adjusted after the task starts. |
| Environment Tag | Tag the instance with an environment label for identification. Optional. |
| Configure ETL | Enable extract, transform, and load (ETL) processing. Select Yes to enter data processing statements in the code editor. See Configure ETL in a data migration or data synchronization task. Select No to skip. See What is ETL? |
| Monitoring and Alerting | Select Yes to configure an alert threshold and notification recipients. DTS sends alerts if a migration fails or latency exceeds the threshold. Select No to skip. |
Step 5: Configure data validation
Click Next: Data Validation to configure a data validation task. See Configure data validation.
Step 6: Configure destination table fields (optional)
Click Next: Configure Database and Table Fields to set the Type, Primary Key Column, and Distribution Key for destination tables in AnalyticDB for PostgreSQL.
This step is available only when Schema Migration is selected. Set Definition Status to All to view and edit all tables.
-
Primary Key Column: Select one or more columns. Multiple columns form a composite primary key.
-
Distribution Key: Select one or more columns from the Primary Key Column. See Manage data tables and Define table distribution.
Step 7: Save settings and run a precheck
Click Next: Save Task Settings and Precheck.
To preview the API parameters for this configuration, hover over the Next: Save Task Settings and Precheck button and click Preview OpenAPI parameters.
Before the migration task starts, DTS performs a precheck. The task starts only after it passes the precheck.
If the precheck fails, click View Details next to the failed item, fix the issue, and click Precheck Again.
If a warning appears:
-
For warnings that cannot be ignored, fix the underlying issue and rerun the precheck.
-
For ignorable warnings, click Confirm Alert Details > Ignore > OK > Precheck Again to proceed. Ignoring warnings may cause data inconsistency.
Step 8: Purchase the instance
-
When Success Rate reaches 100%, click Next: Purchase Instance.
-
On the Purchase page, set the following parameters.
Parameter Description Resource Group Settings Resource group for the instance. Default: default resource group. See What is Resource Management? Instance Class Migration link specification that determines migration speed. See Data migration link specifications. -
Read and select Data Transmission Service (Pay-as-you-go) Service Terms.
-
Click Buy and Start, then click OK in the confirmation dialog.
Verify migration status
After the task starts, monitor its progress on the Data Migration Tasks list page.
-
Full migration only: The task stops automatically when full migration completes. The Status changes to Completed.
-
Includes incremental migration: The task continues running after full migration. The Status shows Running during incremental migration.
Before switching your business to the destination instance:
-
Verify that data is consistent between the source and destination.
-
Validate sequences and other metadata manually—DTS does not validate metadata.
-
End or release the DTS task, or use the
REVOKEcommand to revoke DTS write permissions on the destination. This prevents DTS auto-recovery (which runs for up to 7 days) from overwriting destination data.
If the task fails, DTS technical support attempts recovery within 8 hours. During recovery, the task may be restarted or its parameters adjusted. Only DTS task parameters are modified—database parameters remain unchanged. See Modify instance parameters.
What's next
-
Object name mapping — Rename objects during migration
-
Enable throttling for data migration — Adjust migration speed after the task starts
-
Configure data validation — Verify data consistency between source and destination
-
Billing overview — Understand DTS pricing