IP Library Granted Patent US 12,197,506
Granted Patent B2
US 12,197,506 · App. 17/886,250 · Granted Jan 14, 2025

Executing database queries for grouping data using channel based flow control

Inventor: Adam Szymański (Warsaw, PL)
Assignee: Oxla sp. z o.o.
G06F16/90335G06F16/24537G06F16/24542G06F16/24544
View Patent ↗
Loading inventors, assignments & file history…
Monitor This Case
Get email alerts when status or documents change.
Order Certified Copies
Most orders are placed with the USPTO same day — all within 24 business hours.
Order via The Patent Place →
Pre-filled with this patent's details
Quick Facts
Patent No.
US 12,197,506
App. No.
17/886,250
Granted
Jan 14, 2025
Kind
B2
Abstract

A database system generates an execution plan including multiple operators for processing a database query, for example, a join query or a group by query. The database system allocates a set of threads. Threads communicate with other threads via blocking channels. A blocking channel includes a buffer of a fixed capacity. The database system processes the database query by streaming data through operators of the execution plan. A thread sends data generated by an operator to another thread via the blocking channel if the buffer of the blocking channel has available capacity to store the data, or else the thread blocks until the buffer has capacity to store the data. Similarly, a thread receives data generated by an operator of another thread via the blocking channel if the buffer of the blocking channel has available data, or else the thread blocks until the buffer has data.

Claims (55)

1. A computer-implemented method for executing a database query for grouping data stored in an input table, the computer-implemented method comprising:

receiving, by a database system executing on a cluster of servers, the database query including a grouping clause for aggregating data stored in the input table;

generating an execution plan for executing the database query, the execution plan comprising a plurality of operators, the execution plan storing partial aggregation results in a data structure, the execution plan including instructions for a plurality of data distribution strategies for distributing the data structure over the cluster of servers, the plurality of data distribution strategies including a first data distribution strategy and a second data distribution strategy;

allocating a set of threads for executing operators of the execution plan, each thread processing one or more operators, the set of threads comprising at least a first thread and a second thread, wherein the first thread communicates with the second thread via a blocking channel comprising a buffer of fixed capacity for storing data, wherein the blocking channel blocks the first thread if the buffer is full, wherein the second thread processes an operator with a plurality of inputs. wherein a blocking channel is allocated to each of the plurality of inputs; and

processing the database query by streaming data through the operators of the execution plan, comprising:

determining at execution time of the database query, characteristics of input data processed by the database query, the characteristics comprising one or more of: a size of data of the input table, or a number of unique keys in the input table,

selecting at execution time of the database query, the first data distribution strategy from the plurality of data distribution strategies included in the execution plan of the database query based on the characteristics of input data processed by the database query,

monitoring characteristics of input data during execution of the database query,

responsive to detecting a change in characteristics of input data during execution of the database query, changing the distribution strategy from the first distribution strategy to the second distribution strategy, and

communicating data by the first thread via the blocking channel to the second thread.

2. The computer-implemented method of claim 1 , wherein the blocking channel allows a thread to perform one or more of:

a push operation that pushes data to the buffer of the blocking channel, wherein the push operation causes the thread to block if the buffer of the blocking channel is full; and

a pull operation that pulls data from the buffer of the blocking channel, wherein the pull operation causes the thread to block if the buffer of the blocking channel is empty.

3. The computer-implemented method of claim 1 , wherein the data structure is a hashmap that maps keys representing columns for grouping the data to partial results of aggregation of data of the input table.

4. The computer-implemented method of claim 1 , wherein one of the first data distribution strategy or the second data distribution strategy stores the data structure in each server of the cluster of servers if the size of the data structure is below a threshold value.

5. The computer-implemented method of claim 1 , wherein one of the first data distribution strategy or the second data distribution strategy partitions the data structure across a plurality of servers of the cluster of servers if the size of the data structure exceeds a threshold value.

6. The computer-implemented method of claim 1 , wherein the blocking channel is introduced between the first thread and the second thread, wherein the first thread executes an operator of the execution plan that shuffles data stored in the input table across the cluster of servers.

7. The computer-implemented method of claim 1 , wherein the blocking channel is introduced between the first thread and the second thread, wherein the first thread executes an operator for broadcasting data of the data structure to each server of the cluster of servers.

8. The computer-implemented method of claim 1 , wherein the blocking channel is introduced between the first thread and the second thread responsive to determining that a second operator performed by the second thread performs an aggregation of data stored in a table.

9. A non-transitory computer readable storage medium storing instructions that when executed by one or more computer processors, cause the one or more computer processors to perform steps comprising:

receiving, by a database system executing on a cluster of servers, a database query including a grouping clause for aggregating data stored in an input table;

generating an execution plan for executing the database query, the execution plan comprising a plurality of operators, the execution plan storing partial aggregation results in a data structure, the execution plan including instructions for a plurality of data distribution strategies for distributing the data structure over the cluster of servers, the plurality of data distribution strategies including a first data distribution strategy and a second data distribution strategy;

allocating a set of threads for executing operators of the execution plan, each thread processing one or more operators, the set of threads comprising at least a first thread and a second thread, wherein the first thread communicates with the second thread via a blocking channel comprising a buffer of fixed capacity for storing data, wherein the blocking channel blocks the first thread if the buffer is full, wherein the second thread processes an operator with a plurality of inputs. wherein a blocking channel is allocated to each of the plurality of inputs; and

processing the database query by streaming data through the operators of the execution plan, comprising:

determining at execution time of the database query, characteristics of input data processed by the database query, the characteristics comprising one or more of: a size of data of the input table, or a number of unique keys in the input table,

selecting at execution time of the database query, the first data distribution strategy from the plurality of data distribution strategies included in the execution plan of the database query based on the characteristics of input data processed by the database query,

monitoring characteristics of input data during execution of the database query,

responsive to detecting a change in characteristics of input data during execution of the database query, changing the distribution strategy from the first distribution strategy to the second distribution strategy, and

communicating data by the first thread via the blocking channel to the second thread.

10. The non-transitory computer readable storage medium of claim 9 , wherein the blocking channel allows a thread to perform one or more of:

a push operation that pushes data to the buffer of the blocking channel, wherein the push operation causes the thread to block if the buffer of the blocking channel is full; and

a pull operation that pulls data from the buffer of the blocking channel, wherein the pull operation causes the thread to block if the buffer of the blocking channel is empty.

11. The non-transitory computer readable storage medium of claim 9 , wherein the data structure is a hashmap that maps keys representing columns for grouping the data to partial results of aggregation of data of the input table.

12. The non-transitory computer readable storage medium of claim 9 , wherein one of the first data distribution strategy or the second data distribution strategy stores the data structure in each server of the cluster of servers if the size of the data structure is below a threshold value.

13. The non-transitory computer readable storage medium of claim 9 , wherein one of the first data distribution strategy or the second data distribution strategy partitions the data structure across a plurality of servers of the cluster of servers if the size of the data structure exceeds a threshold value.

14. The non-transitory computer readable storage medium of claim 9 , wherein the blocking channel is introduced between the first thread and the second thread, wherein the first thread executes an operator of the execution plan that shuffles data stored in the input table across the cluster of servers.

15. The non-transitory computer readable storage medium of claim 9 , wherein the blocking channel is introduced between the first thread and the second thread, wherein the first thread executes an operator for broadcasting data of the data structure to each server of the cluster of servers.

16. The non-transitory computer readable storage medium of claim 9 , wherein the blocking channel is introduced between the first thread and the second thread responsive to determining that a second operator performed by the second thread performs an aggregation of data stored in a table.

17. A computer system comprising:

one or more computer processors; and

a non-transitory computer readable storage medium storing instructions that when executed by the one or more computer processors, cause the one or more computer processors to perform steps comprising:

receiving, by a database system executing on a cluster of servers, a database query including a grouping clause for aggregating data stored in an input table;

generating an execution plan for executing the database query, the execution plan comprising a plurality of operators, the execution plan storing partial aggregation results in a data structure, the execution plan including instructions for a plurality of data distribution strategies for distributing the data structure over the cluster of servers, the plurality of data distribution strategies including a first data distribution strategy and a second data distribution strategy;

allocating a set of threads for executing operators of the execution plan, each thread processing one or more operators, the set of threads comprising at least a first thread and a second thread, wherein the first thread communicates with the second thread via a blocking channel comprising a buffer of fixed capacity for storing data, wherein the blocking channel blocks the first thread if the buffer is full, wherein the second thread processes an operator with a plurality of inputs. wherein a blocking channel is allocated to each of the plurality of inputs; and

processing the database query by streaming data through the operators of the execution plan, comprising:

determining at execution time of the database query, characteristics of input data processed by the database query, the characteristics comprising one or more of: a size of data of the input table, or a number of unique keys in the input table,

selecting at execution time of the database query, the first data distribution strategy from the plurality of data distribution strategies included in the execution plan of the database query based on the characteristics of input data processed by the database query,

monitoring characteristics of input data during execution of the database query,

responsive to detecting a change in characteristics of input data during execution of the database query, changing the distribution strategy from the first distribution strategy to the second distribution strategy, and

communicating data by the first thread via the blocking channel to the second thread.

18. The computer system of claim 17 , wherein the blocking channel allows a thread to perform one or more of:

a push operation that pushes data to the buffer of the blocking channel, wherein the push operation causes the thread to block if the buffer of the blocking channel is full; and

a pull operation that pulls data from the buffer of the blocking channel, wherein the pull operation causes the thread to block if the buffer of the blocking channel is empty.

19. The computer system of claim 17 , wherein the blocking channel is introduced between the first thread and the second thread, wherein the first thread executes an operator of the execution plan that shuffles data stored in the input table across the cluster of servers.

20. The computer system of claim 17 , wherein the blocking channel is introduced between the first thread and the second thread, wherein the first thread executes an operator for broadcasting data of the data structure to each server of the cluster of servers.

Assignments (2)
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Dec 15, 2025
From: OXLA SP. Z O.O
To: REDPANDA DATA, INC.
Reel/Frame 073213/0277 →
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Dec 12, 2022
From: SZYMANSKI, ADAM
To: OXLA SP. Z O.O.
Reel/Frame 062053/0041 →
Priority Claims (1)
PL 441869 · Jul 28, 2022 · national
Continuity (1)
Related Publication 20240037098A1 · Feb 1, 2024
References Cited (36)
US 5638535A · Rosenthal · 1997 [cited by examiner]
US 5742806A · Reiner · 1998 [cited by examiner]
US 6009265A · Huang · 1999 [cited by examiner]
US 6754652B2 · Bestgen · 2004 [cited by examiner]
US 9684671B1 · Dorin · 2017 [cited by examiner]
US 11481398B1 · Behm · 2022 [cited by examiner]
US 20060074874A1 · Day · 2006 [cited by examiner]
US 20070162425A1 · Betawadkar-Norwood et al. · 2007 [cited by applicant]
US 20070250470A1 · Duffy et al. · 2007 [cited by applicant]
US 20080133891A1 · Salz et al. · 2008 [cited by applicant]
US 20090083238A1 · Chaudhuri · 2009 [cited by examiner]
US 20090113188A1 · Hattori · 2009 [cited by examiner]
US 20090225082A1 · Hargrove · 2009 [cited by examiner]
US 20090248618A1 · Carlson · 2009 [cited by examiner]
US 20100332472A1 · Graefe · 2010 [cited by examiner]
US 20130238656A1 · Chen et al. · 2013 [cited by applicant]
US 20140214800A1 · Liang et al. · 2014 [cited by applicant]
US 20150324135A1 · Chan · 2015 [cited by examiner]
US 20160103879A1 · Attaluri et al. · 2016 [cited by applicant]
US 20160314176A1 · Dhayapule · 2016 [cited by examiner]
US 20160328488A1 · Lytle · 2016 [cited by examiner]
US 20160350394A1 · Gaumnitz · 2016 [cited by examiner]
US 20170351551A1 · Manhardt · 2017 [cited by examiner]
US 20180173753A1 · Pei · 2018 [cited by examiner]
US 20180218039A1 · Steinbeck · 2018 [cited by examiner]
US 20180357331A1 · Wen et al. · 2018 [cited by applicant]
US 20190303297A1 · Fleming et al. · 2019 [cited by applicant]
US 20210073226A1 · Chavan · 2021 [cited by examiner]
US 20210211399A1 · Kim et al. · 2021 [cited by applicant]
US 20210224675A1 · P. · 2021 [cited by examiner]
US 20210240713A1 · Kondiles et al. · 2021 [cited by applicant]
US 20210303593A1 · Breß · 2021 [cited by examiner]
US 20210326341A1 · Funke et al. · 2021 [cited by applicant]
US 20210374135A1 · Cruanes · 2021 [cited by examiner]
US 20220284320A1 · Yan · 2022 [cited by examiner]
United States Office Action, U.S. Appl. No. 17/886,383, filed Dec. 20, 2023, 27 pages. [cited by applicant]