Query Plan Native Code Compilation for Database Execution Speed
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Traditional query processors use inefficient interpreter-based execution strategies for database queries, leading to slow processing times due to the need for static code interpretation and lack of native machine code execution.
Innovation Solution
Converting query plans into native machine code using a compiler backend and programmatic control flow, such as labels and goto statements, to instantiate code templates that perform the functionality of operators with specific operational parameters, thereby bypassing intermediate steps and optimizing execution.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Ease of operation
If interpreter-based execution strategies are used for query processing, then language compatibility and ease of operation are maintained, but execution speed and productivity deteriorate
Solution Approach 1:
The patent creates native code copies of query execution plans. Instead of interpreting SQL queries directly, the system compiles query plans into native machine code that can be executed directly by the processor, eliminating the interpretation overhead while preserving the high-level query language interface for users
Solution Approach 2:
The patent replaces the mechanical interpretation process with a compilation and direct execution model. The interpreter-based mechanical execution of instructions is substituted by compiling query plans into native code that the processor can execute directly, significantly improving execution speed
2Productivity
If native code compilation is used for query execution, then execution speed improves, but device complexity and manufacturing precision requirements increase
Solution Approach 1:
The patent segments the query processing system into distinct components: query parsing, query optimization, code generation, and execution. Each component handles a specific aspect of query processing, allowing the complex task of query execution to be divided into manageable segments that can be optimized independently
Solution Approach 2:
The patent performs query compilation and code generation in advance, before actual query execution. Query plans are compiled into native code templates that are stored and reused, eliminating the need for repeated compilation and interpretation during query execution, thus reducing runtime complexity
3Productivity
If query plans are converted to native code templates, then execution efficiency improves, but code generation complexity and time increase
Solution Approach 1:
The patent performs query compilation and native code generation in advance, before actual query execution. Query plans are compiled into native code templates that are stored and reused, eliminating the need for repeated compilation and interpretation during query execution
Solution Approach 2:
The patent creates universal code templates that can handle multiple similar query operations. Once a query plan is compiled into native code, the resulting template can be reused for executing similar queries, amortizing the code generation time across multiple executions and improving overall efficiency
Data Source
AI summary
Performing database queries. A method includes receiving a particular database query. The method further includes accessing a query plan based on the particular database query. The query plan has operators and specific operational parameters associated with each of the operators. The association of operators and specific operational parameters is specific to the particular database query. From the query plan, the method further includes instantiating a plurality of compiled code templates. Each code template includes executable code that when executed performs functionality of one of the operators from the query plan with the specific operational parameters applied in the compilation. The method further includes binding the code templates together using programmatic control flow to create a functioning program.


