# US 2023/0055715 A1 · Scalable compaction in a concurrent transaction processing distributed database

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

- Number: US 2023/0055715 A1
- Document ID: US20230055715A1
- Status: Published application
- Kind: A1
- Application number: 17/463,353
- Filed: 2021-08-31
- Published: 2023-02-23
- Earliest claimed: 2021-08-13
- Assignees: Snowflake Inc.
- Applicants: Snowflake Inc.
- Inventors: Chen Luo; Alexander Miller; William Waddington; Zhaohui Zhang
- Web page: https://patentgrep.com/patent/US20230055715A1

## CPC

- G06F 16/24568: {Data stream processing; Continuous queries}
- G06F 16/273: {Asynchronous replication or reconciliation}
- G06F 16/2343: {Locking methods, e.g. distributed locking or locking implementation details}
- G06F 16/2379: {Updates performed during online database operations; commit processing}
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

A distributed database compaction system can perform compaction for transactional queries in an asynchronous matter without affecting completion of the queries. The compaction system can implement asynchronous transformation of key pairs in the database, and older keys can be periodically purged using a scheduled compactor. Subsequent queries use the compacted stored keys to perform efficient queries with direct reads of committed transactions and more efficient access to key values stores of the distributed database.

## Claims

### Claim 1

A method comprising:
receiving, by a distributed database, a plurality of transactional queries against a key-value database comprising data managed by key-value pairs;
performing, using asynchronous threads of execution nodes of the distributed database, asynchronous transformation and compaction of key-value pairs of data that corresponds to the plurality of transactional queries, the asynchronous threads transforming the key-value pairs from an initial format to a commit format that includes a commit time of data committed to the distributed database, the one or more asynchronous threads compacting the key-value pairs by deleting the key-value pairs in the initial format;
processing, using transactional threads in the execution nodes, the plurality of transactional queries to generate results data, the asynchronous threads performing the asynchronous transformation and compaction while the transactional threads generate the results data; and
storing the results data.

### Claim 2 (depends on 1)

The method of claim 1, further comprising:
receiving a plurality of additional transactional queries against the distributed database.

### Claim 3 (depends on 2)

The method of claim 2, further comprising:
processing, by the transactional threads, the plurality of additional transactional queries using the key-value pairs in the commit time form, the transactional threads using commit times in the key-value pairs to generate additional results data; and
storing the additional results data.

### Claim 4 (depends on 1)

The method of claim 1, wherein the distributed database comprises a transaction status table that indicates whether data of transactions has committed to the database.

### Claim 5 (depends on 4)

The method of claim 4, wherein queries for data having key-value pairs in the initial format are executed by identifying transaction identifiers in the key-value pairs and access the transaction status table to determine commit statuses.

### Claim 6 (depends on 4)

The method of claim 4, further comprising:
performing, using a dedicated compactor thread in one of the execution nodes, transformation and compaction of the key-value pairs from the initial format to the commit format.

### Claim 7 (depends on 6)

The method of claim 6, further comprising:
performing, using the dedicated compactor thread, compaction of the transaction status table by deleting key-value pairs in the transaction status table that have corresponding key-value pairs in the commit format.

### Claim 8 (depends on 1)

The method of claim 1, wherein each key-value pair in the initial format includes a transaction identifier value.

### Claim 9 (depends on 1)

The method of claim 1, wherein the asynchronous threads perform transformation by rewriting each key-value pair such that the commit time replaces the transaction identifier value.

### Claim 10 (depends on 1)

The method of claim 1, wherein the key-value pairs having transaction identifiers are deleted by the asynchronous threads.

### Claim 11

A system comprising:
one or more processors of a machine; and
a memory storing instructions that, when executed by the one or more processors, cause the machine to perform operations comprising:
receiving, by a distributed database, a plurality of transactional queries against a key-value database comprising data managed by key-value pairs;
performing, using asynchronous threads of execution nodes of the distributed database, asynchronous transformation and compaction of key-value pairs of data that corresponds to the plurality of transactional queries, the asynchronous threads transforming the key-value pairs from an initial format to a commit format that includes a commit time of data committed to the distributed database, the one or more asynchronous threads compacting the key-value pairs by deleting the key-value pairs in the initial format;
processing, using transactional threads in the execution nodes, the plurality of transactional queries to generate results data, the asynchronous threads performing the asynchronous transformation and compaction while the transactional threads generate the results data; and
storing the results data.

### Claim 12 (depends on 11)

The system of claim 11, the operations further comprising:
receiving a plurality of additional transactional queries against the distributed database.

### Claim 13 (depends on 12)

The system of claim 12, the operations further comprising:
processing, by the transactional threads, the plurality of additional transactional queries using the key-value pairs in the commit time form, the transactional threads using commit times in the key-value pairs to generate additional results data; and
storing the additional results data.

### Claim 14 (depends on 11)

The system of claim 11, wherein the distributed database comprises a transaction status table that indicates whether data of transactions has committed to the database.

### Claim 15 (depends on 14)

The system of claim 14, wherein queries for data having key-value pairs in the initial format are executed by identifying transaction identifiers in the key-value pairs and access the transaction status table to determine commit statuses.

### Claim 16 (depends on 14)

The system of claim 14, the operations further comprising:
performing, using a dedicated compactor thread in one of the execution nodes, transformation and compaction of the key-value pairs from the initial format to the commit format.

### Claim 17 (depends on 16)

The system of claim 16, the operations further comprising:
performing, using the dedicated compactor thread, compaction of the transaction status table by deleting key-value pairs in the transaction status table that have corresponding key-value pairs in the commit format.

### Claim 18 (depends on 11)

The system of claim 11, wherein each key-value pair in the initial format includes a transaction identifier value.

### Claim 19 (depends on 11)

The system of claim 11, wherein the asynchronous threads perform transformation by rewriting each key-value pair such that the commit time replaces the transaction identifier value.

### Claim 20 (depends on 11)

The system of claim 11, wherein the key-value pairs having transaction identifiers are deleted by the asynchronous threads.

### Claim 21

A machine storage medium comprising:
receiving, by a distributed database, a plurality of transactional queries against a key-value database comprising data managed by key-value pairs;
performing, using asynchronous threads of execution nodes of the distributed database, asynchronous transformation and compaction of key-value pairs of data that corresponds to the plurality of transactional queries, the asynchronous threads transforming the key-value pairs from an initial format to a commit format that includes a commit time of data committed to the distributed database, the one or more asynchronous threads compacting the key-value pairs by deleting the key-value pairs in the initial format;
processing, using transactional threads in the execution nodes, the plurality of transactional queries to generate results data, the asynchronous threads performing the asynchronous transformation and compaction while the transactional threads generate the results data; and
storing the results data.

### Claim 22 (depends on 21)

The machine storage medium of claim 21, the operations further comprising:
receiving a plurality of additional transactional queries against the distributed database.

### Claim 23 (depends on 22)

The machine storage medium of claim 22, the operations further comprising:
processing, by the transactional threads, the plurality of additional transactional queries using the key-value pairs in the commit time form, the transactional threads using commit times in the key-value pairs to generate additional results data; and
storing the additional results data.

### Claim 24 (depends on 21)

The machine storage medium of claim 21, wherein the distributed database comprises a transaction status table that indicates whether data of transactions has committed to the database.

### Claim 25 (depends on 24)

The machine storage medium of claim 24, wherein queries for data having key-value pairs in the initial format are executed by identifying transaction identifiers in the key-value pairs and access the transaction status table to determine commit statuses.

### Claim 26 (depends on 24)

The machine storage medium of claim 24, the operations further comprising:
performing, using a dedicated compactor thread in one of the execution nodes, transformation and compaction of the key-value pairs from the initial format to the commit format.

### Claim 27 (depends on 26)

The machine storage medium of claim 26, the operations further comprising:
performing, using the dedicated compactor thread, compaction of the transaction status table by deleting key-value pairs in the transaction status table that have corresponding key-value pairs in the commit format.

### Claim 28 (depends on 21)

The machine storage medium of claim 21, wherein each key-value pair in the initial format includes a transaction identifier value.

### Claim 29 (depends on 21)

The machine storage medium of claim 21, wherein the asynchronous threads perform transformation by rewriting each key-value pair such that the commit time replaces the transaction identifier value.

### Claim 30 (depends on 21)

The machine storage medium of claim 21, wherein the key-value pairs having transaction identifiers are deleted by the asynchronous threads.
