SQL Query Group-By Normalization for Arithmetic Expressions

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Existing database management systems face limitations in applying early grouping transformations to SQL queries due to restrictive rules that treat all database objects in aggregate expressions as an indivisible group, preventing wider applicability and reducing the potential states considered for query rewriting, especially in cases with complex arithmetic expressions or all database objects being used in aggregate functions.

Innovation Solution

Introducing relaxed-C states that allow some tables in aggregate expressions to be included in the GBP view while others are not, enabling normalization of arithmetic expressions and applying aggregate function-specific query modification rules to split tables between the GBP view and the outer query, thereby increasing the applicability of GBP transformations and generating more potential states for cost-based optimization.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Adaptability or versatility

If all database objects in aggregate expressions are treated as an indivisible group, then query transformation rules are simpler to implement, but the applicability of GBP transformations is limited and fewer potential states are considered

Engineering Contradiction:
Improveapplicability of GBP transformationsVSAvoidcomplexity of query transformation framework
Core Design Contradiction:
Adaptability or versatilityVSDevice complexity

Solution Approach 1:

The patent segments the set of database objects referenced in aggregate expressions into two distinct groups: those included in the GBP view and those excluded. This segmentation allows the query transformation framework to consider more potential states by independently deciding which objects to include, rather than treating all objects as an indivisible group. The segmentation enables GBP transformations to be applied to a wider range of queries while maintaining manageable complexity through systematic state generation.

Inventive Principle:
Principle #1Segmentation

2Adaptability or versatility

If complex arithmetic expressions are present in aggregate functions, then query semantics become more expressive, but GBP transformations cannot be applied

Engineering Contradiction:
Improverange of queries eligible for GBPVSAvoiddifficulty of analyzing arithmetic expressions
Core Design Contradiction:
Adaptability or versatilityVSDifficulty of detecting and measuring

Solution Approach 1:

The patent extracts database objects from complex arithmetic expressions within aggregate functions and treats them as separate entities that can be independently included or excluded in the GBP view. By taking out the database objects from the arithmetic expressions, the system can analyze and transform queries with complex arithmetic without being blocked by the presence of such expressions. This extraction approach maintains semantic correctness while enabling GBP transformations.

Inventive Principle:
Principle #2Taking out (Extraction)

3Productivity

If more potential states of GBP transformation are considered, then better query optimization is achieved, but the cost-based query transformation framework becomes more computationally expensive

Engineering Contradiction:
Improvequery execution efficiencyVSAvoidtime for cost-based optimization
Core Design Contradiction:
ProductivityVSLoss of time

Solution Approach 1:

The patent performs preliminary actions by systematically generating potential GBP states based on segmented database objects before the cost-based optimization process. By pre-identifying which database objects can be included in the GBP view and generating the corresponding potential states in advance, the framework reduces the computational burden during the actual optimization phase. This preliminary segmentation and state generation enables more states to be considered without proportionally increasing the overall optimization time.

Inventive Principle:
Principle #10Preliminary action

Data Source

PatentUS11416489B2Early grouping optimization for SQL statements by normalizing arithmetic expressions in aggregates
Publication Date: 2022.08.16 ORACLE INT CORP
  • US11416489B2 patent drawing
  • US11416489B2 patent drawing
  • US11416489B2 patent drawing

AI summary

According to embodiments, a database server instance may generate group-by placement (GBP) states that define potential GBP transformations for a query in which some aggregate tables are included in the GBP view and other aggregate tables are not. Such states are referred to herein as relaxed-C states. To rewrite a query based on a selected relaxed-C GBP state such that the rewritten query is semantically equivalent to the original query, any arithmetic expression within an aggregate expression of the query is normalized into terms, and the query rewrite is implemented on a term-specific basis. Specifically, aggregate function-specific query modification rules are applied to each term of the normalized arithmetic expression. The applied query modification rules dictate what is included in the GBP view and what is included in the outer portion of the rewritten query to ensure that the rewritten query is semantically equivalent to the original query.