This topic describes the precautions and limits when you migrate data from a PostgreSQL database, such as a self-managed PostgreSQL database and an ApsaraDB RDS for PostgreSQL database. To ensure that your data migration task runs as expected, read the precautions and limits before you configure the task.

Scenarios of migrating data from a PostgreSQL database

You can view the precautions and limits based on the following migration scenarios:

Migrate data between PostgreSQL databases

The following table describes the precautions and limits when you migrate data to a PostgreSQL database, such as a self-managed PostgreSQL database and an ApsaraDB RDS for PostgreSQL database.
Type Description
Limits on the source database
  • Bandwidth requirements: The server to which the source database belongs must have sufficient egress bandwidth. Otherwise, the data migration speed is affected.
  • The source database must have PRIMARY KEY or UNIQUE constraints and all fields must be unique. Otherwise, the destination database may contain duplicate data records.
  • If you want to migrate incremental data, you must make sure that the following requirements are met:
    • The data logging feature must be enabled.
    • Data logs are retained for at least 7 days during full data migration. You can wait until full data migration is complete, and then clear the data logs generated in the source database after the DTS task is run.
      Note To ensure data security, the DTS server stores only 50 GB of data logs or the data logs for the last 24 hours. If the limit is exceeded, the DTS server automatically clears the logs that exceed the limit.
      Warning If you clear the data logs of the source database during full data migration, the task may fail to migrate incremental data. For example, full data migration takes more than 24 hours due to the large data volume in the source database and abnormal writing in the destination database. In this case, if the data logs of the source database are cleared during full data migration, DTS cannot obtain the data logs generated 24 hours ago. Therefore, the task may fail to migrate incremental data.
  • Limits on operations:
    • During schema migration and full data migration, do not perform data definition language (DDL) operations to change the schemas of databases or tables. Otherwise, the data migration task fails.
    • If you perform only full data migration, do not write data to the source database during data migration. Otherwise, data will be inconsistent between the source and destination databases. To ensure data consistency, we recommend that you select Schema Migration, Full Data Migration, and Incremental Data Migration as the migration types.
Other limits
  • To ensure that the data migration task runs as expected, you can perform primary/secondary switchover only on an ApsaraDB RDS for PostgreSQL instance V11 during data migration. In this case, you must set the rds_failover_slot_mode parameter to sync. For more information, see Use the failover slot feature for logical subscriptions.
    Warning If you perform primary/secondary switchover on a self-managed PostgreSQL database or an ApsaraDB RDS for PostgreSQL instance of other versions, the data migration task fails.
  • A single data migration task can migrate data from only one database. To migrate data from multiple databases, you must create a data migration task for each database.
  • During incremental data migration, if you select a schema as the object to be migrated, take note of the following limits: If you create a table in the schema or run the RENAME command to rename the table, you must run the ALTER TABLE schema.table REPLICA IDENTITY FULL; command before you write data to the table.
    Note Replace the schema and table in the preceding sample command with the actual schema name and table name.
  • To ensure that the delay time of incremental data migration is accurate, DTS adds a heartbeat table named dts_postgres_heartbeat to the source database.
  • During incremental data migration, DTS creates a replication slot for the source database. The replication slot is prefixed with dts_sync_. DTS automatically clears historical replication slots every 90 minutes to reduce storage usage.
    Note If the data migration task is released or fails, DTS automatically clears the replication slot. If a primary/secondary switchover is performed on the source ApsaraDB RDS for PostgreSQL instance, you must log on to the secondary database to clear the replication slot.
    Replication slot information
  • Before you migrate data, evaluate the impact of data migration on the performance of the source and destination databases. We recommend that you migrate data during off-peak hours. During full data migration, DTS uses read and write resources of the source and destination databases. This may increase the loads of the database servers.
  • During full data migration, concurrent INSERT operations cause fragmentation in the tables of the destination database. After full data migration is complete, the tablespace of the destination database is larger than that of the source database.
  • You must make sure that the precision settings for columns of the FLOAT or DOUBLE data type meets your business requirements. DTS uses the ROUND(COLUMN,PRECISION) function to retrieve values from columns of the FLOAT or DOUBLE data type. If you do not specify a precision, DTS sets the precision for the FLOAT data type to 38 digits and the precision for the DOUBLE data type to 308 digits.
  • DTS attempts to resume data migration tasks that failed within the last seven days. Before you switch workloads to the destination instance, stop or release the data migration task. You can also run the revoke command to revoke the write permissions from the accounts that are used by DTS to access the destination instance. Otherwise, the data in the source database will overwrite the data in the destination instance after the task is resumed.
Special cases
  • If the source or destination instance is an ApsaraDB RDS for PostgreSQL instance, take note of the following limits:

    During data migration, do not modify the endpoint and zone of the ApsaraDB RDS for PostgreSQL instance. Otherwise, the data migration task fails.

Migrate data from a PostgreSQL database to a MySQL database

DTS console of the new version supports the following migration scenarios:
  • Migrate data from an ApsaraDB RDS for PostgreSQL instance to an ApsaraDB RDS for MySQL instance
  • Migrate data from a self-managed PostgreSQL database to a self-managed MySQL database
The following table describes the precautions and limits.
Type Description
Limits on the source database
  • Bandwidth requirements: The server to which the source database belongs must have sufficient egress bandwidth. Otherwise, the data migration speed is affected.
  • The source database must have PRIMARY KEY or UNIQUE constraints and all fields must be unique. Otherwise, the destination database may contain duplicate data records.
  • If you want to migrate incremental data, you must make sure that the following requirements are met:
    • The data logging feature must be enabled.
    • Data logs are retained for at least 7 days during full data migration. You can wait until full data migration is complete, and then clear the data logs generated in the source database after the DTS task is run.
      Note To ensure data security, the DTS server stores only 50 GB of data logs or the data logs for the last 24 hours. If the limit is exceeded, the DTS server automatically clears the logs that exceed the limit.
      Warning If you clear the data logs of the source database during full data migration, the task may fail to migrate incremental data. For example, full data migration takes more than 24 hours due to the large data volume in the source database and abnormal writing in the destination database. In this case, if the data logs of the source database are cleared during full data migration, DTS cannot obtain the data logs generated 24 hours ago. Therefore, the task may fail to migrate incremental data.
  • Limits on operations:
    • To ensure that the data migration task runs as expected, you can perform primary/secondary switchover only on an ApsaraDB RDS for PostgreSQL instance V11 during data migration. In this case, you must set the rds_failover_slot_mode parameter to sync. For more information, see Use the failover slot feature for logical subscriptions.
      Warning If you perform primary/secondary switchover on a self-managed PostgreSQL database or an ApsaraDB RDS for PostgreSQL instance of other versions, the data migration task fails.
    • During schema migration and full data migration, do not perform data definition language (DDL) operations to change the schemas of databases or tables. Otherwise, the data migration task fails.
    • If you perform only full data migration, do not write data to the source database during data migration. Otherwise, data will be inconsistent between the source and destination databases. To ensure data consistency, we recommend that you select Schema Migration, Full Data Migration, and Incremental Data Migration as the migration types.
Other limits
  • During incremental data migration, if you select a schema as the object to be migrated, take note of the following limits: If you create a table in the schema or run the RENAME command to rename the table, you must run the ALTER TABLE schema.table REPLICA IDENTITY FULL; command before you write data to the table.
    Note Replace the schema and table in the preceding sample command with the actual schema name and table name.
  • To ensure that the delay time of incremental data migration is accurate, DTS adds a heartbeat table named dts_postgres_heartbeat to the source database.
  • During incremental data migration, DTS creates a replication slot for the source database. The replication slot is prefixed with dts_sync_. DTS automatically clears historical replication slots every 90 minutes to reduce storage usage.
    Note If the data migration task is released or fails, DTS automatically clears the replication slot. If a primary/secondary switchover is performed on the source ApsaraDB RDS for PostgreSQL instance, you must log on to the secondary database to clear the replication slot.
    Replication slot information
  • A single data migration task can migrate data from only one database. To migrate data from multiple databases, you must create a data migration task for each database.
  • Before you migrate data, evaluate the impact of data migration on the performance of the source and destination databases. We recommend that you migrate data during off-peak hours. During full data migration, DTS uses read and write resources of the source and destination databases. This may increase the loads of the database servers.
  • During full data migration, concurrent INSERT operations cause fragmentation in the tables of the destination database. After full data migration is complete, the tablespace of the destination database is larger than that of the source database.
  • You must make sure that the precision settings for columns of the FLOAT or DOUBLE data type meets your business requirements. DTS uses the ROUND(COLUMN,PRECISION) function to retrieve values from columns of the FLOAT or DOUBLE data type. If you do not specify a precision, DTS sets the precision for the FLOAT data type to 38 digits and the precision for the DOUBLE data type to 308 digits.
  • DTS attempts to resume data migration tasks that failed within the last seven days. Before you switch workloads to the destination instance, stop or release the data migration task. You can also run the revoke command to revoke the write permissions from the accounts that are used by DTS to access the destination instance. Otherwise, the data in the source database will overwrite the data in the destination instance after the task is resumed.
Special cases
  • If the source instance is an ApsaraDB RDS for PostgreSQL instance, take note of the following limits:

    During data migration, do not modify the endpoint and zone of the ApsaraDB RDS for PostgreSQL instance. Otherwise, the data migration task fails.

  • If the destination instance is an ApsaraDB RDS for MySQL instance, take note of the following limits:

    DTS automatically creates a destination database in the ApsaraDB RDS for MySQL instance. However, if the name of the source database is invalid, you must manually create a database in the ApsaraDB RDS for MySQL instance before you configure the data migration task. For more information, see Create a database on an ApsaraDB RDS for MySQL instance.

Migrate data from a self-managed PostgreSQL database to a PolarDB O Edition cluster

The following table describes the precautions and limits.
Type Description
Limits on the source database
  • Bandwidth requirements: The server to which the source database belongs must have sufficient egress bandwidth. Otherwise, the data migration speed is affected.
  • The source database must have PRIMARY KEY or UNIQUE constraints and all fields must be unique. Otherwise, the destination database may contain duplicate data records.
  • If you want to migrate incremental data, you must make sure that the following requirements are met:
    • The data logging feature must be enabled.
    • Data logs are retained for at least 7 days during full data migration. You can wait until full data migration is complete, and then clear the data logs generated in the source database after the DTS task is run.
      Note To ensure data security, the DTS server stores only 50 GB of data logs or the data logs for the last 24 hours. If the limit is exceeded, the DTS server automatically clears the logs that exceed the limit.
      Warning If you clear the data logs of the source database during full data migration, the task may fail to migrate incremental data. For example, full data migration takes more than 24 hours due to the large data volume in the source database and abnormal writing in the destination database. In this case, if the data logs of the source database are cleared during full data migration, DTS cannot obtain the data logs generated 24 hours ago. Therefore, the task may fail to migrate incremental data.
  • Limits on operations:
    • If you perform primary/secondary switchover on a self-managed PostgreSQL database, the data migration task fails.
    • During schema migration and full data migration, do not perform data definition language (DDL) operations to change the schemas of databases or tables. Otherwise, the data migration task fails.
    • If you perform only full data migration, do not write data to the source database during data migration. Otherwise, data will be inconsistent between the source and destination databases. To ensure data consistency, we recommend that you select Schema Migration, Full Data Migration, and Incremental Data Migration as the migration types.
Other limits
  • Schema migration is not supported. Before you configure a data migration task, you must create databases and tables in the destination instance.
  • During incremental data migration, if you select a schema as the object to be migrated, take note of the following limits: If you create a table in the schema or run the RENAME command to rename the table, you must run the ALTER TABLE schema.table REPLICA IDENTITY FULL; command before you write data to the table.
    Note Replace the schema and table in the preceding sample command with the actual schema name and table name.
  • To ensure that the delay time of incremental data migration is accurate, DTS adds a heartbeat table named dts_postgres_heartbeat to the source database.
  • During incremental data migration, DTS creates a replication slot for the source database. The replication slot is prefixed with dts_sync_. DTS automatically clears historical replication slots every 90 minutes to reduce storage usage.
    Note If the data migration task is released or fails, DTS automatically clears the replication slot. If a primary/secondary switchover is performed on the source ApsaraDB RDS for PostgreSQL instance, you must log on to the secondary database to clear the replication slot.
    Replication slot information
  • A single data migration task can migrate data from only one database. To migrate data from multiple databases, you must create a data migration task for each database.
  • Before you migrate data, evaluate the impact of data migration on the performance of the source and destination databases. We recommend that you migrate data during off-peak hours. During full data migration, DTS uses read and write resources of the source and destination databases. This may increase the loads of the database servers.
  • During full data migration, concurrent INSERT operations cause fragmentation in the tables of the destination database. After full data migration is complete, the tablespace of the destination database is larger than that of the source database.
  • You must make sure that the precision settings for columns of the FLOAT or DOUBLE data type meets your business requirements. DTS uses the ROUND(COLUMN,PRECISION) function to retrieve values from columns of the FLOAT or DOUBLE data type. If you do not specify a precision, DTS sets the precision for the FLOAT data type to 38 digits and the precision for the DOUBLE data type to 308 digits.
  • DTS attempts to resume data migration tasks that failed within the last seven days. Before you switch workloads to the destination instance, stop or release the data migration task. You can also run the revoke command to revoke the write permissions from the accounts that are used by DTS to access the destination instance. Otherwise, the data in the source database will overwrite the data in the destination instance after the task is resumed.