All Products
Search
Document Center

Data Transmission Service:Migrate data from PolarDB for PostgreSQL to SelectDB

Last Updated:Dec 27, 2025

This topic describes how to use Data Transmission Service (DTS) to migrate data from a PolarDB for PostgreSQL cluster to a SelectDB instance to support your data analytics needs for large data volumes.

Prerequisites

Create a destination SelectDB instance. The storage space of the destination instance must be larger than the used storage space of the source PolarDB for PostgreSQL cluster. For more information, see Create an instance.

Precautions

Type

Description

Source database limits

  • The tables to be migrated from the source PolarDB for PostgreSQL cluster must contain primary keys or UNIQUE NOT NULL indexes.

  • Requirements for migration objects:

    • All tables to be migrated have a primary key or a non-null unique index:

      Ensure that the table fields are unique. Otherwise, duplicate data may exist in the destination database.

    • The migration objects include tables that have neither a primary key nor a non-null unique index:

      When you configure the instance, select Migration Types and then select Schema Migration. In the Configurations for Databases, Tables, and Columns step, set Engine to duplicate for these tables. Otherwise, the instance may fail or data may be lost.

      Note

      During schema migration, DTS adds fields to the destination table. For more information, see Information about additional columns.

  • For incremental migration, you must set the wal_level parameter of the source PolarDB for PostgreSQL cluster to logical. For more information, see Set cluster parameters.

  • If the source database has long-running transactions and the data migration task contains incremental data migration, the write-ahead logging (WAL) logs that are generated before the long-running transactions are submitted may not be cleared and therefore pile up, resulting in insufficient storage space in the source database.

  • If you want to perform a primary/secondary switchover on the source PolarDB for PostgreSQL cluster, the logical replication slot failover feature must be enabled. This prevents logical subscriptions from being interrupted and ensures that your data migration task can run as expected. For more information, see Logical replication slot failover.

    Note

    If the source PolarDB for PostgreSQL cluster does not support the logical replication slot failover feature (for example, when Database Engine is set to PostgreSQL 14) and when you trigger a primary/secondary switchover, the data synchronization task may fail and it cannot be recovered.

  • Operational limits on the source database:

    • During schema migration and full migration, do not perform DDL operations to change the schema of a database or table. Otherwise, the data migration task fails.

    • If you perform only full data migration, do not write new data to the source instance. Otherwise, data inconsistency occurs between the source and destination instances. To ensure real-time data consistency, select Schema Migration, Full Data Migration, and Incremental Data Migration.

    • Due to the limits of logical replication in the source database, if a single piece of data to be migrated exceeds 256 MB after an incremental change, the migration instance may fail and cannot be recovered. You must reconfigure the migration instance.

Other limits

  • You can migrate data only to tables that use the Unique or Duplicate engine in SelectDB instances.

    If the destination table uses the Unique engine

    If the destination table uses the Unique engine, make sure that all unique keys of the destination table exist in the source table and are included in the migration objects. Otherwise, data inconsistency may occur.

    If the destination table uses the Duplicate engine

    If the destination table uses the Duplicate engine, duplicate data may exist in the destination database in the following cases. You can remove duplicate data based on the additional columns (_is_deleted, _version, and _record_id).

    • A retry operation occurred in the migration instance.

    • The migration instance was restarted.

    • Two or more DML operations were performed on the same data row after the migration instance started.

      Note

      If the destination table uses the Duplicate engine, DTS converts UPDATE or DELETE statements to INSERT statements.

  • When you configure parameters in the Selected Objects box, you can set only the bucket_count (number of buckets) parameter.

    Note

    The value of the bucket_count parameter must be a positive integer. The default value is auto.

  • SelectDB instances support only database and table names that start with a letter. If the name of a database or table that you want to migrate does not start with a letter, use the object name mapping feature to rename the database or table.

  • If the name of an object that you want to migrate, such as a database, table, or column, contains Chinese characters, use the object name mapping feature to rename the object. For example, you can change the name from Chinese to English. Otherwise, the task may fail.

  • You cannot perform DDL operations that modify multiple columns at a time or that modify the same table in succession.

  • A migration instance can migrate only one database. To migrate multiple databases, you must configure a migration instance for each database.

  • DTS does not support the migration of TimescaleDB extension tables or tables with cross-schema inheritance.

  • If the migration instance includes an incremental data migration task, you must run the ALTER TABLE schema.table REPLICA IDENTITY FULL; command on the tables to be migrated in the source database before writing data to them. This ensures data consistency. Do not lock the tables when you run this command. Otherwise, a deadlock may occur. If you skip the relevant check during the precheck, DTS automatically runs this command during instance initialization. This applies in the following scenarios:

    • When the instance runs for the first time.

    • When the migration object granularity is set to Schema, and a new table is created in the schema or an existing table is rebuilt using the RENAME command.

    Note
    • In the command, replace schema and table with the actual schema name and table name.

    • Run this command during off-peak hours.

  • During full data migration, DTS consumes some read and write resources of the source and destination databases, which may increase the database load. Before you migrate data, evaluate the performance of the source and destination databases. We recommend that you perform data migration during off-peak hours, for example, when the CPU load of the source and destination databases is below 30%.

  • During data migration, do not add backend (BE) nodes to the SelectDB database. Otherwise, the task fails. You can restart the migration instance to resume the failed task.

  • During data migration, do not create clusters in the destination SelectDB instance. Otherwise, the data migration task fails. You can restart the migration instance to resume the failed task.

  • In a multi-table merge scenario, where data from multiple source tables is migrated to a single destination table, ensure that the schemas of the source tables are consistent. Otherwise, data inconsistency or task failure may occur.

  • DTS does not check the validity of metadata such as sequences. You must manually check the validity of metadata.

  • DTS creates the following temporary tables in the source database to obtain DDL statements for incremental data, the structure of incremental tables, and heartbeat information. Do not delete these temporary tables during migration. Otherwise, the DTS task becomes abnormal. The temporary tables 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.

  • During incremental data migration, DTS creates a replication slot with the prefix dts_sync_ in the source database to replicate data. DTS uses this replication slot to obtain incremental logs from the source database within the last 15 minutes. When the data migration fails or the migration instance is released, DTS attempts to clean up this replication slot.

    Note
    • If you change the password of the source database account used by the task or delete the DTS IP address from the whitelist during data migration, the replication slot cannot be automatically cleaned up. In this case, you must manually clean up the replication slot in the source database. This prevents it from accumulating and consuming disk space, which could make the source database unavailable.

    • If a primary/secondary failover occurs in the source database, you must log on to the secondary database to perform the cleanup.

  • When you migrate a partitioned table, you must include both the child partitions and the parent table as synchronization objects. Otherwise, data inconsistency may occur for the partitioned table.

    Note

    The parent table of a PostgreSQL partitioned table does not directly store data. All data is stored in the child partitions. The synchronization task must include the parent table and all its child partitions. Otherwise, data in the child partitions may be missed, leading to data inconsistency between the source and destination.

  • During incremental migration, DTS uses a batch synchronization policy to reduce the load on the destination. By default, for a single synchronization object, DTS writes data at most once every 5 seconds. As a result, the DTS migration task may have a normal synchronization latency, usually within 10 seconds. To reduce this normal migration latency, modify the selectdb.reservoir.timeout.milliseconds parameter of the DTS instance in the console to adjust the batching time. The allowed range is [1000, 10000] milliseconds.

    Note

    When you adjust the batching time, a lower value increases the write frequency of DTS. This may increase the load and response time (RT) of the destination, which in turn increases the DTS synchronization latency. Adjust the batching time based on the load of the destination.

  • If an instance fails, DTS helpdesk will try to recover the instance within 8 hours. During the recovery process, operations such as restarting the instance or adjusting its parameters may be performed.

    Note

    When parameters are adjusted, only the parameters of the DTS instance are modified. The parameters in the database are not modified. The parameters that may be modified include but are not limited to those described in Modify instance parameters.

Billing

Migration Type

Link configuration cost

Data transfer cost

Schema migration and full data migration

Free of charge.

This example is free of charge.

Incremental data migration

Charged. For more information, see Billing overview.

SQL operations supported for incremental migration

Operation Type

SQL Operation

DML

INSERT, UPDATE, DELETE

DDL

ADD COLUMN, DROP COLUMN

Database account permissions

Database

Required permissions

Creation and authorization method

Source PolarDB for PostgreSQL cluster

A privileged account that is the owner of the database to be migrated.

Create a database account and Database management.

Destination SelectDB instance

Cluster access permissions (Usage_priv) and database read/write permissions (Select_priv, Load_priv, Alter_priv, Create_priv, and Drop_priv).

Cluster permission management and Basic permission management.

Procedure

  1. Use one of the following methods to go to the Data Migration page and select the region in which the data migration instance resides.

    DTS console

    1. Log on to the DTS console.

    2. In the left-side navigation pane, click Data Migration.

    3. In the upper-left corner of the page, select the region in which the data migration instance resides.

    DMS console

    Note

    The actual operation may vary based on the mode and layout of the DMS console. For more information, see Simple mode and Customize the layout and style of the DMS console.

    1. Log on to the DMS console.

    2. In the top navigation bar, move the pointer over Data + AI > DTS (DTS) > Data Migration.

    3. From the drop-down list to the right of Data Migration Tasks, select the region in which the data synchronization instance resides.

  2. Click Create Task to go to the task configuration page.

  3. Configure the source and destination databases. The following table describes the parameters.

    Category

    Configuration

    Description

    None

    Task Name

    The name of the DTS task. DTS automatically generates a task name. We recommend that you specify a descriptive name that makes it easy to identify the task. You do not need to specify a unique task name.

    Source Database

    Select Existing Connection

    • If you use a database instance that is registered with DTS, select the instance from the drop-down list. DTS automatically populates the following database parameters for the instance. For more information, see Manage database connections.

      Note

      In the DMS console, you can select the database instance from the Select a DMS database instance drop-down list.

    • If you fail to register the instance with DTS, or you do not need to use the instance that is registered with DTS, you must configure the following database information.

    Database Type

    Select PolarDB for PostgreSQL.

    Access Method

    Select Alibaba Cloud Instance.

    Instance Region

    Select the region where the source PolarDB for PostgreSQL cluster resides.

    Replicate Data Across Alibaba Cloud Accounts

    In this example, a database instance of the current Alibaba Cloud account is used. Select No.

    Instance ID

    Select the ID of the source PolarDB for PostgreSQL cluster.

    Database Name

    Enter the name of the database that contains the objects to be migrated in the source PolarDB for PostgreSQL cluster.

    Database Account

    Enter the database account of the source PolarDB for PostgreSQL cluster. For information about the required permissions, see Database account permissions.

    Database Password

    The password that is used to access the database.

    Destination Database

    Select Existing Connection

    • If you use a database instance that is registered with DTS, select the instance from the drop-down list. DTS automatically populates the following database parameters for the instance. For more information, see Manage database connections.

      Note

      In the DMS console, you can select the database instance from the Select a DMS database instance drop-down list.

    • If you fail to register the instance with DTS, or you do not need to use the instance that is registered with DTS, you must configure the following database information.

    Database Type

    Select SelectDB.

    Access Method

    Select Alibaba Cloud Instance.

    Instance Region

    Select the region where the destination SelectDB instance resides.

    Replicate Data Across Alibaba Cloud Accounts

    In this example, a database instance of the current Alibaba Cloud account is used. Select No.

    Instance ID

    Select the ID of the destination SelectDB instance.

    Database Account

    Enter the database account of the destination SelectDB instance. For information about the required permissions, see Database account permissions.

    Database Password

    The password that is used to access the database instance.

  4. In the lower part of the page, click Test Connectivity and Proceed.

    Note

    Make sure that the CIDR blocks of DTS servers can be automatically or manually added to the security settings of the source and destination databases to allow access from DTS servers. For more information, see Add DTS server IP addresses to a whitelist.

  5. Configure the objects to be migrated.

    1. On the Configure Objects page, configure the objects that you want to migrate.

      Configuration

      Description

      Migration Types

      • If you only need to perform a full data migration, select Schema Migration and Full Data Migration.

      • To perform a migration without service interruption, select Schema Migration, Full Data Migration, and Incremental Data Migration.

      Important
      • Data types are converted when data is migrated from a PolarDB for PostgreSQL cluster to a SelectDB instance. If you do not select Schema Migration, you must create tables with the Unique or Duplicate data model and the corresponding schemas in the destination SelectDB instance beforehand. For more information, see Data type mappings, Information about additional columns, and Data models.

      • If you do not select Incremental Data Migration, do not write new data to the source instance during the data migration. This ensures data consistency.

      Processing Mode of Conflicting Tables

      • Precheck and Report Errors: DTS checks whether tables with the same name exist in the destination database. If no tables with the same name exist, the task passes this check. If tables with the same name exist, the precheck fails and the data migration task does not start.

        Note

        If you cannot delete or rename the table in the destination database, you can map the table to a different name. For more information, see Map object names.

      • Ignore Errors and Proceed: DTS skips the check for tables with the same name in the destination database.

        Warning

        If you select Ignore Errors and Proceed, data inconsistency may occur and pose risks to your business. For example:

        • If the table schemas are consistent and a record in the destination database has the same primary key value as a record in the source database, the record from the source database overwrites the record in the destination database.

        • If the table schemas are inconsistent, only some columns of data may be migrated or the migration may fail. Use this option with caution.

      Capitalization of Object Names in Destination Instance

      The capitalization of database names, table names, and column names in the destination instance. By default, DTS default policy is selected. You can select other options to make sure that the capitalization of object names is consistent with that of the source or destination database. For more information, see Specify the capitalization of object names in the destination instance.

      Source Objects

      Select one or more objects from the Source Objects section. Click the 向右小箭头 icon to add the objects to the Selected Objects section.

      Note

      The granularity for selecting migration objects can be schema, table, or column.

      Selected Objects

      • To specify the name of an object to be migrated in the destination instance or specify the object to receive data in the destination instance, right-click the object in the Selected Objects section. For more information, see Map object names.

      • To remove one or more objects that are selected for migration, click the objects in the Selected Objects section and then click the image icon to move the objects to the Source Objects section.

      • If you selected Schema Migration for Migration Types and the migration object granularity is table, you must set the number of buckets (the bucket_count parameter). To do this, right-click the table in the Selected Objects section. In the Parameter Settings area, set Enable Parameter Settings to Yes, set Value as needed, and then click OK.

      Note
      • If you use the object name mapping feature to rename an object, other objects that depend on the object may fail to be migrated.

      • To specify WHERE conditions to filter data, right-click a table in the Selected Objects section. In the dialog box that appears, specify the conditions. For more information, see Specify filter conditions.

      • To select the SQL operations for incremental migration, right-click an object in the Selected Objects section. In the dialog box that appears, select the SQL operations that you want to migrate.

    2. Click Next: Advanced Settings to configure advanced settings.

      Configuration

      Description

      Dedicated Cluster for Task Scheduling

      By default, DTS schedules the data migration task to the shared cluster if you do not specify a dedicated cluster. If you want to improve the stability of data migration tasks, purchase a dedicated cluster. For more information, see What is a DTS dedicated cluster.

      Retry Time for Failed Connections

      The retry time range for failed connections. If the source or destination database fails to be connected after the data migration task is started, DTS immediately retries a connection within the retry time range. Valid values: 10 to 1,440. Unit: minutes. Default value: 720. We recommend that you set the parameter to a value greater than 30. If DTS is reconnected to the source and destination databases within the specified retry time range, DTS resumes the data migration task. Otherwise, the data migration task fails.

      Note
      • If you specify different retry time ranges for multiple data migration tasks that share the same source or destination database, the value that is specified later takes precedence.

      • When DTS retries a connection, you are charged for the DTS instance. We recommend that you specify the retry time range based on your business requirements. You can also release the DTS instance at the earliest opportunity after the source database and destination instance are released.

      Retry Time for Other Issues

      The retry time range for other issues. For example, if DDL or DML operations fail to be performed after the data migration task is started, DTS immediately retries the operations within the retry time range. Valid values: 1 to 1440. Unit: minutes. Default value: 10. We recommend that you set the parameter to a value greater than 10. If the failed operations are successfully performed within the specified retry time range, DTS resumes the data migration task. Otherwise, the data migration task fails.

      Important

      The value of the Retry Time for Other Issues parameter must be smaller than the value of the Retry Time for Failed Connections parameter.

      Enable Throttling for Full Data Migration

      Specifies whether to enable throttling for full data migration. During full data migration, DTS uses the read and write resources of the source and destination databases. This may increase the loads of the database servers. You can enable throttling for full data migration based on your business requirements. To configure throttling, you must configure the Queries per second (QPS) to the source database, RPS of Full Data Migration, and Data migration speed for full migration (MB/s) parameters. This reduces the loads of the destination database server.

      Note

      You can configure this parameter only if you select Full Data Migration for the Migration Types parameter.

      Enable Throttling for Incremental Data Migration

      Specifies whether to enable throttling for incremental data migration. To configure throttling, you must configure the RPS of Incremental Data Migration and Data migration speed for incremental migration (MB/s) parameters. This reduces the loads of the destination database server.

      Note

      You can configure this parameter only if you select Incremental Data Migration for the Migration Types parameter.

      Environment Tag

      You can select an environment tag to identify the instance. This step is optional.

      Configure ETL

      Specifies whether to enable the extract, transform, and load (ETL) feature. For more information, see What is ETL? Valid values:

      Monitoring and Alerting

      Specifies whether to configure alerting for the data migration task. If the task fails or the migration latency exceeds the specified threshold, the alert contacts receive notifications. Valid values:

    3. Optional: After you complete the preceding configurations, click Next: Configure Database and Table Fields to set the Primary Key Column, Distribution Key, and Engine for the tables to be migrated to the destination database.

      Note
      • This step is available only if you selected Schema Migration when you configured the migration objects. To make changes, you can set Definition Status to All.

      • The Primary Key Column can be a composite primary key that consists of multiple columns. You must select one or more columns from the Primary Key Column to use as the Distribution Key.

      • For tables that have neither a primary key nor a UNIQUE constraint, you must set Engine to duplicate. Otherwise, the migration may fail or data may be lost.

  6. Save the task settings and run a precheck.

    • To view the parameters to be specified when you call the relevant API operation to configure the DTS task, move the pointer over Next: Save Task Settings and Precheck and click Preview OpenAPI parameters.

    • If you do not need to view or have viewed the parameters, click Next: Save Task Settings and Precheck in the lower part of the page.

    Note
    • Before you can start the data migration task, DTS performs a precheck. You can start the data migration task only after the task passes the precheck.

    • If the task fails to pass the precheck, click View Details next to each failed item. After you analyze the causes based on the check results, troubleshoot the issues. Then, run a precheck again.

    • If an alert is triggered for an item during the precheck:

      • If an alert item cannot be ignored, click View Details next to the failed item and troubleshoot the issues. Then, run a precheck again.

      • If the alert item can be ignored, click Confirm Alert Details. In the View Details dialog box, click Ignore. In the message that appears, click OK. Then, click Precheck Again to run a precheck again. If you ignore the alert item, data inconsistency may occur, and your business may be exposed to potential risks.

  7. Purchase the instance.

    1. Wait until Success Rate becomes 100%. Then, click Next: Purchase Instance.

    2. On the Purchase Instance page, configure the Instance Class parameter for the data migration instance. The following table describes the parameters.

      Section

      Parameter

      Description

      New Instance Class

      Resource Group

      The resource group to which the data migration instance belongs. Default value: default resource group. For more information, see What is Resource Management?

      Instance Class

      DTS provides instance classes that vary in the migration speed. You can select an instance class based on your business scenario. For more information, see Instance classes of data migration instances.

    3. Read and agree to Data Transmission Service (Pay-as-you-go) Service Terms by selecting the check box.

    4. Click Buy and Start. In the message that appears, click OK.

      You can view the progress of the task on the Data Migration page.

      Note
      • If a data migration task cannot be used to migrate incremental data, the task automatically stops. The Completed is displayed in the Status section.

      • If a data migration task can be used to migrate incremental data, the task does not automatically stop. The incremental data migration task never stops or completes. The Running is displayed in the Status section.

Data type mappings

Category

Data type in PolarDB for PostgreSQL

Data type in SelectDB

NUMERIC

SMALLINT

SMALLINT

INTEGER

INT

BIGINT

BIGINT

DECIMAL

DECIMAL

NUMERIC

DECIMAL

REAL

DOUBLE

DOUBLE

DOUBLE

SMALLSERIAL

SMALLINT

SERIAL

INT

BIGSERIAL

BIGINT

MONETARY

MONEY

STRING

CHARACTER

  • CHAR(n)

  • VARCHAR(n)

VARCHAR

Important

To prevent data loss, data of the CHAR(n) and VARCHAR(n) types is converted to VARCHAR(4*n) after being migrated to a SelectDB instance.

  • If no data length is specified, the default value of SelectDB, VARCHAR(65533), is used.

  • If the data length exceeds 65533, the data is converted to STRING after being migrated to SelectDB.

TEXT

STRING

BINARY

BYTEA

STRING

DATE AND TIME

TIMESTAMP [(P)] [WITHOUT TIME ZONE]

DATETIMEV2

TIMESTAMP [(P)] WITH TIME ZONE

DATETIMEV2

DATE

DATEV2

TIME [(P)] [WITHOUT TIME ZONE]

VARCHAR(50)

TIME [(P)] WITH TIME ZONE

VARCHAR(50)

INTERVAL [FIELDS] [(P)]

STRING

BOOLEAN

BOOLEAN

BOOLEAN

GEOMETRIC

  • POINT

  • LINE

  • LSEG

  • BOX

  • PATH

  • POLYGON

  • CIRCLE

STRING

NETWORK ADDRESS

  • CIDR

  • INET

  • MACADDR

  • MACADDR8

STRING

TEXT SEARCH

TSVECTOR

STRING

XML

XML

STRING

JSON

JSON

JSON

Information about additional columns

Note

The following table describes the additional columns that DTS automatically adds or that you need to manually add to the destination tables that use the Duplicate model.

Name

Data type

Default value

Description

_is_deleted

Int

0

Indicates whether the data is deleted.

  • Insert: The value is 0.

  • Update: The value is 0.

  • Delete: The value is 1.

_version

Bigint

0

  • For full data migration, the value is 0.

  • For incremental data migration, the value is the timestamp in seconds from the source binary log.

_record_id

Bigint

0

  • For full data migration, the value is 0.

  • For incremental data migration, the value is the record ID of the incremental log entry. This ID uniquely identifies the log entry.

    Note

    The ID is unique and auto-incrementing.