Hybrid Sort Hash Query Execution for Database Aggregation

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Existing database systems face challenges in efficiently implementing grouping operations, particularly when the number of groups is large, as traditional hash-based approaches become costly and sort-based approaches are complex, leading to inefficient aggregation performance and increased memory requirements.

Innovation Solution

A hybrid sort and hash-based query execution method that hashes aggregation keys on a per bucket basis, dynamically switching between list mode, no change mode, and secondary hashing mode based on the number of hashed tuples per bucket, allowing for real-time adaptation and efficient aggregation.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Productivity

If hash-based approaches are used for grouping operations, then effectiveness is improved for scenarios with a small number of groups, but cost increases significantly when the number of groups increases

Engineering Contradiction:
Improvegrouping operation effectivenessVSAvoidhashing cost
Core Design Contradiction:
ProductivityVSLoss of energy

Solution Approach 1:

The system dynamically switches between hash-based and sort-based approaches based on the number of groups detected during query execution. This dynamic adaptation allows the system to use the most efficient approach for the current data characteristics, avoiding the performance degradation that occurs when a static hash-based approach is used for all scenarios with varying group counts

Inventive Principle:
Principle #15Dynamics

Solution Approach 2:

The system changes the operational parameter (grouping method) based on the number of groups. When the number of groups exceeds a threshold, the system transitions from hash-based to sort-based grouping, optimizing performance for large numbers of groups while maintaining efficiency for smaller group counts

Inventive Principle:
Principle #35Parameter changes

2Productivity

If sort based grouping is used for cases with a large number of groups, then effectiveness is improved, but complexity increases

Engineering Contradiction:
Improvegrouping operation effectiveness for large groupsVSAvoidsorting complexity
Core Design Contradiction:
ProductivityVSDevice complexity

Solution Approach 1:

The system segments the grouping operation into two distinct phases: an initial hash-based grouping phase that creates buckets, and a secondary sort-based phase that processes only the buckets exceeding the group threshold. This segmentation allows the complex sorting operation to be applied only where necessary, reducing overall complexity while maintaining effectiveness for large numbers of groups

Inventive Principle:
Principle #1Segmentation

3Ease of manufacture

If traditional hash-based approaches are used, then code generation is simplified, but memory requirements increase for large numbers of groups

Engineering Contradiction:
Improvecode generation simplicityVSAvoidmemory requirements
Core Design Contradiction:
Ease of manufactureVSQuantity of substance

Solution Approach 1:

The system performs preliminary hash-based grouping to create buckets and evaluate the number of groups before committing to the final grouping approach. This preliminary action allows the system to identify when sort-based processing is needed and allocate memory efficiently, avoiding the excessive memory requirements of traditional hash-based approaches for large numbers of groups

Inventive Principle:
Principle #10Preliminary action

Data Source

PatentUS11194778B2Method and system for hybrid sort and hash-based query execution
Publication Date: 2021.12.07 INTERNATIONAL BUSINESS MACHINE CORPORATION
  • US11194778B2 patent drawing
  • US11194778B2 patent drawing
  • US11194778B2 patent drawing

AI summary

A database system, computer program product, and a method for evaluating aggregates in database systems includes hashing of aggregation keys on a per bucket basis, and depending on a number of hashed tuples per bucket, sorting said tuples. Additionally, depending on the number of hashed tuples per bucket, the bucket is kept without change. Moreover, depending on the number of hashed tuples per bucket, maintaining a secondary hash table for a particular bucket, map tuples to it, aggregate as you map.