IP Library Granted Patent US 12,411,829
Granted Patent B2
US 12,411,829 · App. 18/310,455 · Granted Sep 9, 2025

Efficient hash table based processing of database queries

Inventor: Adam Szymański (Warsaw, PL)
Assignee: Oxla sp. z o.o.
G06F16/2255G06F16/2237G06F16/24542G06F16/2455G06F16/24552G06F16/2456G06F16/24561
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,411,829
App. No.
18/310,455
Granted
Sep 9, 2025
Kind
B2
Abstract

A database system uses a hash table for processing database queries. The system stores keys mapped to data values in the hash table. For processing a set of records using the hash table, the system partially sorts the records to match the order of keys of the hash table. The partial storing of the records results in improving the performance of a cache storing the hash table. The hash table may be a multimap that maps a key to multiple data values. The system stores data values mapped to a key in a vector that stores all data values mapped to the key in contiguous memory. The system stores a pointer to the vector in association with the key in the multimap. The system optimizes the multimap to store the data value instead of the pointer if there is a single data value associated with a key.

Claims (71)

1. A computer-implemented method for executing database queries, the computer-implemented method comprising:

receiving, by a database system, a database query for processing data stored in one or more input tables;

generating a hash table configured to store a plurality of keys, each of the plurality of keys associated with one or more data values; generating the hash table comprising:

applying a hash function to the plurality of keys to map each of the plurality of keys to a corresponding position within the hash table; and

storing the plurality of keys and associated data values in the hash table at their corresponding positions, such that the plurality of keys and associated data values are stored in a particular order in the hash table;

processing the database query, comprising:

receiving a set of records, each record associated with a key;

reordering the set of records to obtain a reordered set of records that is at least partially sorted to match the particular order of the plurality of keys in the hash table, wherein the reordering comprises:

performing a first pass through the set of records to determine a count of records assigned to each of a plurality of buckets, wherein the buckets are defined based on the hash function;

computing, based on the counts, an offset for each bucket representing a position for storing records assigned to the respective bucket; and

performing a second pass through the set of records to place the records in positions based on their respective bucket offsets, thereby obtaining the reordered set of records;

accessing the hash table in order of the reordered set of records, comprising, for each record of the reordered set of records, accessing a data value stored in the hash table that is mapped to a key corresponding to the record; and

determining a set of results based on data values accessed from the hash table; and

providing the set of results as a result of processing the database query.

2. The computer-implemented method of claim 1 , wherein the database query specifies a group by operation that determines an aggregate value for each group based on keys of the hash table, wherein the data value stored in the hash table that is mapped to a key corresponding to the record is a partial aggregate value determined based on a subset of the set of records processed.

3. The computer-implemented method of claim 1 , wherein the database query specifies a join operation between a first table and a second table, wherein the hash table stores data values based on the first table, and the set of records is from the second table.

4. The computer-implemented method of claim 1 , wherein applying the hash function to the plurality of keys comprises:

determining a plurality of buckets, wherein a number of buckets is determined based on a number of keys that can be stored in the hash table, wherein the buckets are ordered;

associating each record of the set of record with a bucket from the plurality of buckets; and

processing the keys in an order of the buckets.

5. The computer-implemented method of claim 4 , wherein a set of keys assigned to a bucket are stored in proximity with each other in the hash table compared to keys assigned to other buckets.

6. The computer-implemented method of claim 4 , wherein the number of buckets is a power of two.

7. The computer-implemented method of claim 4 , wherein the database query is processed using a plurality of processors, wherein a first subset of the set of records associated with a first bucket is processed using a first processor and a second subset of the set of records associated with a second bucket is processed using a second processor.

8. A computer readable storage medium storing instructions for a method for executing database queries, the instructions when executed by a computer processor cause the computer processor to perform steps comprising:

receiving, by a database system, a database query for processing data stored in one or more input tables;

generating a hash table configured to store a plurality of keys, each of the plurality of keys associated with one or more data values, generating the hash table comprising:

applying a hash function to the plurality of keys to map each of the plurality of keys to a corresponding position within the hash table; and

storing the plurality of keys and associated data values in the hash table at their corresponding positions, such that the plurality of keys and associated data values are stored in a particular order in the hash table;

processing the database query, comprising:

receiving a set of records, each record associated with a key;

reordering the set of records to obtain a reordered set of records that is at least partially sorted to match the order of keys in the hash table, wherein the reordering comprises:

performing a first pass through the set of records to determine a count of records assigned to each of a plurality of buckets, wherein the buckets are defined based on the hash function;

computing, based on the counts, an offset for each bucket representing a position for storing records assigned to the respective bucket; and

performing a second pass through the set of records to place the records in positions based on their respective bucket offsets, thereby obtaining the reordered set of records;

accessing the hash table in order of the reordered set of records, comprising, for each record of the reordered set of records, accessing a data value stored in the hash table that is mapped to a key corresponding to the record; and

determining a set of results based on data values accessed from the hash table; and

providing the set of results as a result of processing the database query.

9. The computer readable storage medium of claim 8 , wherein the database query specifies a group by operation that determines an aggregate value for each group based on keys of the hash table, wherein the data value stored in the hash table that is mapped to a key corresponding to the record is a partial aggregate value determined based on a subset of the set of records processed.

10. The computer readable storage medium of claim 8 , wherein the database query specifies a join operation between a first table and a second table, wherein the hash table stores data values based on the first table, and the set of records is from the second table.

11. The computer readable storage medium of claim 8 , wherein applying a hash function to the plurality of keys comprises:

determining a plurality of buckets, wherein a number of buckets is determined based on a number of keys that can be stored in the hash table, wherein the buckets are ordered;

associating each record of the set of record with a bucket from the plurality of buckets; and

processing the keys in an order of the buckets.

12. The computer readable storage medium of claim 11 , wherein a set of keys assigned to a bucket are stored in proximity with each other in the hash table compared to keys assigned to other buckets.

13. The computer readable storage medium of claim 11 , wherein the number of buckets is a power of two.

14. The computer readable storage medium of claim 11 ,

wherein the database query is processed using a plurality of processors, wherein a first subset of the set of records associated with a first bucket is processed using a first processor and a second subset of the set of records associated with a second bucket is processed using a second processor.

15. A computer system comprising:

a computer processor; and

a computer-implemented method for executing database queries, the computer-implemented method comprising:

receiving, by a database system, a database query for processing data stored in one or more input tables;

generating a hash table configured to store a plurality of keys, each of the plurality of keys associated with one or more data values, generating the hash table comprising:

applying a hash function to the plurality of keys to map each of the plurality of keys to a corresponding position within the hash table; and

storing the plurality of keys and associated data values in the hash table at their corresponding positions, such that the plurality of keys and associated data values are stored in a particular order in the hash table;

processing the database query, comprising:

receiving a set of records, each record associated with a key;

reordering the set of records to obtain a reordered set of records that is at least partially sorted to match the order of keys in the hash table, wherein the reordering comprises:

performing a first pass through the set of records to determine a count of records assigned to each of a plurality of buckets, wherein the buckets are defined based on the hash function;

computing, based on the counts, an offset for each bucket representing a position for storing records assigned to the respective bucket; and

performing a second pass through the set of records to place the records in positions based on their respective bucket offsets, thereby obtaining the reordered set of records;

accessing the hash table in order of the reordered set of records, comprising, for each record of the reordered set of records, accessing a data value stored in the hash table that is mapped to a key corresponding to the record; and

determining a set of results based on data values accessed from the hash table; and

providing the set of results as a result of processing the database query.

16. The computer system of claim 15 , wherein the database query specifies a group by operation that determines an aggregate value for each group based on keys of the hash table, wherein the data value stored in the hash table that is mapped to a key corresponding to the record is a partial aggregate value determined based on a subset of the set of records processed.

17. The computer system of claim 15 , wherein the database query specifies a join operation between a first table and a second table, wherein the hash table stores data values based on the first table, and the set of records is from the second table.

18. The computer system of claim 15 , wherein applying a hash function to the plurality of keys comprises:

determining a plurality of buckets, wherein a number of buckets is determined based on a number of keys that can be stored in the hash table, wherein the buckets are ordered;

associating each record of the set of record with a bucket from the plurality of buckets; and

processing the keys in an order of the buckets.

19. The computer system of claim 18 , wherein a set of keys assigned to a bucket are stored in proximity with each other in the hash table compared to keys assigned to other buckets.

20. The computer system of claim 18 , wherein the database query is processed using a plurality of processors, wherein a first subset of the set of records associated with a first bucket is processed using a first processor and a second subset of the set of records associated with a second bucket is processed using a second processor.

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 Sep 29, 2023
From: SZYMANSKI, ADAM
To: OXLA SP. Z O.O.
Reel/Frame 065068/0771 →
Priority Claims (1)
PL 443718 · Feb 8, 2023 · national
Continuity (1)
Related Publication 20240264993A1 · Aug 8, 2024
References Cited (37)
US 9531839B1 · Wang et al. · 2016 [cited by applicant]
US 10248663B1 · Keisler et al. · 2019 [cited by applicant]
US 10366083B2 · Chavan et al. · 2019 [cited by applicant]
US 10558659B2 · Hopeman et al. · 2020 [cited by applicant]
US 10776401B2 · Gross et al. · 2020 [cited by applicant]
US 10977234B2 · Arye et al. · 2021 [cited by applicant]
US 11138175B2 · Arye et al. · 2021 [cited by applicant]
US 11238039B2 · Chavan et al. · 2022 [cited by applicant]
US 20040243257A1 · Theimer · 2004 [cited by applicant]
US 20060095485A1 · Moore · 2006 [cited by applicant]
US 20150039628A1 · Sen et al. · 2015 [cited by applicant]
US 20150143112A1 · Yavuz et al. · 2015 [cited by applicant]
US 20150288691A1 · Dickie · 2015 [cited by examiner]
US 20160267135A1 · Idicula et al. · 2016 [cited by applicant]
US 20160350375A1 · Das · 2016 [cited by examiner]
US 20170031976A1 · Chavan et al. · 2017 [cited by applicant]
US 20180081939A1 · Hopeman et al. · 2018 [cited by applicant]
US 20180081946A1 · Bondalapati · 2018 [cited by examiner]
US 20180089261A1 · Li et al. · 2018 [cited by applicant]
US 20180165348A1 · Cole et al. · 2018 [cited by applicant]
US 20180217987A1 · Helland et al. · 2018 [cited by applicant]
US 20180276289A1 · Gross et al. · 2018 [cited by applicant]
US 20190205459A1 · Busjaeger et al. · 2019 [cited by applicant]
US 20190220461A1 · Chavan et al. · 2019 [cited by applicant]
US 20210034586A1 · Arye et al. · 2021 [cited by applicant]
US 20210034598A1 · Arye et al. · 2021 [cited by applicant]
US 20210149897A1 · Kim · 2021 [cited by examiner]
US 20210191915A1 · Arye et al. · 2021 [cited by applicant]
US 20220277010A1 · Zhou · 2022 [cited by examiner]
US 20230120492A1 · Shalom et al. · 2023 [cited by applicant]
Henderson, Michael. Multi-way hash join effectiveness. Diss. University of British Columbia, 2013. (Year: 2013). [cited by examiner]
Shin, Hyunkwang, Ingyu Lee, and Gyu Sang Choi. “Bucket-Sorted Hash Join.” Journal of Information Science & Engineering 36.1 (2020). (Year: 2020). [cited by examiner]
Dong, Wei, et al. “ASH: A modern framework for parallel spatial hashing in 3D perception.” IEEE transactions on pattern analysis and machine intelligence 45.5 (2022): 5417-5435. (Year: 2022). [cited by examiner]
Jünger, Daniel, et al. “General-purpose GPU hashing data structures and their application in accelerated genomics.” Journal of Parallel and Distributed Computing 163 (2022): 256-268. (Year: 2022). [cited by examiner]
United States Office Action, U.S. Appl. No. 18/310,460, May 21, 2024, 13 pages. [cited by applicant]
United States Office Action, U.S. Appl. No. 18/310,459, May 10, 2024, 11 pages. [cited by applicant]
United States Patent Office, Office Action, U.S. Appl. No. 18/310,459, Oct. 31, 2024, 11 pages. [cited by applicant]