Step 4: Compare Synchronization Items

Scenarios

This section describes how to compare synchronization items to check if there are any differences between source and destination databases. To minimize the impact on services and shorten the service interruption duration, the following comparison methods are provided:

When you check data consistency, compare the number of rows first. If the number of rows are inconsistent, you can then compare the data in the table to determine the inconsistent data.

Constraints

Prerequisites

Creating a Comparison Task

  1. On the Data Synchronization Management page, click the target synchronization task name in the Task Name/ID column.
  2. Click the Synchronization Comparison tab.
  3. Compare synchronization items.

    • On the Object-Level Comparison tab, check whether the comparison results of the source and destination databases are consistent. Locate a comparison item you want to view and click View Details in the Operation column.
    • On the Data-Level Comparison tab, click Create Comparison Task. In the displayed dialog box, specify Comparison Type, Comparison Time, and Object. Then, click OK.
      • Comparison Type: compares rows and values.
        • Row comparison: checks whether the source table has the same number of rows as the destination table.
          • After a task enters the incremental comparison phase, you can create a row comparison task.
        • Value comparison: checks whether the source table has the same data as the destination table.
          • After a task enters the incremental synchronization phase, you can create a value comparison task. After the full synchronization is complete, data in the source database cannot be changed. Otherwise, the comparison result will be inconsistent.

          Value comparison only applies to tables with single-column primary key or unique index. You can use row comparison for tables that do not support value comparison. Therefore, you can compare data by row or value based on scenarios.

      • Comparison Policy: DRS supports one-to-one and many-to-one comparison policies.
        • One-to-one: compares the number of rows in a table in the source database with that in the table mapped to the destination database.
        • Many-to-one: compares the number of rows in a table in the source database with that in the aggregate table mapped to the destination database.

          If you select Row Comparison for Comparison Type, the Comparison Policy option becomes available.

      • Comparison Time: You can select Start upon task creation or Start at a specified time. There is a slight difference in time between the source and destination databases during synchronization. Data inconsistency may occur. You are advised to compare migration items during off-peak hours for more accurate results.
      • Object: You can select objects to be compared based on the scenarios.
    • User comparison: Click the User Comparison tab to view the comparison results of database accounts and permissions.
      • Full synchronization tasks do not support account comparisons.
      • Only PostgreSQL to PostgreSQL synchronization supports account comparison.

  4. After the comparison creation task is submitted, the Data-Level Comparison tab is displayed. Click to refresh the list and view the comparison result of the specified comparison type.

    Value comparison only applies to tables with single-column primary key or unique index. You can use row comparison for tables that do not support value comparison. Therefore, you can compare data by row or value based on scenarios.

    If you want to view the row or value comparison details, click View Results.

    If you want to download the row comparison or value comparison result, locate a specified comparison type and click Export Report in the Operation column.

    You can also view comparison details of canceled comparison tasks.

Periodic Comparison

Periodic comparison indicates that DRS periodically compares the number of rows in the source database table with those in the destination database table and displays the comparison results.

  1. On the Data Synchronization Management page, click the target synchronization task name in the Task Name/ID column.
  2. Click the Synchronization Comparison tab.
  3. Click the Periodic Comparison tab and click Modify Comparison Policy to modify the comparison policy.
  4. In the Modify Comparison Policy dialog box, enable periodic comparison, configure the comparison frequency and time, and click Yes.

    • After periodic comparison is enabled, DRS compares the number of rows at the scheduled time. You can view the comparison results on the Data-Level Comparison tab.
    • After periodic comparison is disabled, only historical comparison results can be viewed.
    • Modifications to the comparison policy settings take effect from the next comparison and do not affect the on-going periodic comparison tasks.
    • During periodic comparison, the source and destination databases will be read. Perform the comparison during off-peak hours.
    • During periodic comparison, ultra-large tables (those with more than 100 million rows) are automatically filtered out. You can use data-level comparison to spot check such large tables. It is not recommended that these large tables be compared periodically.