TECHNICAL FIELD

The present invention relates generally to data replication and, more specifically, to dynamic selection of a data apply strategy for replication of data to a target database.

BACKGROUND

Replication of a state of a primary database to one or more secondary databases can be used, among other things, to create a recovery record in the case of failure of the primary database. Generally, a primary database is continuously changed by operations, such as insert, update, and delete. Records of these operations can be gathered and applied to the recovery database using dynamic or batch replication. While dynamic replication allows each individual transaction to be immediately mirrored to a secondary database, this form of replication is resource intensive and generally only performed in situations where the data needs to be completely up to date in the secondary site. Less resource intensive is batch replication, in which change operations are not mirrored instantly. Rather, in batch replication, records can be gathered until a threshold is reached, such as a certain period of time and/or a particular quantity of data, before the gathered change operations are applied to the recovery database. This results in the recovery database having latency relative to the primary database. The greater the latency of the recovery database, the more out of date that database is relative to the primary database and the less useful the recovery database is in the case that data recovery is necessitated.

SUMMARY

Approaches presented herein enable replicating data records between a source database and a target database. More specifically, for a batch of change records in a table received from the source database, a first estimated replication duration needed to apply the batch as a bulk change to the target is determined. For the same batch, a second estimated replication duration needed to apply a set of changes in a single row of the table to the target is determined based on time penalties for each column in the row. A threshold quantity of rows at which the first duration equals a summed total of second durations for the quantity is calculated. The bulk change is selected if a number of rows in the batch exceeds the threshold. Applying change records singly is selected if the number of rows in the batch is less than the threshold.

One aspect of the present invention includes a method for replicating data records between a source database system and a target database system, comprising: determining, for a batch of change records received from the source database system in a table, a first estimated replication duration needed to apply the batch of change records as a bulk change to the target database system; determining, for the batch of change records received from the source database system in the table, a second estimated replication duration needed to apply a set of changes in a single row of the table to the target database system based on time penalties for each column in the row; calculating a threshold quantity of rows at which the first estimated replication duration equals a summed total of second replication durations for the quantity of rows; selecting the bulk change in the case that a number of rows in the batch exceeds the threshold; and applying, responsive to the selecting, the batch of changes to the target database system using the selected bulk change.

Another aspect of the present invention includes a computer system for replicating data records between a source database system and a target database system, the computer system comprising: a memory medium comprising program instructions; a bus coupled to the memory medium; and a processor, for executing the program instructions, coupled to an apply manager via the bus that when executing the program instructions causes the computer system to: determine, for a batch of change records received from the source database system in a table, a first estimated replication duration needed to apply the batch of change records as a bulk change to the target database system; determine, for the batch of change records received from the source database system in the table, a second estimated replication duration needed to apply a set of changes in a single row of the table to the target database system based on time penalties for each column in the row; calculate a threshold quantity of rows at which the first estimated replication duration equals a summed total of second replication durations for the quantity of rows; select the bulk change in the case that a number of rows in the batch exceeds the threshold; and apply, responsive to the selection, the batch of changes to the target database system using the selected bulk change.

Yet another aspect of the present invention includes a computer program product for replicating data records between a source database system and a target database system, the computer program product comprising at least one computer readable hardware storage device, and program instructions collectively stored on the at least one computer readable hardware storage device, to: determine, for a batch of change records received from the source database system in a table, a first estimated replication duration needed to apply the batch of change records as a bulk change to the target database system; determine, for the batch of change records received from the source database system in the table, a second estimated replication duration needed to apply a set of changes in a single row of the table to the target database system based on time penalties for each column in the row; calculate a threshold quantity of rows at which the first estimated replication duration equals a summed total of second replication durations for the quantity of rows; select the bulk change in the case that a number of rows in the batch exceeds the threshold; and apply, responsive to the selection, the batch of changes to the target database system using the selected bulk change.

Still yet, any of the components of the present invention could be deployed, managed, serviced, etc., by a service provider who offers to implement passive monitoring in a computer system.

Embodiments of the present invention also provide related systems, methods, and/or program products.

