SQL Logical Plan Deduplication for Repeated Subqueries

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Data platforms face inefficiencies in handling repeated subqueries in complex SQL statements, leading to slower query execution times and increased resource consumption, particularly in distributed computing environments.

Innovation Solution

A client system generates an optimized query by identifying and replacing duplicate subqueries in a logical plan tree with optimized subqueries, using Common Table Expressions (CTEs) to eliminate redundant computations.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Productivity

If traditional query execution methods are used, then queries can be executed without optimization, but query execution times increase and resource consumption increases due to repeated subqueries

Engineering Contradiction:
Improvequery execution speedVSAvoidresource consumption
Core Design Contradiction:
ProductivityVSLoss of energy

Solution Approach 1:

The patent merges duplicate subqueries into a single execution unit by identifying identical subquery patterns in the logical plan tree and consolidating them. This consolidation eliminates redundant computations while maintaining query functionality, directly reducing resource consumption and improving execution speed.

Inventive Principle:
Principle #5Merging (Combining)

Solution Approach 2:

The system performs preliminary optimization by analyzing the logical plan tree before query execution, identifying duplicate subqueries in advance, and replacing them with optimized versions. This pre-processing step prevents redundant computations during actual query execution, thereby improving productivity and reducing resource loss.

Inventive Principle:
Principle #10Preliminary action

2Productivity

If manual query optimization is performed, then query performance can be improved, but the complexity of operation increases and requires extensive expertise

Engineering Contradiction:
Improvequery execution speedVSAvoidease of query optimization
Core Design Contradiction:
ProductivityVSEase of operation

Solution Approach 1:

The system implements self-service optimization by automatically analyzing queries, identifying duplicate subqueries, and generating optimized execution plans without human intervention. This automation eliminates the need for manual optimization expertise while maintaining high query performance, thereby improving ease of operation.

Inventive Principle:
Principle #25Self-service

Solution Approach 2:

The system incorporates feedback mechanisms that analyze query patterns and execution results to continuously improve optimization strategies. By automatically learning from execution feedback, the system refines its optimization capabilities without requiring manual tuning or expert intervention, making the process easier to operate.

Inventive Principle:
Principle #23Feedback

3Power

If distributed computing environments are used, then data processing capacity increases, but resource consumption increases due to repeated subquery execution across multiple nodes

Engineering Contradiction:
Improvedata processing capacityVSAvoidresource consumption
Core Design Contradiction:
PowerVSLoss of energy

Solution Approach 1:

In distributed computing environments, the patent merges duplicate subqueries across multiple computing nodes by identifying and consolidating identical subquery patterns. This ensures that each unique subquery is executed only once or minimized across the distributed architecture, reducing redundant resource consumption while maintaining the enhanced processing capacity provided by distribution.

Inventive Principle:
Principle #5Merging (Combining)

Solution Approach 2:

The optimization approach creates universal subquery execution plans that can be applied across multiple distributed nodes. By generating optimized subqueries that serve multiple purposes and can be reused across different nodes, the system maximizes the utility of each computation, reducing overall resource consumption while maintaining distributed processing power.

Inventive Principle:
Principle #6Universality (Multi-functionality)

Data Source

PatentUS20260064678A1Generating high-performance queries using optimized subqueries
Publication Date: 2026.03.05 SNOWFLAKE INC
  • US20260064678A1 patent drawing
  • US20260064678A1 patent drawing
  • US20260064678A1 patent drawing

AI summary

A client system of a computing environment including a data platform is provided that optimizes a database query. The client system creates a logical plan tree for a Structured Query Language (SQL) query, with the logical plan tree comprising a set of nodes. The client system identifies a set of duplicate nodes in the set of nodes of the logical plan tree and identifies a duplicate subtree in the logical plan tree by determining a set of root nodes of the duplicate subtree using parent-child relationships of the set of nodes. The client system generates an optimized query by replacing instances of subqueries represented by the duplicate subtree using a set of optimized subqueries. The client system communicates the optimized query to the data platform for execution.