A database replication compression method, system, device, product and medium
By decomposing and reordering database task instructions, the problems of real-time performance and resource consumption in high-concurrency scenarios of existing database replication methods are solved, and efficient database replication is achieved.
Patent Information
- Application Number
- CN202511376403.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-25
- Publication Date
- 2025-12-30
- Estimated Expiration
- 2045-09-25
AI Technical Summary
Existing database replication methods struggle to meet millisecond-level real-time requirements in high-concurrency business scenarios, and snapshot-based replication methods consume significant storage and computing resources, making them unsuitable for dynamically changing business data scenarios.
By breaking down and logically analyzing task instructions, simple and direct data processing is performed on different instruction combinations. Combined with reordering technology, efficient database replication is achieved.
It saves computing resources, improves database operating efficiency, and meets the real-time requirements of high-concurrency business scenarios.
Smart Images

Figure CN120849518B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of database technology, and in particular to a compression method, system, device, product, and medium for database replication. Background Technology
[0002] In the digital age, databases, as the core carrier of data storage and management, have become the cornerstone of stable operation in critical sectors such as finance, e-commerce, and government, thanks to their high availability, data consistency, and disaster recovery capabilities. Database replication technology, as a core means of achieving these goals, effectively avoids data loss due to single points of failure by synchronizing data between the primary database and slave databases or multiple replica nodes. It also supports architectural designs such as read / write separation and load balancing, meeting the high concurrency and low latency requirements of business data access.
[0003] Currently, mainstream database replication methods are mainly divided into two categories: log-based incremental replication and snapshot-based full and incremental replication. Log-based replication achieves incremental synchronization by transmitting transaction logs generated by the master database. While this ensures high real-time performance, in high-concurrency business scenarios, even incremental logs experience a surge in data volume with transaction frequency. Transmitting large amounts of raw log data not only consumes valuable network bandwidth but may also cause delays in master-slave node data synchronization due to network latency, making it difficult to meet millisecond-level real-time requirements. Snapshot-based replication, on the other hand, achieves data synchronization by periodically generating full or incremental snapshots of the database. While this reduces log transmission volume, the long snapshot generation intervals and large file sizes result in poor real-time performance and consume significant storage and computing resources, making it difficult to adapt to dynamically changing business data scenarios. Summary of the Invention
[0004] This invention aims to at least solve one of the technical problems existing in related technologies. To this end, this invention provides a compression method, system, device, product, and medium for database replication, enabling efficient and low-space-occupancy data replication of databases.
[0005] This invention provides a compression method for database replication, comprising:
[0006] S1: Determine the target database, input task instructions, break down the task instructions to obtain multiple starting task instructions and final task instructions, and input the starting task instructions and final task instructions into the target database;
[0007] S2: Parse the start task instruction and the end task instruction, and make a judgment on the start task instruction and the end task instruction;
[0008] When the initial task instruction is insertion, the initial operation evaluation is skipped, and the final operation evaluation is performed. The insertion operation output is obtained based on the final task instruction and the final operation evaluation.
[0009] When the initial task instruction is update, determine the final task instruction. When the final task instruction is delete, perform an initial operation evaluation, skip the final operation evaluation, and obtain the first update operation output based on the initial operation evaluation and the final task instruction.
[0010] When the initial task instruction is update and the final task instruction is update, perform initial operation evaluation and final operation evaluation, and obtain the second update operation output based on the initial operation evaluation, final operation evaluation and final task instruction;
[0011] After all the starting and ending task instructions have been evaluated, proceed to step S3;
[0012] S3: Obtain intermediate operation data, reorder the intermediate operation data to obtain target intermediate operation data, update the target database based on the target intermediate operation data, insert operation output, first update operation output and second update operation output to obtain the updated database, thereby completing the database copy operation.
[0013] According to a database replication compression method provided by the present invention, in step S1, the target database includes multiple data rows.
[0014] According to a database replication compression method provided by the present invention, in step S2, when the final task instruction is deletion, the final operation evaluation is not performed, and the insertion operation output is not to replicate.
[0015] When the final task instruction is to update, the final operation evaluation is performed by determining whether the final updated data meets the replication conditions. When the final updated data meets the replication conditions, the output of the insertion operation is to output the final row image.
[0016] When the final updated data does not meet the replication conditions, the output of the insertion operation is "do not replicate".
[0017] According to a database replication compression method provided by the present invention, in step S2, when the final task instruction is deletion, the initial operation is evaluated by determining whether the initial update data meets the replication conditions. When the initial update data meets the replication conditions, the first update operation output is the deleted row data.
[0018] When the initial update data does not meet the replication conditions, the first update operation outputs "do not replicate".
[0019] According to a database replication compression method provided by the present invention, in step S2, when the initial task instruction is update and the final task instruction is update, the initial operation is evaluated by determining whether the initial update data meets the replication conditions, and the final operation is evaluated by determining whether the final update data meets the replication conditions. When the initial update data meets the replication conditions and the final update data meets the replication conditions, the second update operation output is to delete the initial row image, output the final row image and update the data primary key.
[0020] When the initial update data meets the replication conditions, but the final update data does not meet the replication conditions, the output of the second update operation is to delete row data;
[0021] When the initial update data does not meet the replication conditions, but the final update data does meet the replication conditions, the output of the second update operation is to output the final row image;
[0022] When the initial update data does not meet the replication conditions, and the final update data does not meet the replication conditions, the output of the second update operation is to not perform replication.
[0023] According to a database replication compression method provided by the present invention, in step S3, intermediate operation data arranged in the order of first insertion list, second insertion list, first update list, and second update list are obtained; the intermediate operation data is reordered to obtain target intermediate operation data arranged in the order of first insertion list, first update list, second insertion list, and second update list; and the target database is updated according to the target intermediate operation data, insertion operation output, first update operation output, and second update operation output to obtain the updated database.
[0024] The present invention also provides a compression system for database replication, comprising:
[0025] Instruction input module: used to determine the target database, input task instructions, break down the task instructions to obtain multiple starting task instructions and final task instructions, and input the starting task instructions and final task instructions into the target database;
[0026] Task instruction judgment module: used to parse the start task instruction and the end task instruction, and to judge the start task instruction and the end task instruction;
[0027] When the initial task instruction is insertion, the initial operation evaluation is skipped, and the final operation evaluation is performed. The insertion operation output is obtained based on the final task instruction and the final operation evaluation.
[0028] When the initial task instruction is update, determine the final task instruction. When the final task instruction is delete, perform an initial operation evaluation, skip the final operation evaluation, and obtain the first update operation output based on the initial operation evaluation and the final task instruction.
[0029] When the initial task instruction is update and the final task instruction is update, perform initial operation evaluation and final operation evaluation, and obtain the second update operation output based on the initial operation evaluation, final operation evaluation and final task instruction;
[0030] After all the starting and ending task instructions have been evaluated, proceed to step S3;
[0031] The database update module is used to obtain intermediate operation data, reorder the intermediate operation data to obtain the target intermediate operation data, and update the target database based on the target intermediate operation data, the insert operation output, the first update operation output, and the second update operation output to obtain the updated database, thereby completing the database copying operation.
[0032] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of a database replication compression method as described in any of the above embodiments.
[0033] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of a database replication compression method as described in any of the above.
[0034] The present invention also provides a computer program product comprising a computer program stored on a non-transitory computer-readable storage medium, the computer program comprising program instructions, which, when executed by a computer, enable the computer to perform the steps of any of the above-described database replication compression methods.
[0035] The above-described one or more technical solutions in the embodiments of the present invention have at least one of the following technical effects:
[0036] This invention provides a compression method, system, device, product, and medium for database replication. By decomposing and logically analyzing task instructions, it provides a simpler and more direct data processing method for different instruction combinations based on the final effect achieved by the instructions, rather than mechanically executing and evaluating the instructions step by step. This effectively saves computing resources. Furthermore, through reordering, the transaction update list in the target database only needs to be updated once to complete the database replication, thereby improving the database's operational efficiency.
[0037] Additional aspects and advantages of the invention will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention. Attached Figure Description
[0038] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0039] Figure 1 This is a flowchart illustrating a database replication compression method provided by the present invention.
[0040] Figure 2 This is a schematic diagram of the structure of a database replication compression system provided by the present invention.
[0041] Figure 3 This is a schematic diagram of the structure of a database replication compression device provided by the present invention.
[0042] Figure label:
[0043] 100. Instruction input module; 200. Task instruction judgment module; 300. Database update module; 810. Processor; 820. Communication interface; 830. Memory; 840. Communication bus. Detailed Implementation
[0044] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. Based on the embodiments of this invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this invention. The following embodiments are used to illustrate this invention but cannot be used to limit the scope of this invention.
[0045] In the description of the embodiments of the present invention, it should be noted that the terms "first", "second" and "third" are used for descriptive purposes only and should not be construed as indicating or implying relative importance.
[0046] In the description of the embodiments of the present invention, it should be noted that, unless otherwise explicitly specified and limited, the terms "connected" and "linked" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral connection; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium. Those skilled in the art can understand the specific meaning of the above terms in the embodiments of the present invention based on the specific circumstances.
[0047] In the description of this specification, the references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., refer to specific features, structures, materials, or characteristics described in connection with that embodiment or example, which are included in at least one embodiment or example of the present invention. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples. Moreover, without contradiction, those skilled in the art can combine and integrate the different embodiments or examples described in this specification, as well as the features of different embodiments or examples.
[0048] The following is combined Figures 1 to 3 Specific embodiments of the present invention are described below. Figure 1 A flowchart illustrating a database replication compression method provided by the present invention specifically includes:
[0049] S1 determines the target database, inputs task instructions, breaks down the task instructions to obtain multiple starting task instructions and final task instructions, and inputs the starting task instructions and final task instructions into the target database.
[0050] Furthermore, the purpose of this stage is to break down the task instructions to obtain the starting task instructions and the final task instructions and input them into the target database. Specifically, in step S1, the target database includes multiple data rows.
[0051] The specific implementation method for the above steps in this embodiment is as follows:
[0052] First, a target database needs to be selected, with data stored in rows. Next, the user needs to input task instructions related to data replication. Since these instructions repeatedly perform insert, update, and delete operations, some unnecessary intermediate steps are omitted, such as inserting and then deleting the same data, or operating on data outside the scope of the replication instructions. The task instructions are then broken down into two parts based on the operations required: the starting instruction and the final instruction. The starting instruction includes insert and update operations, while the final instruction includes delete and update operations. These are input into the target database. The starting instruction applies to the data at the beginning of the replication task, and the final instruction applies to the data after the starting instruction has been executed. There are multiple starting and final instructions, each with a paired final instruction. Each pair of starting and final instructions applies to a single data row.
[0053] S2: Parse the start task instruction and the end task instruction, and make a judgment on the start task instruction and the end task instruction;
[0054] When the initial task instruction is insertion, the initial operation evaluation is skipped, and the final operation evaluation is performed. The insertion operation output is obtained based on the final task instruction and the final operation evaluation.
[0055] Furthermore, the objective of this stage is to obtain the insertion operation output based on the final task instruction and the final operation evaluation when the initial task instruction is insertion. Specifically, in step S2, when the final task instruction is deletion, the final operation evaluation is to not perform evaluation, and the insertion operation output is to not perform copying.
[0056] When the final task instruction is to update, the final operation evaluation is performed by determining whether the final updated data meets the replication conditions. When the final updated data meets the replication conditions, the output of the insertion operation is to output the final row image.
[0057] When the final updated data does not meet the replication conditions, the output of the insertion operation is "do not replicate".
[0058] The specific implementation method for the above steps in this embodiment is as follows:
[0059] First, the start and end task instructions need to be parsed and evaluated. If the start task instruction is "insert," then different operations need to be performed based on the end task instruction. Here, since insertion does not require data to meet the copying conditions, the initial operation evaluation can be skipped. Next, when the end task instruction is "delete," since deletion also does not require data evaluation, it can be skipped. Furthermore, because the end task instruction is deletion, inserting followed by deletion results in no operation being performed on the data. Therefore, the output of the insertion operation is "no copying," meaning no operation is performed.
[0060] When the final task instruction is "update," the update requires checking if the data meets the replication conditions. Therefore, it's necessary to determine if the data to be updated by the final task instruction—that is, the final updated data obtained after the insert operation—meets the replication conditions. If the final updated data meets the replication conditions, the insert operation output is the final row image. This final row image is the image of the row data obtained after executing the final task instruction's update and the corresponding primary key. The final updated data is the data that needs to be processed by the final task instruction after executing the initial task instruction. Conversely, if the final updated data does not meet the replication conditions, it cannot be updated. Therefore, the insert operation output is "no replication," meaning no operation is performed. This avoids copying invalid or non-compliant data. In this embodiment, the replication conditions can be determined by whether the data is within a predetermined range. If it exceeds this range, it indicates that the replication conditions are not met.
[0061] When the initial task instruction is update, determine the final task instruction. When the final task instruction is delete, perform an initial operation evaluation, skip the final operation evaluation, and obtain the first update operation output based on the initial operation evaluation and the final task instruction.
[0062] Furthermore, the purpose of this stage is to determine the final task instruction and perform an initial operation evaluation, skipping the final operation evaluation to obtain the first update operation output. Specifically, in step S2, when the final task instruction is deletion, the initial operation evaluation is performed by determining whether the initial update data meets the replication conditions. When the initial update data meets the replication conditions, the first update operation output is the deleted row data.
[0063] When the initial update data does not meet the replication conditions, the first update operation outputs "do not replicate".
[0064] The specific implementation method for the above steps in this embodiment is as follows:
[0065] First, the starting task instruction needs to be determined. If the starting task instruction is update and the final task instruction is not update, the final task instruction is determined. If the final task instruction is delete, the starting update data needs to be evaluated to determine if it meets the replication conditions. If it meets the replication conditions, the first update operation output is to delete the row data, meaning it is required to delete the row data according to the final task instruction. Here, the starting update data is the data for which the starting task instruction needs to be executed. When the starting update data does not meet the replication conditions, since it does not meet the replication conditions, it will not affect replication regardless of whether an operation is performed. Therefore, to save computing resources, the first update operation output is not to perform replication, meaning no operation is performed. As for the final operation evaluation, since the final task instruction is not update (it is deletion), deletion does not require evaluation. Therefore, to save computing resources, the final operation evaluation needs to be skipped.
[0066] When the initial task instruction is update and the final task instruction is update, perform initial operation evaluation and final operation evaluation, and obtain the second update operation output based on the initial operation evaluation, final operation evaluation and final task instruction;
[0067] Furthermore, the purpose of this stage is to perform initial operation evaluation and final operation evaluation to obtain the second update operation output. Specifically, in step S2, when the initial task instruction is update and the final task instruction is update, the initial operation evaluation is performed by determining whether the initial update data meets the replication conditions, and the final operation evaluation is performed by determining whether the final update data meets the replication conditions. When the initial update data meets the replication conditions and the final update data meets the replication conditions, the second update operation output is to delete the initial row image, output the final row image, and update the data primary key.
[0068] When the initial update data meets the replication conditions, but the final update data does not meet the replication conditions, the output of the second update operation is to delete row data;
[0069] When the initial update data does not meet the replication conditions, but the final update data does meet the replication conditions, the output of the second update operation is to output the final row image;
[0070] When the initial update data does not meet the replication conditions, and the final update data does not meet the replication conditions, the output of the second update operation is to not perform replication.
[0071] The specific implementation method for the above steps in this embodiment is as follows:
[0072] Normally, the scenario where the initial task instruction is update and the final task instruction is insert does not exist and is therefore not considered. When both the initial and final task instructions are update, since the update requires determining whether the data meets the replication conditions, both the final and initial operation evaluations are necessary. Specifically, the initial operation evaluation is performed by determining whether the initial update data meets the replication conditions, and the final operation evaluation is performed by determining whether the final update data after the first update meets the replication conditions. When both the initial and final update data meet the replication conditions, to avoid conflicts between the two updates, the second update operation deletes the initial row image. The initial row image is the image of the row data obtained after executing the initial task instruction and the corresponding primary key. Additionally, the final row image needs to be output. Since the final row image includes the image of the primary key corresponding to the updated row data, the primary key update is completed. Furthermore, if the primary key corresponding to the data in the initial and final row images has not changed, the initial row image can be left undeleted, and only the final row image can be read.
[0073] When the initial update data meets the replication conditions, but the final update data does not, the second update operation outputs deleted row data to ensure that non-compliant data is not retained. When the initial update data does not meet the replication conditions, but the final update data does, the second update operation outputs the final row image. When neither the initial nor the final update data meets the replication conditions, the second update operation outputs no replication, meaning no operation is performed. After all initial and final task instructions have been evaluated, step S3 can be initiated.
[0074] S3: Obtain intermediate operation data, reorder the intermediate operation data to obtain target intermediate operation data, update the target database based on the target intermediate operation data, insert operation output, first update operation output and second update operation output to obtain the updated database, thereby completing the database copy operation.
[0075] Furthermore, the purpose of this stage is to reorder the intermediate operation data to update the target database, thereby obtaining an updated database and completing the database replication operation. Specifically, in step S3, intermediate operation data arranged in the order of first insertion list, second insertion list, first update list, and second update list are obtained. This intermediate operation data is reordered to obtain the target intermediate operation data arranged in the order of first insertion list, first update list, second insertion list, and second update list. The target database is then updated based on the target intermediate operation data, the insertion operation output, the first update operation output, and the second update operation output to obtain the updated database.
[0076] The specific implementation method of this embodiment for the above steps is as follows:
[0077] Traditional database technology involves sequentially performing copy operations on all rows in the database that require such operations during replication, and then determining the appropriate actions. This process yields intermediate operation data that records the operations performed on all rows in both the copied and post-replication parts of the database. Specifically, a first insertion list records insertions performed at the start of each replication task, a second insertion list records insertions performed at the end of each task, a first update list records updates performed at the start of each task, and a second update list records updates performed at the end of each task. Deletion operations can also be added to the second update list. These lists are sequentially concatenated. However, this approach is inefficient because the lists related to the start and end of each task are interleaved. Therefore, matching each list with the corresponding data requires iterating through all relevant data, which is detrimental to efficiency.
[0078] To address this, the present invention reorders the intermediate operation data, resulting in target intermediate operation data arranged in the following order: first insertion list, first update list, second insertion list, and second update list. In the target intermediate operation data, since the relevant lists for the data at the start of the task and the relevant lists for the data at the end of the task are separated, each row of data at the start of the copy-related task can be mapped using both the first insertion list and the first update list. Similarly, each row of data at the end of the copy-related task can be mapped using both the second insertion list and the second update list. This allows for mapping with only one iteration, thus mapping task instructions to data in the database and facilitating the creation of task logs.
[0079] Finally, after leaving the task log, the data in the target database is operated on according to the output of the insert operation, the first update operation, and the second update operation to update the database and complete the database copying operation.
[0080] This invention can effectively save computing resources and reorder intermediate data, thereby effectively improving the operating efficiency of the database.
[0081] The following describes a database replication compression apparatus provided by the present invention. The database replication compression apparatus described below and the database replication compression method described above can be referred to in correspondence.
[0082] Figure 2 An example is a schematic diagram of the structure of a database replication compression system, such as... Figure 2 As shown, a compression method for performing a database replication as described above includes:
[0083] Instruction input module 100: used to determine the target database, input task instructions, decompose the task instructions to obtain multiple starting task instructions and final task instructions, and input the starting task instructions and final task instructions into the target database;
[0084] Task instruction judgment module 200: used to parse the start task instruction and the end task instruction, and to judge the start task instruction and the end task instruction;
[0085] When the initial task instruction is insertion, the initial operation evaluation is skipped, and the final operation evaluation is performed. The insertion operation output is obtained based on the final task instruction and the final operation evaluation.
[0086] When the initial task instruction is update, determine the final task instruction. When the final task instruction is delete, perform an initial operation evaluation, skip the final operation evaluation, and obtain the first update operation output based on the initial operation evaluation and the final task instruction.
[0087] When the initial task instruction is update and the final task instruction is update, perform initial operation evaluation and final operation evaluation, and obtain the second update operation output based on the initial operation evaluation, final operation evaluation and final task instruction;
[0088] After all the starting and ending task instructions have been evaluated, proceed to step S3;
[0089] The database update module 300 is used to obtain intermediate operation data, reorder the intermediate operation data to obtain the target intermediate operation data, and update the target database based on the target intermediate operation data, the insert operation output, the first update operation output, and the second update operation output to obtain the updated database, thereby completing the database copying operation.
[0090] Figure 3 An example is a schematic diagram of the physical structure of an electronic device, such as... Figure 3 As shown, the electronic device may include: a processor 810, a communication interface 820, a memory 830, and a communication bus 840, wherein the processor 810, the communication interface 820, and the memory 830 communicate with each other via the communication bus 840. The processor 810 can call a computer program in the memory 830 to execute a database replication compression method, which includes:
[0091] S1: Determine the target database, input task instructions, break down the task instructions to obtain multiple starting task instructions and final task instructions, and input the starting task instructions and final task instructions into the target database;
[0092] S2: Parse the start task instruction and the end task instruction, and make a judgment on the start task instruction and the end task instruction;
[0093] When the initial task instruction is insertion, the initial operation evaluation is skipped, and the final operation evaluation is performed. The insertion operation output is obtained based on the final task instruction and the final operation evaluation.
[0094] When the initial task instruction is update, determine the final task instruction. When the final task instruction is delete, perform an initial operation evaluation, skip the final operation evaluation, and obtain the first update operation output based on the initial operation evaluation and the final task instruction.
[0095] When the initial task instruction is update and the final task instruction is update, perform initial operation evaluation and final operation evaluation, and obtain the second update operation output based on the initial operation evaluation, final operation evaluation and final task instruction;
[0096] After all the starting and ending task instructions have been evaluated, proceed to step S3;
[0097] S3: Obtain intermediate operation data, reorder the intermediate operation data to obtain target intermediate operation data, update the target database based on the target intermediate operation data, insert operation output, first update operation output and second update operation output to obtain the updated database, thereby completing the database copy operation.
[0098] Furthermore, when the computer program in the aforementioned memory 830 can be implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0099] On the other hand, the present invention also provides a computer program product, the computer program product comprising a computer program stored on a non-transitory computer-readable storage medium, the computer program comprising program instructions, wherein when the program instructions are executed by a computer, the computer is able to execute a database replication compression method provided by the above methods, the method comprising:
[0100] S1: Determine the target database, input task instructions, break down the task instructions to obtain multiple starting task instructions and final task instructions, and input the starting task instructions and final task instructions into the target database;
[0101] S2: Parse the start task instruction and the end task instruction, and make a judgment on the start task instruction and the end task instruction;
[0102] When the initial task instruction is insertion, the initial operation evaluation is skipped, and the final operation evaluation is performed. The insertion operation output is obtained based on the final task instruction and the final operation evaluation.
[0103] When the initial task instruction is update, determine the final task instruction. When the final task instruction is delete, perform an initial operation evaluation, skip the final operation evaluation, and obtain the first update operation output based on the initial operation evaluation and the final task instruction.
[0104] When the initial task instruction is update and the final task instruction is update, perform initial operation evaluation and final operation evaluation, and obtain the second update operation output based on the initial operation evaluation, final operation evaluation and final task instruction;
[0105] After all the starting and ending task instructions have been evaluated, proceed to step S3;
[0106] S3: Obtain intermediate operation data, reorder the intermediate operation data to obtain target intermediate operation data, update the target database based on the target intermediate operation data, insert operation output, first update operation output and second update operation output to obtain the updated database, thereby completing the database copy operation.
[0107] In another aspect, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to perform one of the above-described database replication compression methods, the method comprising:
[0108] S1: Determine the target database, input task instructions, break down the task instructions to obtain multiple starting task instructions and final task instructions, and input the starting task instructions and final task instructions into the target database;
[0109] S2: Parse the start task instruction and the end task instruction, and make a judgment on the start task instruction and the end task instruction;
[0110] When the initial task instruction is insertion, the initial operation evaluation is skipped, and the final operation evaluation is performed. The insertion operation output is obtained based on the final task instruction and the final operation evaluation.
[0111] When the initial task instruction is update, determine the final task instruction. When the final task instruction is delete, perform an initial operation evaluation, skip the final operation evaluation, and obtain the first update operation output based on the initial operation evaluation and the final task instruction.
[0112] When the initial task instruction is update and the final task instruction is update, perform initial operation evaluation and final operation evaluation, and obtain the second update operation output based on the initial operation evaluation, final operation evaluation and final task instruction;
[0113] After all the starting and ending task instructions have been evaluated, proceed to step S3;
[0114] S3: Obtain intermediate operation data, reorder the intermediate operation data to obtain target intermediate operation data, update the target database based on the target intermediate operation data, insert operation output, first update operation output and second update operation output to obtain the updated database, thereby completing the database copy operation.
[0115] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0116] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0117] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method of compression for database replication, characterized in that, The method comprises the following steps: S1: determining a target database, inputting a task instruction, decomposing the task instruction to obtain a plurality of starting task instructions and a final task instruction, and inputting the starting task instruction and the final task instruction into the target database; S2: analyzing the starting task instruction and the final task instruction, and judging the starting task instruction and the final task instruction; when the starting task instruction is insertion, skipping initial operation evaluation, performing final operation evaluation, and obtaining insertion operation output according to the final task instruction and the final operation evaluation; wherein, when the final task instruction is deletion, the final operation evaluation is no evaluation, and when the final task instruction is update, the final operation evaluation is performed by judging whether the final update data meets the replication condition; when the starting task instruction is update, determining the final task instruction, when the final task instruction is deletion, performing initial operation evaluation and skipping final operation evaluation, and obtaining first update operation output according to the initial operation evaluation and the final task instruction; wherein, the initial operation evaluation is performed by judging whether the starting update data meets the replication condition; when the starting task instruction is update and the final task instruction is update, performing initial operation evaluation and final operation evaluation, and obtaining second update operation output according to the initial operation evaluation, the final operation evaluation and the final task instruction; wherein, when the starting task instruction is update and the final task instruction is update, the initial operation evaluation is performed by judging whether the starting update data meets the replication condition, and the final operation evaluation is performed by judging whether the final update data meets the replication condition; after judging all starting task instructions and final task instructions, entering step S3; S3: obtaining operation intermediate data, reordering the operation intermediate data to obtain target operation intermediate data, updating the target database according to the target operation intermediate data, the insertion operation output, the first update operation output and the second update operation output, obtaining an updated database, and thus completing the replication operation on the database.
2. The method of claim 1, wherein, In step S1, the target database comprises a plurality of data rows.
3. The method of claim 1, wherein, In step S2, when the final task instruction is deletion, the final operation evaluation is no evaluation, and the insertion operation output is no replication; when the final task instruction is update, the final operation evaluation is performed by judging whether the final update data meets the replication condition, and when the final update data meets the replication condition, the insertion operation output is to output a final row image; when the final update data does not meet the replication condition, the insertion operation output is no replication.
4. The method of claim 1, wherein, In step S2, when the final task instruction is deletion, the initial operation evaluation is performed by judging whether the starting update data meets the replication condition, when the starting update data meets the replication condition, the first update operation output is to delete row data; when the starting update data does not meet the replication condition, the first update operation output is no replication.
5. The method of claim 1, wherein, In step S2, when the initial task instruction is update and the final task instruction is update, the initial operation evaluation is performed by judging whether the initial update data meets the replication condition, the final operation evaluation is performed by judging whether the final update data meets the replication condition, when the initial update data meets the replication condition and the final update data meets the replication condition, the second update operation output is deleting the initial row image, outputting the final row image and updating the data primary key; When the initial update data meets the replication condition but the final update data does not meet the replication condition, the second update operation output is deleting the row data; When the initial update data does not meet the replication condition but the final update data meets the replication condition, the second update operation output is outputting the final row image; When the initial update data does not meet the replication condition and the final update data does not meet the replication condition, the second update operation output is not performing replication.
6. The method of claim 1, wherein, In step S3, the operation intermediate data in the order of the first insertion list, the second insertion list, the first update list and the second update list is obtained, the operation intermediate data is reordered to obtain the target operation intermediate data in the order of the first insertion list, the first update list, the second insertion list and the second update list, and the target database is updated according to the target operation intermediate data, the insertion operation output, the first update operation output and the second update operation output to obtain the updated database.
7. A system for compressing database replication for performing a method of compressing database replication according to any one of claims 1 to 6, characterized in that, Comprise: An instruction input module is used for determining a target database, inputting a task instruction, decomposing the task instruction to obtain a plurality of initial task instructions and final task instructions, and inputting the initial task instructions and the final task instructions into the target database; A task instruction judgment module is used for analyzing and judging the initial task instructions and the final task instructions; When the initial task instruction is insertion, the initial operation evaluation is skipped and the final operation evaluation is performed, and the insertion operation output is obtained according to the final task instruction and the final operation evaluation; When the initial task instruction is update, the final task instruction is determined, when the final task instruction is delete, the initial operation evaluation is performed and the final operation evaluation is skipped, and the first update operation output is obtained according to the initial operation evaluation and the final task instruction; When the initial task instruction is update and the final task instruction is update, the initial operation evaluation and the final operation evaluation are performed, and the second update operation output is obtained according to the initial operation evaluation, the final operation evaluation and the final task instruction; After judging all the initial task instructions and the final task instructions, step S3 is entered; An updated database module is used for obtaining operation intermediate data, reordering the operation intermediate data to obtain target operation intermediate data, updating the target database according to the target operation intermediate data, the insertion operation output, the first update operation output and the second update operation output to obtain an updated database, thereby completing the replication operation on the database.
8. An electronic device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, The computer program is executed by the processor to implement the steps of the database replication compression method according to any one of claims 1 to 6. 9.A non-transitory computer-readable storage medium having stored thereon a computer program, characterized in that, The computer program is executed by the processor to implement the steps of the database replication compression method according to any one of claims 1 to 6.
10. A computer program product comprising a computer program stored on a non-transitory computer readable storage medium, the computer program comprising program instructions, characterized in that, The computer program is executed by the processor to implement the steps of the database replication compression method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Synchronization Of Replicated Sequential Access Storage Components
CN102483711A
Processing method and system for database affairs
CN106294841A