LIFO Spilling for GROUP BY Aggregation Hash Tables

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Existing database systems face performance issues when executing GROUP BY commands on large data sets, as they often require transferring the entire aggregation table to external storage, leading to varying execution speeds and inefficiencies due to memory constraints.

Innovation Solution

A LIFO (Last-In-First-Out) spilling algorithm that maintains a single hash table and spills data in LIFO order to free memory, allowing for efficient data transfer and processing by moving only the necessary data to auxiliary storage, while maintaining minimal overhead on the in-memory path and ensuring good asymptotic performance.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Quantity of substance

If the entire aggregation table is transferred to external storage when memory is full, then memory constraints are satisfied, but execution speed varies considerably and performance cliffs occur

Engineering Contradiction:
Improvememory capacityVSAvoidexecution speed
Core Design Contradiction:
Quantity of substanceVSProductivity

Solution Approach 1:

The patent divides the aggregation table into multiple partitions based on hash ranges. Each partition can be independently managed and spilled to disk. This segmentation allows the system to spill only specific partitions when memory pressure occurs, rather than transferring the entire aggregation table, thereby reducing I/O overhead and maintaining better execution speed.

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

The patent implements partial spilling by selecting and spilling only the necessary partitions that exceed memory capacity,而非spilling the entire aggregation table. This partial action reduces the amount of data transferred to external storage, minimizing performance impact while still satisfying memory constraints.

Inventive Principle:
Principle #16Partial or excessive action

2Productivity

If a hash table is used for GROUP BY aggregation, then grouping efficiency is improved, but memory usage increases and requires spilling to external storage for large data sets

Engineering Contradiction:
Improvegrouping efficiencyVSAvoidmemory usage
Core Design Contradiction:
ProductivityVSQuantity of substance

Solution Approach 1:

The hash table is divided into multiple partitions, each managing a specific hash range. This segmentation allows the system to load only necessary partitions into memory based on the data being processed, reducing overall memory usage while maintaining hashing efficiency for grouping operations.

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

The patent implements dynamic partition loading and spilling based on memory availability. When memory pressure is detected, specific partitions are spilled to disk; when memory is available, partitions are loaded back. This dynamic adjustment allows the system to maintain high grouping efficiency when memory permits while adapting to memory constraints when necessary.

Inventive Principle:
Principle #15Dynamics

3Quantity of substance

If data is spilled to external storage, then memory constraints are relieved, but transfer time increases and performance degrades

Engineering Contradiction:
Improveavailable memoryVSAvoidtransfer time
Core Design Contradiction:
Quantity of substanceVSLoss of time

Solution Approach 1:

By segmenting the aggregation table into partitions, the system can spill only the necessary partitions to disk rather than the entire table. This reduces the total transfer time proportional to the amount of data spilled, while still relieving memory constraints.

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

The patent extracts and spills only the specific partitions that exceed memory capacity to external storage, leaving the remaining partitions in memory. This selective extraction minimizes the amount of data transferred, reducing transfer time while still achieving the goal of relieving memory pressure.

Inventive Principle:
Principle #2Taking out (Extraction)

Data Source

PatentUS11481398B1LIFO based spilling for grouping aggregation
Publication Date: 2022.10.25 DATABRICKS INC
  • US11481398B1 patent drawing
  • US11481398B1 patent drawing
  • US11481398B1 patent drawing

AI summary

A system for spilling comprises an interface and a processor. The interface is configured to receive an indication to perform a GROUP BY operation, wherein the indication comprises an input table and a grouping column. The processor is configured to: for each input table entry of the input table, determine a key, wherein the key is based at least in part on the input table entry and the grouping column; add the key to a grouping hash table, wherein adding the key to the grouping hash table comprises last-in, first-out (LIFO) spilling when necessary; create an output table based at least in part on the grouping hash table; and provide the output table.