IP Library Granted Patent US 10,031,940
Granted Patent B2
US 10,031,940 · App. 14/864,289 · Granted Jul 24, 2018

System and method for database query

Inventors: Cheng Zhu (San Jose, CA); Yonghua Ding (San Jose, CA); Guogen Zhang (San Jose, CA)
Assignee: Futurewei Technologies, Inc.
G06F17/30442G06F17/30463G06F17/30569
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 10,031,940
App. No.
14/864,289
Granted
Jul 24, 2018
Kind
B2
Abstract

A method includes receiving, by a database system, a query statement and forming a runtime plan tree in accordance with the query statement. The method also includes traversing the runtime plan tree including determining whether a function node of the runtime plan tree is qualified for just-in-time (JIT) compilation. Additionally, the method includes, upon determining that the function node is a qualified for JIT compilation producing a string key in accordance with a function of the function node and determining whether a compiled object corresponding to the string key is stored in a compiled object cache.

Claims (51)

1. A method comprising:

receiving, by a database system, a query;

forming a runtime plan tree corresponding to the query for executing the query, the runtime plan tree comprising a plurality of function nodes corresponding to functions to be executed for executing the query;

traversing the runtime plan tree, comprising:

determining whether a first function node of the runtime plan tree supports code generation and just-in-time (JIT) compilation; and

upon determining that the first function node supports the code generation and JIT compilation, translating a first function of the first function node into a first string key; and

determining whether a first compiled object corresponding to the first string key is stored in a compiled object cache, the compiled object cache comprising a plurality of compiled objects corresponding to query functions that have been compiled, and each of the plurality of compiled objects being associated with a string key, wherein each of the plurality of compiled objects is reusable for executing queries that comprise a corresponding query function; and

executing the query, comprising executing the first function by directly executing the first compiled object without compiling the first function when the first compiled object is stored in the compiled object cache, and wherein traversing the runtime plan tree further comprises:

machine code just-in-time (MCJIT) compiling a low level virtual machine (LLVM) intermediate representation (IR) format function to produce a compiled object, wherein the LLVM IR format function corresponds to a query function; and

storing the compiled object in the compiled object cache.

2. The method of claim 1 , further comprising performing runtime execution after traversing the runtime plan tree.

3. The method of claim 1 , wherein determining whether the first function node supports the code generation and JIT compilation comprises performing a central processing unit (CPU) profiling analysis.

4. The method of claim 1 , further comprising determining whether initialization of the runtime plan tree is complete.

5. The method of claim 4 , further comprising performing runtime execution upon determining that the initialization of the runtime plan tree is complete.

6. The method of claim 1 , wherein traversing the runtime plan tree further comprises, upon determining that the first compiled object corresponding to the first string key is in the compiled object cache:

retrieving the first compiled object from the compiled object cache in accordance with the first string key; and

setting a function pointer to the first compiled object.

7. The method of claim 6 , wherein traversing the runtime plan tree further comprises, upon determining that the first compiled object is in the compiled object cache:

remapping symbols for the first compiled object; and

relocating an address of symbols for the first compiled object.

8. The method of claim 1 , wherein traversing the runtime plan tree further comprises, upon determining that the first compiled object is not in the compiled object cache, generating a first LLVM IR format function in accordance with the first function of the first function node.

9. The method of claim 1 , wherein traversing the runtime plan tree further comprises setting a function pointer to a compiled object in the compiled object cache.

10. The method of claim 1 , wherein MCJIT compiling the LLVM IR format function comprises compiling a set of functions that comprises a plurality of fragments of a query plan.

11. A computer comprising:

a compiled object cache comprising a plurality of compiled objects corresponding to query functions that have been compiled, each of the plurality of compiled objects being associated with a string key, and being reusable for executing queries that comprise a corresponding query function;

a processor coupled to the compiled object cache; and

a non-transitory computer readable storage medium storing programming for execution by the processor, the programming including instructions to:

receive a query,

form a runtime plan tree corresponding to the query for executing the query, the runtime plan tree comprising a plurality of function nodes corresponding to functions to be executed for executing the query, traverse the runtime plan tree, the instructions comprising further instructions to:

determine whether a first function node of the runtime plan tree supports code generation and just-in-time (JIT) compilation, and

upon determining that the first function node supports the code generation and JIT compilation, translate a first function of the first function node into a first string key, and

determine whether a first compiled object corresponding to the first string key is stored in the compiled object cache; and

execute the query, wherein the first function is executed by directly executing the first compiled object without compiling the first function when the first compiled object is stored in the compiled object cache, and wherein the instructions to traverse the runtime plan tree further comprise instructions to:

machine code just-in-time (MCJIT) compile a low level virtual machine (LLVM) intermediate representation (IR) format function to produce a compiled object, wherein the LLVM IR format function corresponds to a query function; and

store the compiled object in the compiled object cache.

12. The computer of claim 11 , wherein whether the first function node supports the code generation and JIT compilation is determined by performing a central processing unit (CPU) profiling analysis.

13. The computer of claim 11 , wherein the instructions further comprise instructions to determine whether initialization of the runtime plan tree is complete.

14. The computer of claim 11 , wherein the instructions to traverse the runtime plan tree further comprise instructions to, upon determining that the first compiled object corresponding to the first string key is in the compiled object cache,

retrieve the first compiled object from the compiled object cache in accordance with the first string key; and

set a function pointer to the first compiled object.

15. The computer of claim 11 , wherein the instructions to traverse the runtime plan tree further comprise instructions to, upon determining that the first compiled object is not in the compiled object cache, generate a first LLVM IR format function in accordance with the first function of the first function node.

16. The computer of claim 11 , wherein the instructions to traverse the runtime plan tree further comprise instructions to set a function pointer to a compiled object in the compiled object cache.

17. The computer of claim 11 , wherein the instructions to MCJIT compile the LLVM IR format function comprise instructions to compile a set of functions comprising a plurality of fragments of a query plan.

18. A non-transitory computer readable storage medium storing programming for execution by a processor, the programming including instructions for:

receiving, by a database system, a query;

forming a runtime plan tree corresponding to the query for executing the query, the runtime plan tree comprising a plurality of function nodes corresponding to functions to be executed for executing the query;

traversing the runtime plan tree, comprising:

determining whether a first function node of the runtime plan tree supports code generation and just-in-time (JIT) compilation, and upon determining that the first function node supports the code generation and JIT compilation: translating a first function of the first function node into a first string key, and determining whether a first compiled object corresponding to the first string key is stored in a compiled object cache, the compiled object cache comprising a plurality of compiled objects corresponding to query functions that have been compiled, and each of the plurality of compiled objects being associated with a string key, wherein each of the plurality of compiled objects is reusable for executing queries that comprise a corresponding query function; and

executing the query, comprising executing the first function by directly executing the first compiled object without compiling the first function when the first compiled object is stored in the compiled object cache, and wherein traversing the runtime plan tree further comprises:

machine code just-in-time (MCJIT) compiling a low level virtual machine (LLVM) intermediate representation (IR) format function to produce a compiled object, wherein the LLVM IR format function corresponds to a query function; and

storing the compiled object in the compiled object cache.

Assignments (1)
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Sep 24, 2015
From: ZHU, CHENG; DING, YONGHUA; ZHANG, GUOGEN
To: FUTUREWEI TECHNOLOGIES, INC.
Reel/Frame 036649/0784 →
Continuity (1)
Related Publication 20170091269A1 · Mar 30, 2017