# US 2021/0286775 A1 · Dynamic selection of data apply strategy during database replication

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 2021/0286775 A1
- Document ID: US20210286775A1
- Status: Published application
- Kind: A1
- Application number: 16/815,415
- Filed: 2020-03-11
- Published: 2021-09-16
- Earliest claimed: 2020-03-11
- Assignees: International Business Machines Corporation
- Applicants: International Business Machines Corporation
- Inventors: Felix Beier; Dennis Butterstein; Einar Lueck; Sabine Perathoner-Tschaffler; Daniel Martin
- Web page: https://patentgrep.com/patent/US20210286775A1

## CPC

- G06F 16/1844: {Management specifically adapted to replicated file systems}
- G06F 16/27: Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
- G06F 16/1734: {Details of monitoring file system events, e.g. by the use of hooks, filter drivers, logs}
- G06F 16/1827: {Management specifically adapted to NAS (management of storage area networks [SAN] G06F3/067)}
- G06F 16/1865: {Transactional file systems}
- G06F 16/221: {Column-oriented storage; Management thereof}
- G06F 16/2282: {Tablespace storage structures; Management thereof}
- G06F 16/24534: {Query rewriting; Transformation}
- G06F 16/254: {Extract, transform and load [ETL] procedures, e.g. ETL data flows in data warehouses}
- G06F 16/273: {Asynchronous replication or reconciliation}
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

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.

## Claims

### Claim 1

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.

### Claim 2 (depends on 1)

The method of claim 1, the method further comprising:
selecting applying change records singly in the case that the number of rows in the batch is less than the threshold; and
applying, responsive to the single application selection, the batch of changes to the target database system singly.

### Claim 3 (depends on 2)

The method of claim 2, wherein the bulk change transforms change records into a format that is used as input for native bulk-loading utilities provided by the target database system, and wherein applying the change records singly executes a Structured Query Language (SQL) statement to apply the change for each change record.

### Claim 4 (depends on 1)

The method of claim 1, the method further comprising obtaining the batch of change records flushed from a change record buffer associated with the source database table.

### Claim 5 (depends on 4)

The method of claim 4, the method further comprising:
extracting change records encoding data changes from the source database system by reading transaction recovery logs of the source database system;
buffering the extracted change records in the change record buffer and grouping the extracted change records into the batch of change records; and
flushing the buffered changes from the buffer using a flush strategy, the flush strategy comprising at least one strategy selected from the group consisting of: flush in response to a filled buffer, flush periodically, and flush based on latency of the target database system.

### Claim 6 (depends on 1)

The method of claim 1, the determining the second estimated replication duration needed to apply a set of changes in a single row further comprising:
evaluating table schema information of the batch as a cost model for each column type of the table;
determining a time penalty for each column type of the table; and
summing the time penalties for each column type to yield the second estimated replication duration.

### Claim 7 (depends on 6)

The method of claim 6, the method further comprising:
calibrating the cost models by creating sample tables with a predefined set of columns of the types to be calibrated;
executing sample insertions and deletions on said sample tables; and
measuring and averaging execution costs of the samples.

### Claim 8

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.

### Claim 9 (depends on 8)

The computer system of claim 8, the instructions further causing the computer system to:
select applying change records singly in the case that the number of rows in the batch is less than the threshold; and
apply, responsive to the single application selection, the batch of changes to the target database system singly.

### Claim 10 (depends on 9)

The computer system of claim 9, wherein the bulk change transforms change records into a format that is used as input for native bulk-loading utilities provided by the target database system, and wherein applying the change records singly executes a Structured Query Language (SQL) statement to apply the change for each change record.

### Claim 11 (depends on 8)

The computer system of claim 8, the instructions further causing the computer system to obtain the batch of change records flushed from a change record buffer associated with the source database table.

### Claim 12 (depends on 11)

The computer system of claim 11, the instructions further causing the computer system to:
extract change records encoding data changes from the source database system by reading transaction recovery logs of the source database system;
buffer the extracted change records in the change record buffer and group the extracted change records into the batch of change records; and
flush the buffered changes from the buffer using a flush strategy, wherein the flush strategy comprises at least one strategy selected from the group consisting of: flush in response to a filled buffer, flush periodically, and flush based on latency of the target database system.

### Claim 13 (depends on 8)

The computer system of claim 8, the instructions causing the computer system to determine the second estimated replication duration needed to apply a set of changes in a single row further causing the computer system to:
evaluate table schema information of the batch as a cost model for each column type of the table;
determine a time penalty for each column type of the table; and
sum the time penalties for each column type to yield the second estimated replication duration.

### Claim 14 (depends on 13)

The computer system of claim 13, the instructions further causing the system to:
calibrate the cost models by creating sample tables with a predefined set of columns of the types to be calibrated;
execute sample insertions and deletions on said sample tables; and
measure and average execution costs of the samples.

### Claim 15

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.

### Claim 16 (depends on 15)

The computer program product of claim 15, the at least one computer readable storage device further collectively comprising instructions to:
select applying change records singly in the case that the number of rows in the batch is less than the threshold; and
apply, responsive to the single application selection, the batch of changes to the target database system singly.

### Claim 17 (depends on 16)

The computer program product of claim 16, wherein the bulk change transforms change records into a format that is used as input for native bulk-loading utilities provided by the target database system, and wherein applying the change records singly executes a Structured Query Language (SQL) statement to apply the change for each change record.

### Claim 18 (depends on 15)

The computer program product of claim 15, the at least one computer readable storage device further collectively comprising instructions to obtain the batch of change records flushed from a change record buffer associated with the source database table.

### Claim 19 (depends on 18)

The computer program product of claim 18, the at least one computer readable storage device further collectively comprising instructions to:
extract change records encoding data changes from the source database system by reading transaction recovery logs of the source database system;
buffer the extracted change records in the change record buffer and group the extracted change records into the batch of change records; and
flush the buffered changes from the buffer using a flush strategy, wherein the flush strategy comprises at least one strategy selected from the group consisting of: flush in response to a filled buffer, flush periodically, and flush based on latency of the target database system.

### Claim 20 (depends on 15)

The computer program product of claim 15, the instructions to determine the second estimated replication duration needed to apply a set of changes in a single row further comprising instructions to:
evaluate table schema information of the batch as a cost model for each column type of the table;
calibrate the cost models by creating sample tables with a predefined set of columns of the types to be calibrated;
execute sample insertions and deletions on said sample tables;
measure and average execution costs of the samples;
determine a time penalty for each column type of the table; and
sum the time penalties for each column type to yield the second estimated replication duration.
