Imperative Code Optimization in Relational Database Engines

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Current database systems inefficiently evaluate imperative code, such as User Defined Functions (UDFs), due to iterative execution, lack of costing, limited predicate pushdown, interpreted execution, and parallelism limitations, leading to poor performance.

Innovation Solution

Converting imperative code into declarative forms using standardized relational operators, allowing query optimizers to optimize UDFs by transforming multi-statement UDFs into single relational algebra expressions, applying simplification rules, and incorporating compiler optimizations.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Productivity

If imperative code is executed using traditional iterative evaluation methods, then code modularity and reuse are maintained, but execution performance is poor due to lack of optimization

Engineering Contradiction:
Improveexecution performanceVSAvoidevaluation complexity
Core Design Contradiction:
ProductivityVSDevice complexity

Solution Approach 1:

The patent introduces an intermediary translation layer that converts imperative code into declarative SQL representations. This intermediary process enables the query optimizer to work with standardized relational operators, achieving efficient optimization without requiring changes to the original imperative code structure or losing code modularity.

Inventive Principle:
Principle #24Intermediary (Mediator)

Solution Approach 2:

The patent replaces the mechanical iterative evaluation system with a declarative query system that uses standardized relational operators. This substitution allows the query optimizer to apply sophisticated optimization techniques such as cost-based optimization, predicate pushdown, and parallel execution, dramatically improving performance.

Inventive Principle:
Principle #28Mechanics substitution (Replace mechanical system)

2Measurement precision

If fixed costs are assigned to imperative functions for query optimization, then optimization can proceed, but accuracy is poor because actual costs change over time with technology changes

Engineering Contradiction:
Improvecost estimation accuracyVSAvoidadaptability to technology changes
Core Design Contradiction:
Measurement precisionVSAdaptability or versatility

Solution Approach 1:

The patent transforms the cost estimation approach by changing the parameters from fixed static values to dynamic values derived from actual SQL operator costs. By translating imperative functions into declarative SQL representations, the system can use current, accurate cost information that reflects actual hardware and system conditions, eliminating the need for outdated fixed cost assignments.

Inventive Principle:
Principle #35Parameter changes

3Productivity

If imperative code is converted to declarative query representations, then query optimization efficiency is improved, but conversion complexity increases

Engineering Contradiction:
Improvequery optimization efficiencyVSAvoidconversion process complexity
Core Design Contradiction:
ProductivityVSDevice complexity

Solution Approach 1:

The patent creates a universal translation framework that handles multiple imperative code patterns (loops, conditionals, function calls) using a unified declarative SQL representation approach. This universal method simplifies the conversion process by providing consistent rules and patterns for translating various imperative constructs into optimized SQL, reducing the apparent complexity despite the powerful optimization capabilities enabled.

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

Data Source

PatentUS10515075B2Method for optimization of imperative code executing inside a relational database engine
Publication Date: 2019.12.24 MICROSOFT TECHNOLOGY LICENSING LLC
  • US10515075B2 patent drawing
  • US10515075B2 patent drawing
  • US10515075B2 patent drawing

AI summary

Processing a database query. A method includes receiving a database query from a user. The database query includes one or more imperative functions. The one or more imperative functions are converted to one or more declarative query representations. The one or more declarative query representations include standardized relational operators included in a relational query language. Further, the one or more declarative query representations are optimizable by a query optimizer of the database. The database query is optimized at the query optimizer to create a query plan by evaluating any declarative query representation originally in the database query received from the user and the one or more declarative query representations.