Data Comparison (Comparing DR Items)
Comparison Scenarios
DR item comparison: You can compare DR items to check data consistency between the service database and DR database. Currently, you can compare the following items during DR:
- Object-level comparison: compares databases, events, indexes, tables, views, and triggers.
- Data-level comparison is classified into row comparison and value comparison.
- Row comparison: It helps you compare the number of rows in the tables to be synchronized. This comparison method is recommended because it is fast.
- Value comparison: It helps you check whether data in the synchronized table is consistent. The comparison process is relatively slow.
To ensure that the comparison results are valid, compare data during off-peak hours by select Start at a specified time or compare cold data that is infrequently modified.
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
- During a comparison, the comparison items are case sensitive. If one of the service or DR database is case insensitive and the other one is case sensitive, the comparison result may be inconsistent.
- If DDL operations were performed on the service database, you need to compare the objects again to ensure the accuracy of the comparison results.
- If data in the DR database is modified separately, the comparison results may be inconsistent.
- If the encoding of the service database character type is abnormal, the database driver will convert the character type to an abnormal code point during DRS disaster recovery or comparison. As a result, the values may be consistent but the bytes may be inconsistent.
- Currently, only tables with primary keys support value comparison. For tables that do not support value comparison, you can compare rows. Therefore, you can compare data by row or value based on scenarios.
- The DRS task cannot be suspended during value comparison. Otherwise, the comparison task may fail.
- To prevent resources from being occupied for a long time, DRS limits the row comparison duration. If the row comparison duration exceeds the threshold, the row comparison task stops automatically. If the service database is a relational database, the row comparison duration is limited within 60 minutes. If the service database is a non-relational database, the row comparison duration is limited within 30 minutes.
- To avoid occupying resources, the comparison results of DRS tasks can be retained for a maximum of 60 days. After 60 days, the comparison results are automatically cleared.
- For a DR task from MySQL or GaussDB(for MySQL), virtual columns in the source database do not support value comparison. During the comparison, virtual columns are filtered out.
Impact on Databases
- Object comparison: System tables of the source and destination databases are queried, occupying about 10 sessions. The database is not affected. However, if there are a large number of objects (for example, hundreds of thousands of tables), the database may be overloaded.
- Row comparison: The number of rows in the source and destination databases is queried, which occupies about 10 sessions. The SELECT COUNT statement does not affect the database. However, if a table contains a large amount of data (hundreds of millions of records), the database will be overloaded and the query results will be returned slowly.
- Value comparison: All data in the source and destination databases is queried, and each field is compared. The query pressure on the database leads to high I/O. The query speed is limited by the I/O and network bandwidth of the source and destination databases. Value comparison occupies one or two CPUs, and about 10 sessions.
Estimated Comparison Duration
- Object comparison: Generally, the comparison results are returned within several minutes based on the query performance of the source database. If the amount of data is large, the comparison may take dozens of minutes.
- Row comparison: The SELECT COUNT method is used. The query speed depends on the database performance.
- Value comparison: If the database workload is not heavy and the network is normal, the comparison speed is about 5 MB/s.
Prerequisites
- You have logged in to the DRS console.
- A DR task has been started.
Procedure
- On the Disaster Recovery Management page, click the target DR task in the Task Name/ID column.
- On the Disaster Recovery Comparison tab, compare the service and DR databases.
- Check the integrity of the database object.
Click Validate Objects. On the Object-Level Comparison tab, view the comparison result of each comparison item.
Locate a comparison item you want to view and click View Details in the Operation column.
- 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.
- To view the comparison details, locate the target comparison type and click View Results in the Operation column. On the displayed page, locate a pair of service and DR databases, and click View Details in the Operation column to view detailed comparison results.Note
- You can also view comparison details of canceled comparison tasks.
- You can sort the row comparison results displayed on the current page in ascending or descending order based on the number of rows in the source database table or the destination database table.
- If a negative number is displayed in the differences column, the number of rows in the destination database table is greater than that in the source database table. If a positive number is displayed in the differences column, the number of rows in the source database table is greater than that in the destination database table.
- Check the integrity of the database object.
Parent topic: Task Management
- Comparison Scenarios
- Constraints
- Impact on Databases
- Estimated Comparison Duration
- Prerequisites
- Procedure