IP Library Granted Patent US 8,171,018
Granted Patent B2
US 8,171,018 · App. 12/287,152 · Granted May 1, 2012

SQL code generation for heterogeneous environment

View Patent ↗
Loading inventors, assignments & file history…
Monitor This Case
Get email alerts when status or documents change.
Order Certified Copies
Most orders are placed with the USPTO same day — all within 24 business hours.
Order via The Patent Place →
Pre-filled with this patent's details
Quick Facts
Patent No.
US 8,171,018
App. No.
12/287,152
Granted
May 1, 2012
Kind
B2
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. In one preferred embodiment, the method begins by receiving a subject query, and then forming an execution plan corresponding to the subject query. The execution plan will typically have a sequence of component snippets or pieces and corresponding processes for implementing the pieces. For at least one piece in the plan, the process then (a) generates source code using different code generation techniques as a function of expected runtime processing machine types; and then (b) compiles the generated source code to form machine executable code for implementing the subject query. As a result, the query executed directly as machine executable code thereby avoiding runtime interpretation of the pieces in the execution plan.

Claims (43)

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; and

for at least one piece of the plan, (a) generating source code corresponding to the at least one piece of the plan using at least one of a plurality of different code generation techniques being selected as a function of an expected processing machine type of a plurality of expected processing machine types; and (b) compiling the generated source code to form machine executable code for implementing the subject query, said generated source code avoiding runtime interpretation of the pieces in the execution plan,

wherein the code generated for at least one piece of the plan is cached in a centralized location to remain available to be used in processing a subsequent plan piece without rerunning the generating step.

2. A method as in claim 1 additionally comprising:

delivering the compiled machine executable code to a selected one of the processing machine types for execution.

3. A method as in claim 2 wherein the delivered machine executable code is run on the identified processing machine types to complete the query.

4. A method as in claim 1 wherein the expected processing machine type is two or more machine types to provide a heterogeneous code execution environment.

5. A method as in claim 1 additionally comprising

generating linkage information for the generated machine code.

6. A method as in claim 1 wherein the generated machine code is in a C language.

7. A method as in claim 1 wherein there are multiple expected processing machine types for executing at least one piece of the database query, and the generated machine code runs on the multiple machine types in parallel.

8. A method as in claim 1 wherein the code generation step is performed for the subsequent piece without recompiling the code.

9. A method as in claim 1 wherein the query language specifies arithmetic operations at a query language precision level, and wherein the generating step generates only instructions that are carried out using native data types of the target processing machine types.

10. A method as in claim 1 wherein the target processing machines have different numbers of general purpose registers (GPRs), and the compiling step tracks register usage differently for the different target processing machines.

11. A method as in claim 1 wherein the query language specifies arithmetic operations at a query language precision level, and wherein the generating step generates instructions carried out at a precision level determined from statistics of data stored in the database.

12. A method as in claim 1 wherein the generated source code includes human readable code containing comments for later analysis.

13. A method as in claim 1 wherein the generated code includes human readable source code having variable names that follow a predefined convention.

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;

forming an execution plan corresponding to the subject query, the execution plan having a sequence of pieces and corresponding processes for implementing the pieces; and

for at least several identified pieces of the plan, (a) generating source code corresponding to the several identified pieces of the plan, with the source code generated for at least one identified subsequent piece of the plan being dependent upon the results of code generated for a another identified prior piece of the plan to be executed prior to the identified piece of the plan, wherein the source code generation uses at least one of a plurality of different code generation techniques being selected as a function of an expected processing machine type of a plurality of expected processing machine types; and (b) compiling the generated source code to form machine executable code for implementing the subject query, said generated source code avoiding runtime interpretation of the at least several pieces in the execution plan.

15. A method as in claim 14 wherein the code for the subsequent piece of the plan is not generated until after execution of the prior piece of the plan.

16. A method as in claim 14 wherein the code for the subsequent piece of the plan is not generated until a prior piece of the plan is executing.

17. A method as in claim 14 wherein the code for the subsequent piece of the plan is not generated until a run time for the piece occurs.

18. A method as in claim 17 wherein the delivered machine executable code is run on the identified processing machine types to complete the query.

19. A method as in claim 14 wherein the expected processing machine type is two or more machine types to provide a heterogeneous code execution environment.

20. A method as in claim 14 further including delivering the compiled machine executable code to a selected one of the processing machine types for execution.

21. A system for processing a query on a database comprising:

at least one computer having a memory;

a plurality of database operation processor components, with at least two of the database operation processor components having different operation processing capabilities, such that the database operation processor components provide at least two different locales for executing database operations, with the two locales having different operation processing capabilities and such that more than one database operation processor component locale is executing a given selected database operation;

a database catalog comprising database table information, database operation processor component locale information, and database operation processor characteristic information;

a query optimizer receiving the query and accessing the database catalog to develop a query execution plan, the query execution plan defining two or more plan pieces that include database operations to carry out the query, and the query execution plan also defining a respective database operation processor component locale at which to carry out each such database operation in the query execution plan, by comparing the processing capabilities of the different locale types for the database operation; and

for at least one piece of the query execution plan, (a) generating source code corresponding to the at least one piece of the plan using at least one of a plurality of different code generation techniques being selected as a function of specified locale types of a plurality of specified locale types; and (b) compiling the generated source code to form machine executable code for implementing the query execution plan, said generated source code avoiding runtime interpretation of the query execution plan pieces.

22. A computer program product for generating machine executable code for implementing a query of a database, the database having tables and records of data, comprising:

a non-transitory computer readable storage medium having computer readable program code embodied therewith, the computer readable program code configured to:

receive a subject query;

form an execution plan corresponding to the subject query, the execution plan having a sequence of pieces and corresponding processes for implementing the pieces; and

for at least several identified pieces of the plan, (a) generate source code corresponding to the several identified pieces of the plan, with the source code generated for at least one identified subsequent piece of the plan being dependent upon the results of code generated for a another identified prior piece of the plan to be executed prior to the identified piece of the plan, wherein the source code generation uses at least one of a plurality of different code generation techniques being selected as a function of an expected processing machine type of a plurality of expected processing machine types; and (b) compile the generated source code to form machine executable code for implementing the subject query, said generated source code avoiding runtime interpretation of the at least several pieces in the execution plan.

23. A computer program product as in claim 22 wherein the code for the subsequent piece of the plan is not generated until after execution of the prior piece of the plan.

24. A computer program product as in claim 22 wherein the code for the subsequent piece of the plan is not generated until a prior piece of the plan is executing.

25. A computer program product as in claim 22 wherein the code for the subsequent piece of the plan is not generated until a run time for the piece occurs.

Assignments (7)
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded May 26, 2021
From: SOFTWARE LABS CAMPUS UNLIMITED COMPANY
To: INTERNATIONAL BUSINESS MACHINES CORPORATION
Reel/Frame 056396/0942 →
CORRECTIVE ASSIGNMENT TO CORRECT THE 4 ERRONEOUSLY LISTED PATENTS ON SCHEDULE A. PREVIOUSLY RECORDED AT REEL: 053452 FRAME: 0580. ASSIGNOR(S) HEREBY CONFIRMS THE ASSIGNMENT . Recorded Jan 29, 2021
From: IBM TECHNOLOGY CORPORATION
To: SOFTWARE LABS CAMPUS UNLIMITED COMPANY
Reel/Frame 055171/0693 →
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Aug 11, 2020
From: IBM TECHNOLOGY CORPORATION
To: SOFTWARE LABS CAMPUS UNLIMITED COMPANY
Reel/Frame 053452/0580 →
NUNC PRO TUNC ASSIGNMENT Recorded Dec 17, 2018
From: IBM INTERNATIONAL GROUP B.V.
To: IBM INTERNATIONAL C.V.
Reel/Frame 047794/0779 →
NUNC PRO TUNC ASSIGNMENT Recorded Dec 17, 2018
From: IBM INTERNATIONAL C.V.
To: IBM ATLANTIC C.V.
Reel/Frame 047794/0927 →
NUNC PRO TUNC ASSIGNMENT Recorded Dec 17, 2018
From: IBM ATLANTIC C.V.
To: IBM TECHNOLOGY CORPORATION
Reel/Frame 047795/0001 →
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Feb 2, 2012
From: NETEZZA CORPORATION
To: IBM INTERNATIONAL GROUP B.V.
Reel/Frame 027642/0172 →