Optimized SQL code generation
First Claim
1. A method for generating machine executable code for implementing a query of a database, the database having tables and records of data, comprising the steps of:
- receiving a subject query;
forming an execution plan corresponding to the subject query, the execution plan having a sequence of pieces and corresponding processes for implementing the pieces;
for each piece of the plan, (a) generating source code using different code generation techniques as a function of any combination of data characteristics, current conditions and workload, and (b) compiling the generated source code to form machine executable code for implementing the subject query, said compiling being in a manner that optimizes total query processing time, including, compilation time and execution time,wherein the subject query includes a join operation; and
wherein the step of generating source code includes (a) representing output stream of the join operation as local variables that reference current records in each input stream, and (b) projecting named fields of the records, such that use of intermediate materialization and auxiliary structures are minimized, the step of projecting includes utilizing structure offset expressions in the generated source code.
8 Assignments
0 Petitions
Accused Products
Abstract
This invention relates generally to a system for processing database queries, and more particularly to a method for generating high level language or machine code to implement query execution plans. The present invention provides a method for generating executable machine code for query execution plans, that is adaptive to dynamic runtime conditions, that is compiled just in time for execution and most importantly, that avoids the bounds checking, pointer indirection, materialization and other similar kinds of overhead that are typical in interpretive runtime execution engines.
178 Citations
17 Claims
-
1. A method for generating machine executable code for implementing a query of a database, the database having tables and records of data, comprising the steps of:
-
receiving a subject query; forming an execution plan corresponding to the subject query, the execution plan having a sequence of pieces and corresponding processes for implementing the pieces; for each piece of the plan, (a) generating source code using different code generation techniques as a function of any combination of data characteristics, current conditions and workload, and (b) compiling the generated source code to form machine executable code for implementing the subject query, said compiling being in a manner that optimizes total query processing time, including, compilation time and execution time, wherein the subject query includes a join operation; and wherein the step of generating source code includes (a) representing output stream of the join operation as local variables that reference current records in each input stream, and (b) projecting named fields of the records, such that use of intermediate materialization and auxiliary structures are minimized, the step of projecting includes utilizing structure offset expressions in the generated source code. - View Dependent Claims (2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13)
-
-
14. A method for generating machine executable code for implementing a query of a database, the database having tables and records of data, comprising the steps of:
-
receiving a subject query having a join operation; forming an execution plan corresponding to the subject query, the execution plan having a sequence of pieces and corresponding processing nodes for implementing the pieces; generating high level language source code for each piece of the plan including (a) minimally defining relevant structures and classes, and (b) forming therefrom optimized Include statements in the source code; and compiling the generated source code to form machine executable code for implementing the subject query, the formed optimized Include statements in the source code enabling relatively reduced compilation time, the step of generating high level language source code includes (a) representing output stream of the join operation as local variables that reference current records in each input stream, and (b) projecting named fields of the records, such that use of intermediate materialization and auxiliary structures are minimized, the step of projecting includes utilizing structure offset expressions in the generated source code. - View Dependent Claims (15, 16, 17)
-
Specification