# US 2017/0293530 A1 · Providing snapshot isolation to a database management system

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

- Number: US 2017/0293530 A1
- Document ID: US20170293530A1
- Status: Published application
- Kind: A1
- Application number: 15/224,959
- Filed: 2016-08-01
- Published: 2017-10-12
- Earliest claimed: 2016-04-07
- Assignees: International Business Machines Corporation
- Applicants: International Business Machines Corporation
- Inventors: Andreas Brodt; Daniel Martin; Oliver Schiller; Knut Stolze
- Web page: https://patentgrep.com/patent/US20170293530A1

## CPC

- G06F 16/2365: {Ensuring data consistency and integrity}
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

Providing snapshot isolation to a database managed by a database management system includes providing a program module to analyze a plurality of database queries directed at a table of the database and generates a view for said table. The table comprises a counter value column and the view is configured to selectively read, upon being called, data records having assigned particular counter values. The program module modifies the view of said table such that the particular counter values comprise counter values generated at moments when the program module received respective write queries which have already committed at the moment of modifying the view, are free of counter values of data records having become outdated by an update statement committed at the moment of modifying the view, and are free of counter values generated by the counter after the moment of modifying the view.

## Claims

### Claim 1

A computer-implemented method for providing snapshot isolation to a database managed by a database management system, the method comprising:
analyzing, by a program module, a plurality of database queries submitted by a client application to the database, each of the queries comprising one or more read or write statements directed at a table of the database, the table comprising a counter value column;
generating, by the program module, a view for said table, the view being configured to selectively read, upon being called, data records having assigned particular counter values;
upon determining, by the program module, that one of the database queries comprises a write statement for inserting a new data record into the table, storing the new data record in association with a counter value, the counter value being provided by a counter that increases its value at least every time a data record is requested to be updated or is requested to be inserted in said table;
upon determining, by the program module, that one of the database queries comprises a write statement for updating one of the data records in the table, storing an updated copy of the data record in association with a counter value provided by said counter in the table;
modifying, by the program module, the view of said table such that the particular counter values:
comprise counter values generated at moments when the program module received respective write queries which have already committed at the moment of modifying the view,
whereby the particular counter values are free of counter values of data records having become outdated by an update statement committed at the moment of modifying the view, and
are free of counter values generated by the counter after the moment of modifying the view;
upon determining, by the program module, that one of the database queries comprises a read statement for reading one or more data records from the table, calling, by the program module, the view of the table instead of performing the read statement on the table and forwarding the data records provided by the view to the client application.

### Claim 2 (depends on 1)

The computer-implemented method of claim 1, the database management system being a database management system that:
lacks an inbuilt support for managing transactions in accordance with at least one from a group of:
a snapshot isolation level; and
Atomicity, Consistency, Isolation, Durability (ACID) characteristics.

### Claim 3 (depends on 1)

The computer-implemented method of claim 1, wherein at least one of the queries comprises a write query for loading a partition of a source database into the database, the partition comprising a plurality of data records having assigned the partition-ID of said partition of the source database, and the method further comprises:
upon receiving, by the program module, the partition from the source database, receiving a current counter value from the counter and storing the data records of the loaded partition in association with the received current counter value in the database;
upon committing the load operation, modifying, by the program module, the view of said table such that the particular counter values comprise the counter value stored in association with the data records of the loaded partition and such that the particular counter values are free of counter values of any outdated version of the partition of the source database.

### Claim 4 (depends on 1)

The computer-implemented method of claim 1, wherein the counter values comprise at least one from a group of: timestamps indicating a moment of receiving, by the program module, a database query; and transaction-IDs of respective transactions specified in one or more of the received database queries.

### Claim 5 (depends on 1)

The computer-implemented method of claim 1, wherein the database management system comprises a database management system comprising an inbuilt table partition-based query optimization functionality, and the method further comprises:
modifying, by the program module, the table such that all data records comprising the same counter value are processed by the database management system as data records belonging to the same table partition and such that data records comprising different counter values are processed by the database management system as data records belonging to different table partitions, thereby enabling the inbuilt table-partition-based query optimization functionality to use the table partitions.

### Claim 6 (depends on 1)

The computer-implemented method of claim 1, wherein the database management system comprises a database management system comprising an inbuilt table partition-based bulk delete functionality, the method further comprising:
modifying, by the program module, the table such that all data records comprising the same counter value are processed by the database management system as data records belonging to the same table partition, such that data records comprising different counter values are processed by the database management system as data records belonging to different table partitions, thereby enabling the inbuilt table partition-based bulk delete functionality to delete partitions comprising data records which are outdated versions of one or more data records having been updated by an already committed update statement.

### Claim 7 (depends on 1)

The computer-implemented method of claim 1, further comprising:
modifying, by the program module, the table such that all data records comprising the same counter value are processed by the database management system as data records belonging to the same table partition and such that data records comprising different counter values are processed by the database management system as data records belonging to different table partitions;
determining, by the program module, that at least one of the partitions comprises data records which are outdated versions of one or more data records having been updated by an already committed update statement; and
sending, by the program module, a delete command for the at least one partition to the database management system.

### Claim 8 (depends on 1)

The computer-implemented method of claim 1, wherein modifying the view further comprises:
upon receiving, by the program module, one of the queries that comprises an insert or update statement for the table, modifying the view of said table such that the view comprises the counter value stored in association with the new data records generated by said statement, said counter value being stored in the view as a candidate for becoming one of the particular counter values;
upon determining, by the program module, that said update or write statement has committed, modifying the view of said table such that:
the counter value candidate becomes a member of the particular counter values; and
in case of an update statement removing the one of the counter values stored in the table in association with one or more data records having become outdated by the commit of said update statement from the particular counter values.

### Claim 9 (depends on 1)

The computer-implemented method of claim 1, wherein the database management system comprises an asynchronous deletion functionality, the method comprising:
determining, by the program module, that one or more data records stored in the table in association with the same counter value have become outdated by a commit of an update statement having created updated versions of said data records;
determining, by the program module, if one or more currently executed read statements exist that access the outdated data records;
if no currently executed read statements exist that access the outdated data records, modifying the view of said table such that the counter value stored in association with the outdated data record is stored in the view as a candidate for asynchronous deletion, the candidate for asynchronous deletion not being one of the particular counter values, and notifying the asynchronous deletion functionality of the database management system that the data rows stored in the table in association with said counter value of said outdated data records can be safely deleted.

### Claim 10 (depends on 9)

The computer-implemented method of claim 9, wherein the modification of the view is performed using a soft invalidation function of the database management system.

### Claim 11 (depends on 9)

The computer-implemented method of claim 9, further comprising:
regularly deleting, by the asynchronous deletion functionality, all data records stored in the table in association with a counter value stored in the view as deletion candidate counter value, whereby all data records stored in association with the same counter value are deleted in a single bulk delete operation.

### Claim 12 (depends on 1)

The computer-implemented method of claim 1, further comprising:
configuring, by the program module, the counter value column to be invisible to the client application.

### Claim 13 (depends on 1)

The computer-implemented method of claim 1, wherein the database management system comprises a locking system that locks every added or deleted table row while it is being changed, and the method further comprises:
causing, by the client application or by the program module, the locking system to operate in an uncommitted read isolation level that allows an application to access the uncommitted changes of other transactions, whereby the plurality of database queries are executed in accordance with the snapshot isolation level that is provided by the program module generating, modifying and calling the view.

### Claim 14 (depends on 1)

The computer-implemented method of claim 1, wherein the counter also increases its value every time a data record is modified or inserted in any other table of the database.

### Claim 15 (depends on 1)

The computer-implemented method of claim 1, wherein the program module comprises at least one of:
a library stored on a client system hosting the client application, the client system being connected to the database management system via a network;
a proxy module connected via a network to the client application and to one or more further client applications; and
an inbuilt program module of the database management system.

### Claim 16 (depends on 1)

The computer-implemented method of claim 1, wherein each state of a view corresponding to a logical snapshot of the table and to a specific set of particular counter values determines which of the data records of the table can be accessed by a currently received database query.

### Claim 17

A computer program product for providing snapshot isolation to a database managed by a database management system, the computer program product comprising a computer readable storage medium having program instructions embodied therewith, the program instructions executable by a processor to cause the processor to execute the method comprising:
analyzing a plurality of database queries submitted by a client application to the database, each of the queries comprising one or more read or write statements directed at a table of the database, the table comprising a counter value column;
generating a view for said table, the view being configured to selectively read, upon being called, data records having assigned particular counter values;
upon determining that one of the database queries comprises a write statement for inserting a new data record into the table, storing the new data record in association with a counter value, the counter value being provided by a counter that increases its value at least every time a data record is requested to be updated or is requested to be inserted in said table;
upon determining that one of the database queries comprises a write statement for updating one of the data records in the table, storing an updated copy of the data record in association with a counter value provided by said counter in the table;
modifying the view of said table such that the particular counter values:
comprise counter values generated at moments when a program module received respective write queries which have already committed at the moment of modifying the view,
whereby the particular counter values are free of counter values of data records having become outdated by an update statement committed at the moment of modifying the view, and
are free of counter values generated by the counter after the moment of modifying the view;
upon determining that one of the database queries comprises a read statement for reading one or more data records from the table, calling the view of the table instead of performing the read statement on the table and forwarding the data records provided by the view to the client application.

### Claim 18

A computer system comprising a processor and a program module for providing snapshot isolation to a database managed by the database management system, the program module being configured to cause the processor to perform a method comprising:
analyzing a plurality of database queries submitted by a client application to the database, each of the queries comprising one or more read or write statements directed at a table of the database, the table comprising a counter value column;
generating a view for said table, the view being configured to selectively read, upon being called, data records having assigned particular counter values;
upon determining that one of the database queries comprises a write statement for inserting a new data record into the table, storing the new data record in association with a counter value, the counter value being provided by a counter that increases its value at least every time a data record is requested to be updated or is requested to be inserted in said table;
upon determining that one of the database queries comprises a write statement for updating one of the data records in the table, storing an updated copy of the data record in association with a counter value provided by said counter in the table;
modifying the view of said table such that the particular counter values:
comprise counter values generated at moments when a program module received respective write queries which have already committed at the moment of modifying the view,
whereby the particular counter values are free of counter values of data records having become outdated by an update statement committed at the moment of modifying the view, and
are free of counter values generated by the counter after the moment of modifying the view;
upon determining that one of the database queries comprises a read statement for reading one or more data records from the table, calling the view of the table instead of performing the read statement on the table and forwarding the data records provided by the view to the client application.

### Claim 19 (depends on 18)

The computer system of claim 18, wherein the computer system comprises a client computer system hosting the client application and the program module, the client computer system being connected via a network to a server computer system hosting the database management system.

### Claim 20 (depends on 18)

The computer system of claim 18, wherein the computer system comprises a server computer system hosting the database management system and the program module, the server computer system being connected via a network to a client computer system hosting the client application program.
