Execution method of actuator and related device

Through just-in-time compilation and AVX instruction set optimization, tuples are cached and processed in batches, which solves the performance bottleneck in CPU utilization of the traditional volcano iterative execution model and improves executor efficiency and query performance.

CN114579613BActive Publication Date: 2024-09-27ZHEJIANG DAHUA TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210068418.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-01-20
Publication Date
2024-09-27
Estimated Expiration
2042-01-20

AI Technical Summary

Technical Problem

The traditional volcano iterative execution model is difficult to fully utilize the CPU under modern hardware, resulting in query performance bottlenecks, especially in distributed relational databases that are difficult to optimize.

Method used

By obtaining the execution plan tree, using just-in-time compilation technology to generate logical code, caching and processing tuples in batches, supporting the AVX instruction set for single-instruction multi-data stream operations, optimizing the expressions of selected and projected nodes, thereby improving the execution efficiency of the executor .

Benefits of technology

On the basis of maintaining compatibility, the execution efficiency of the executor is improved, branch judgments and useless machine instructions are reduced, query performance is optimized, and there is no need to redesign the executor architecture or data storage format.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114579613B
    Figure CN114579613B
Patent Text Reader

Abstract

The present application discloses an execution method of an executor and a related device, the execution method comprising: obtaining an execution plan tree; wherein the execution plan tree comprises a scan plan node and an aggregation plan node, and the nodes associated with the scan plan node comprise a selection node and a projection node; obtaining and caching a first target tuple corresponding to a first logic code from a database through the selection node to generate a first tuple set; in response to the cached first target tuple in the first tuple set exceeding a threshold, sending the first tuple set to a projection node and projecting the first target tuple according to a second logic code to obtain a plurality of corresponding second target tuples; wherein the first logic code and the second logic code are respectively generated by just-in-time compilation of a selection expression of a selection node and a projection expression of a projection node; returning the plurality of second target tuples to the aggregation plan node for aggregation processing, and optimizing the execution speed on the basis of retaining the executor function and compatibility.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of database executors, and in particular to an execution method of an executor and related devices. Background Art

[0002] A commonly used executor implementation in the database industry is the Volcano Model, also known as the iterator model. The typical feature of this model is that it is recursively interpreted and executed from top to bottom based on the execution plan tree, and each top-to-bottom iteration result only returns a tuple. At the same time, each operator node in the execution plan tree often contains relational algebra operations such as selection (σ) and projection (Π), which means a lot of calculations. However, this model is difficult to fully utilize the CPU to improve execution efficiency, so it often becomes one of the bottlenecks of query performance in the context of modern hardware.

[0003] At present, the mainstream executor optimization directions for this problem are: (1) compiling execution to replace the original interpreted execution; (2) vectorizing operations to replace the original single iteration. However, these two types of technologies are only applicable to the implementation of new databases. For the volcano iterative execution model that has been implemented in traditional relational databases, it is often difficult to re-implement it for distributed relational databases. Therefore, a new executor execution method is urgently needed to solve the above problems. Summary of the invention

[0004] The main technical problem solved by the present application is to provide an execution method of an actuator and related devices, which can optimize the execution speed of the actuator.

[0005] To solve the above technical problems, a technical solution adopted in the present application is: to provide an execution method of an executor, comprising: obtaining an execution plan tree; wherein the execution plan tree comprises a scan plan node and an aggregation plan node, and the nodes associated with the scan plan node comprise a selection node and a projection node; obtaining and caching a first target tuple corresponding to a first logic code from a database through the selection node to generate a first tuple set; in response to the first target tuple cached in the first tuple set exceeding a threshold, sending the first tuple set to the projection node and projecting the first target tuple according to a second logic code to obtain a plurality of corresponding second target tuples; wherein the first logic code and the second logic code are respectively generated by just-in-time compilation of a selection expression of the selection node and a projection expression of the projection node; and returning the plurality of second target tuples to the aggregation plan node for aggregation processing.

[0006] Among them, before the step of obtaining and caching the first target tuple corresponding to the first logic code from the database through the selection node to generate a first tuple set, it includes: obtaining all scan plan nodes in the execution plan tree; in response to the global switch variable controlling the just-in-time compilation to be turned on and the scan plan node supporting just-in-time compilation, initializing the scan plan node to obtain the first logic code and the second logic code.

[0007] Among them, the step of initializing the scan plan node to obtain the first logic code and the second logic code includes: in response to the selection node needing to be just-in-time compiled and the selection node being able to be just-in-time compiled, the selection expression is just-in-time compiled to generate the first logic code; in response to the projection node being able to be just-in-time compiled, the projection expression is just-in-time compiled to generate the second logic code.

[0008] Among them, in response to the selection node needing to be just-in-time compiled and the selection node being able to be just-in-time compiled, the step of just-in-time compiling the selection expression of the selection node to generate the first logic code includes: in response to the selection expression being a first operation type and satisfying a preset complexity, determining that the selection node needs to be just-in-time compiled and the selection node being able to be just-in-time compiled, and just-in-time compiling the selection expression to generate the first logic code corresponding to the selection expression.

[0009] Among them, in response to the projection node being able to be just-in-time compiled, the step of just-in-time compiling the projection expression of the projection node to generate the second logic code includes: in response to the projection expression being a second operation type, determining that the projection node can be just-in-time compiled, and just-in-time compiling the projection expression to generate the second logic code corresponding to the projection expression.

[0010] Among them, before the step of just-in-time compiling the projection expression of the projection node to generate the second logic code in response to the projection node being able to be just-in-time compiled, it also includes: in response to the global switch variable being set to correct and the data contained in the first target tuple being a first data type, marking the associated variable of the scan plan node as correct, and entering the step of just-in-time compiling the projection expression of the projection node to generate the second logic code in response to the projection node being able to be just-in-time compiled.

[0011] Among them, the step of obtaining and caching the first target tuple corresponding to the first logic code from the database through the selection node to generate a first tuple set includes: obtaining the first target tuple corresponding to the first logic code from the database through the selection node; in response to the associated variable of the scan plan node being marked as correct and the cache context of the scan plan node satisfying a first preset condition, converting the first target tuple and saving it to the cache context to generate a first tuple set.

[0012] Wherein, before the step of obtaining the execution plan tree, it includes: in response to the central processing unit of the executor supporting the AVX instruction set, setting the global switch variable to correct, and entering the step of running the database; in response to the central processing unit of the executor not supporting the AVX instruction set, setting the global switch variable to error, and entering the step of running the database.

[0013] To solve the above technical problems, another technical solution adopted in the present application is: to provide an executor, comprising a memory and a processor coupled to each other, wherein the memory stores program instructions, and the processor is used to execute the program instructions to implement the execution method of the executor mentioned in any of the above embodiments.

[0014] In order to solve the above technical problems, another technical solution adopted in the present application is: providing a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and the computer program is used to implement the execution method of the executor mentioned in any of the above embodiments.

[0015] Different from the prior art, the beneficial effect of the present application is that the execution method provided by the present application includes: obtaining an execution plan tree; wherein the execution plan tree includes a scan plan node and an aggregation plan node, and the nodes associated with the scan plan node include a selection node and a projection node; obtaining and caching the first target tuple corresponding to the first logic code from the database through the selection node to generate a first tuple set; in response to the cached first target tuple in the first tuple set exceeding the threshold, sending the first tuple set to the projection node and projecting the first target tuple according to the second logic code to obtain a plurality of corresponding second target tuples; wherein the first logic code and the second logic code are respectively generated by just-in-time compilation of the selection expression of the selection node and the projection expression of the projection node; returning the plurality of second target tuples to the aggregation plan node for aggregation processing. Through such a design method, the execution efficiency of the executor can be improved on the basis of maintaining the original compatibility, and there is no need to redesign a new executor architecture and a new data storage format. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work. Among them:

[0017] Figure 1 It is an overall schematic diagram of the execution method of the traditional actuator;

[0018] Figure 2 It is the overall flow chart of the execution method of the executor of this application;

[0019] Figure 3 It is an overall schematic diagram of the execution method of the executor of the present application;

[0020] Figure 4 It is a flowchart of an implementation method of an execution device of the present application;

[0021] Figure 5 yes Figure 4 A schematic diagram of a flow chart of an implementation method before step S1;

[0022] Figure 6 yes Figure 4 A schematic diagram of a process flow of an implementation method before step S2;

[0023] Figure 7 yes Figure 6 A schematic diagram of a flow chart of an implementation method of step S22;

[0024] Figure 8 yes Figure 7 A schematic flow chart of an implementation method of steps S220-S222;

[0025] Fig. 9 yes Figure 7 A schematic flow chart of an implementation method of steps S223-S225;

[0026] Fig.10 yes Figure 7 A schematic diagram of a flow chart of an implementation method before step S223;

[0027] Fig.11 yes Figure 4 A schematic flow chart of an implementation method of step S2 in FIG.

[0028] Fig.12 It is a structural schematic diagram of an implementation method of an actuator of the present application;

[0029] Fig.13 It is a schematic diagram of a framework of an implementation method of an actuator of the present application;

[0030] Fig.14 It is a schematic diagram of a framework of an implementation scheme of a computer-readable storage medium of the present application. DETAILED DESCRIPTION

[0031] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0032] The executor of the open source distributed database (Greenplum) uses the volcano execution model with tuples as the flow. For databases similar to this, see Figure 1 , Figure 1 This is a schematic diagram of the execution method of the traditional executor. For example, if the structured query language (SQL) is: SELECT avg(score*score)FROM t WHERE id>1000, Figure 1 As shown in the figure, in the scan plan node (Scan), each time the table t is scanned to obtain a tuple (tuple), if the tuple satisfies the selection expression σ (id>1000) of the selection node (Selection), the tuple is sent to the projection node for projection (Projection) according to the projection expression π (score^2) of the projection node, and then the projected new tuple is immediately returned to the aggregation plan node (Aggregate) for aggregation processing, and the aggregation processing expression is AVG. However, this traditional execution method has performance problems such as not being able to make good use of the CPU cache (cache) and not being able to use single instruction multiple data stream (SIMD) instructions for unit group operations.

[0033] The following is an introduction to the execution method of the actuator in this application.

[0034] See also Figure 2-Figure 3 , Figure 2 It is the overall flow chart of the execution method of the executor of this application. Figure 3 This is a schematic diagram of the execution method of the executor of this application. Specifically, the overall execution process of the executor is: start → given the execution plan tree generated by the optimizer → executor initial stage → executor execution stage → executor execution end → end. This application only involves database executor optimization, not database optimizer optimization and storage layer optimization. Figure 3As shown, after the scan plan node (Scan) obtains the tuples that satisfy the selection expression and complete the projection, it does not return them to the upper node immediately. Instead, the tuple is cached until it reaches a certain number or size, and then returned to the upper layer at one time. The upper layer performs the specified single instruction multiple data stream (SIMD) operation based on the obtained batch of tuples. The projection operation performed inside the scan plan node can also be processed in batches as needed. In this way, in the above structured query language (SQL) example, the projection (score*score) can be batched using instructions such as AVX512mul, and the results can be cached and aggregated in batches. The selection node will only perform general just-in-time compilation (JIT) operations, that is, traverse the selection expression of the selection node and dynamically convert it from interpreted execution to compiled execution, which can effectively reduce branch judgments and remove useless machine instructions, thereby optimizing the execution speed.

[0035] The following describes the specific implementation method of the actuator provided by this application. Figure 4 , Figure 4 It is a flowchart of an implementation method of an execution device of the present application. The execution method includes:

[0036] S1: Get the execution plan tree.

[0037] Specifically, in this embodiment, the above-mentioned plan execution tree is generated by the optimizer, and the execution plan tree includes a scan plan node and an aggregation plan node, and the nodes associated with the scan plan node include a selection node and a projection node. Specifically, the execution plan tree is traversed and the plan nodes (scan plan nodes and aggregation plan nodes) therein are iteratively executed.

[0038] Specifically, in this embodiment, when the database is started, in order to maintain the functionality and compatibility of the actuator itself, the features in this application need to be controlled and enabled by multiple switch variables. Figure 5 , Figure 5 yes Figure 4 Schematic diagram of a flow chart of an implementation method before step S1. Specifically, before step S1 includes:

[0039] S10: Determine whether the central processing unit of the executor supports the AVX instruction set.

[0040] Specifically, in this embodiment, the AVX instruction set can be AVX2, AVX128, AVX512, etc., which can be selected according to actual conditions, and this application does not limit it here.

[0041] S11: If yes, set the global switch variable to correct and enter the step of running the database.

[0042] Specifically, if the central processing unit (CPU) of the executor supports the AVX instruction set, the global switch variable (jit_simd) is set to true (true), and the step of running the database is entered. Since the single instruction multiple data stream (SIMD) operation requires the central processing unit to support at least one of the AVX instruction sets, a detection judgment is performed when the database is started.

[0043] S12: Otherwise, the global switch variable is set to error and the step of running the database is entered.

[0044] Specifically, if the central processor of the executor does not support the AVX instruction set, the global switch variable (jit_simd) is set to an error (false), a warning (warning) is printed, and the step of running the database is entered.

[0045] S2: Obtain and cache a first target tuple corresponding to the first logic code from a database through a selection node to generate a first tuple set.

[0046] Specifically, in this embodiment, the first logic code and the second logic code are generated by just-in-time compilation of the selection expression of the selection node and the projection expression of the projection node. The operation function is dynamically converted from interpreted execution to compiled execution through just-in-time compilation, which can effectively reduce branch judgments and remove useless machine instructions, thereby optimizing the execution speed.

[0047] Specifically, in this embodiment, before entering the executor execution phase, an executor initialization phase is also included. Figure 6 , Figure 6 yes Figure 4 Schematic diagram of a flow chart of an implementation method before step S2. Specifically, before step S2 includes:

[0048] S20: Obtain all scan plan nodes in the execution plan tree.

[0049] Specifically, the execution plan tree generated by the optimizer is traversed to obtain all plan nodes in the above execution plan, and these plan nodes, especially the scan plan nodes, are initialized by default.

[0050] S21: Determine whether the global switch variable controls the start of the just-in-time compilation and whether the scan plan node supports the just-in-time compilation.

[0051] Specifically, the global switch variable can control the opening of multiple operations or instructions. When it is determined that the scan plan node supports just-in-time compilation, the just-in-time compilation operation can be performed, and its interpreted execution is dynamically converted into compiled execution, thereby optimizing the execution speed of the executor.

[0052] S22: If yes, the scan plan node is initialized to obtain the first logic code and the second logic code.

[0053] Specifically, if the global switch variable controls the on-the-fly compilation and the scan plan node supports the on-the-fly compilation, the selection node and the projection node associated with the scan plan node are initialized respectively to obtain the first logic code and the second logic code respectively.

[0054] S23: Otherwise, the initialization of the current plan node is completed and it is determined whether there is a next plan node.

[0055] S24: If yes, return to step S21.

[0056] Specifically, if there is a next plan node that needs to be initialized, the process returns to step S21 and performs default initialization processing on the plan node.

[0057] S25: Otherwise, the actuator initialization ends.

[0058] Specifically, if there is no next plan node, it means that the executor initialization is completed.

[0059] Further, after determining that the global switch variable controls the on-the-fly compilation and the scan plan node supports the on-the-fly compilation, it is necessary to confirm the necessity and feasibility of the on-the-fly compilation of the selection node associated with the scan plan node and the feasibility of the on-the-fly compilation of the projection node. Figure 7 , Figure 7 yes Figure 6 Schematic diagram of a flow chart of an implementation method of step S22 in FIG. Specifically, step S22 includes:

[0060] S220: Determine whether the selected node needs to be compiled in real time and whether the selected node can be compiled in real time.

[0061] S221: If yes, the selected expression is compiled in real time to generate a first logic code.

[0062] Specifically, if the selection node needs to be just-in-time compiled and the selection node can be just-in-time compiled, the selection expression is just-in-time compiled to generate the first logic code.

[0063] S222: Otherwise, the selection expression remains unchanged and proceeds to step S223.

[0064] Specifically, if the selection node does not need to be compiled in real time, or the selection node cannot be compiled in real time, the selection expression in the selection node remains unchanged, and the process proceeds to step S223.

[0065] Specifically, in this embodiment, please refer to Figure 8 , Figure 8 yes Figure 7 Schematic diagram of a flow chart of an implementation method of steps S220-S222 in FIG. Specifically, steps S220-S222 include:

[0066] S30: Determine whether the selection expression is of the first operation type and meets the preset complexity.

[0067] Specifically, for the selection expression of the selection node, the entire expression tree is required to be a first operation type that can support just-in-time compilation. In the present embodiment, the first operation type includes AND, OR, Var, CONST, FUNCCALL, OPCALL, etc., which only needs to support just-in-time compilation, and this application is not limited here. In addition, the selection expression needs to meet the preset complexity, otherwise the logic code after code generation (codegen) will not have a significant efficiency improvement, that is, if the selection expression does not meet the preset complexity, then in order to avoid wasting resources, the selection node does not need to be just-in-time compiled, and the original selection expression can be directly used in the execution phase. Of course, the preset complexity can be determined according to the actual situation, and this application is not limited here.

[0068] S31: If yes, it is determined that the selection node needs to be compiled just in time and the selection node can be compiled just in time, and the selection expression is compiled just in time to generate a first logic code, and then the process goes to step S223.

[0069] Specifically, if the selection expression is of the first operation type and meets the preset complexity, it is determined that the selection node needs to be compiled in real time and the selection node can be compiled in real time, and the selection expression is compiled in real time to generate a first logic code, and then enter the step of determining whether the projection node can be compiled in real time.

[0070] S32: Otherwise, keep the selection expression unchanged and go to step S223.

[0071] Specifically, if the selection expression is not one of the first operation types, it means that the selection node cannot be compiled just in time, or the selection expression does not meet the preset complexity, which means that the selection node does not need to be compiled just in time, then the selection expression in the selection node remains unchanged and proceeds to step S223.

[0072] S223: Determine whether the projection node can be compiled in real time.

[0073] S224: If yes, the projection expression is compiled in real time to generate a second logic code.

[0074] Specifically, if the projection node can be just-in-time compiled, the projection expression is just-in-time compiled to generate the second logic code.

[0075] S225: Otherwise, proceed to step S23.

[0076] Specifically, if the projection node cannot be compiled in real time, the process proceeds to the step of completing the initialization of the current plan node and determining whether there is a next plan node.

[0077] Specifically, in this embodiment, please refer to Fig. 9 , Fig. 9 yes Figure 7 Schematic diagram of a flow chart of an implementation method of steps S223-S225 in FIG. Specifically, steps S223-S225 include:

[0078] S40: Determine whether the projection expression is of the second operation type.

[0079] Specifically, for a projection expression, the projection node can only be compiled in real time when the projection expression is of the second operation type, so it is necessary to determine whether the projection expression is of the second operation type, and then determine whether the projection node can be compiled in real time. In this embodiment, the second operation type includes operator call, function call, etc., which is not limited in this application.

[0080] S41: If yes, it is determined that the projection node can be just-in-time compiled, and the projection expression is just-in-time compiled to generate a second logic code.

[0081] Specifically, if the projection expression is of the second operation type, it is determined that the projection node can be just-in-time compiled, and the projection expression is just-in-time compiled to generate the second logic code.

[0082] S42: Otherwise, determine that the projection node cannot be compiled in real time, and proceed to step S23.

[0083] Specifically, if the projection expression is not the second operation type, it is determined that the projection node cannot be compiled in real time, and the process proceeds to the step of completing the initialization of the current plan node and determining whether there is a next plan node.

[0084] In addition, in this embodiment, the relevant libraries of the open source LLVM framework required for the code generator (Codegen) / just-in-time compiler (JIT) have been built into the database binary, which will not be repeated here.

[0085] Specifically, in this embodiment, before determining whether the projection node can be compiled in real time, it is also necessary to determine whether the projection node can be processed in batches. Fig.10 , Fig.10 yes Figure 7 Schematic diagram of a flow chart of an implementation method before step S223. Specifically, before step S223, it also includes:

[0086] S50: Determine whether the global switch variable is set correctly and whether the data included in the first target tuple is of the first data type.

[0087] Specifically, it is determined whether the global switch variable in steps S10-S12 is set correctly, and it is determined whether the data contained in the first target tuple is a first data type. In this embodiment, only basic types need to perform single instruction multiple data (SIMD) operations, such as user-defined types, composite types, arrays and other complex types are not supported yet, so the data contained in the first data type is a simple type such as integer, floating point, Boolean, time, etc., which is not limited in this application.

[0088] S51: If yes, mark the associated variable of the scan plan node as correct and proceed to step S223.

[0089] Specifically, if the global switch variable in steps S10-S12 is set to be correct and the data contained in the first target tuple is of the first data type, the associated variable (use_simd) of the scan plan node is marked as correct (true), and the process proceeds to the step of determining whether the projection node can be just-in-time compiled. In addition, in this embodiment, if it is confirmed that the projection node needs to be just-in-time compiled and SIMD stream operated, the second logic code generated by just-in-time compilation replaces the original part, especially some operation functions, such as replacing int4_add with int4_add_vec, replacing int4_mul with int4_mul_vec, etc.

[0090] S52: Otherwise, mark the associated variable of the scan plan node as an error and proceed to step S223.

[0091] Specifically, if the global switch variable in steps S10-S12 is set to an error, or the data contained in the first target tuple is not of the first data type, the associated variable (use_simd) of the scan plan node is marked as an error (false), and the process proceeds to the step of determining whether the projection node can be compiled just in time.

[0092] Specifically, in this embodiment, please refer to Fig.11 , Fig.11 yes Figure 4 Schematic diagram of a flow chart of an implementation method of step S2 in FIG. Specifically, step S2 includes:

[0093] S60: Obtain a first target tuple corresponding to the first logic code from the database through the selection node.

[0094] Specifically, step S60 includes the following steps: A: Determine whether the current plan node obtains a tuple from the lower layer; B: If the current plan node obtains a tuple from the lower layer, determine whether the tuple satisfies the first logic code; C: If the current plan node cannot obtain a tuple from the lower layer, the recursion of plan nodes at each level ends, that is, the executor ends; D: If the tuple satisfies the first logic code, it means that the tuple is the first target tuple corresponding to the first logic code, and enters step S61; E: If the tuple does not satisfy the first logic code, return to the step of determining whether the current plan node obtains a tuple from the lower layer.

[0095] S61: Determine whether the associated variables of the scan plan node are marked as correct.

[0096] Specifically, it is determined whether the associated variable (use_simd) in steps S50 - S52 is marked as correct.

[0097] S62: If yes, determine whether the cache context of the scan plan node satisfies the first preset condition.

[0098] Specifically, if the associated variable of the scan plan node is marked as correct, it is determined whether the cache context of the scan plan node has been initialized or the memory is not full to determine whether the first target tuple can be cached into the cache context.

[0099] S63: Otherwise, the second target tuple obtained by projecting the first target tuple is returned to the aggregation plan node, and the process returns to step S1.

[0100] Specifically, in the executor execution phase, the caching operation will be determined based on the tag of the associated variable (use_simd) set by the key plan node. If the associated variable of the scan plan node is marked as an error, the entire execution process will remain unchanged, and the second target tuple obtained by projecting the first target tuple will be immediately returned to the aggregation plan node, and return to step S1.

[0101] S64: If yes, convert the first target tuple and save it into the cache context to generate a first tuple set.

[0102] Specifically, if the associated variable of the scan plan node is marked as correct and the cache context of the scan plan node has been initialized or the memory is not full, the first target tuple is converted and saved in the cache context to generate a first tuple set.

[0103] S65: Otherwise, the cache context is initialized or cleared, and the process proceeds to step S64.

[0104] Specifically, if the cache context of the scan plan node is not initialized or the memory is full, the cache context is initialized or cleared, and the first target tuple is converted and saved in the cache context to generate a first tuple set. In this way, the cache context can have enough space to accommodate multiple first target tuples, so as to facilitate subsequent batch projection processing.

[0105] S3: Determine whether the cached first target tuple in the first tuple set exceeds a threshold.

[0106] Specifically, in this embodiment, the threshold value may be the number of cached tuples or the size of cached tuples, which is not limited in this application. Of course, the threshold value may be dynamically adjusted based on the size of the tuple itself, which is not limited in this application.

[0107] S4: If yes, the first tuple set is sent to the projection node and the first target tuple is projected according to the second logic code to obtain a plurality of corresponding second target tuples.

[0108] Specifically, if the cached first target tuples in the first tuple set exceed the threshold, multiple first target tuples in the first tuple set are sent to the projection node at one time and the first target tuples are projected according to the second logic code to obtain multiple corresponding second target tuples. Through this design, the flow and operation of tuples can be satisfied while adapting the original unit group operation.

[0109] S5: Otherwise, return to step S60.

[0110] Specifically, if the cached first target tuples in the first tuple set do not exceed the threshold, the process returns to the step of obtaining the first target tuple corresponding to the first logic code from the database via the selection node.

[0111] S6: Return the multiple second target tuples to the aggregation plan node for aggregation processing.

[0112] Specifically, in this embodiment, for the aggregation plan node, most aggregation operations can still be performed in batches, which can optimize the execution speed.

[0113] Through this design approach, the execution efficiency of the executor can be improved while maintaining the original compatibility, without the need to redesign a new executor architecture and a new data storage format.

[0114] See also Fig.12 , Fig.12 It is a structural schematic diagram of an implementation method of the actuator of the present application. The actuator specifically includes:

[0115] The acquisition module 10 is used to acquire an execution plan tree; wherein the execution plan tree includes a scan plan node and an aggregation plan node, and the nodes associated with the scan plan node include a selection node and a projection node.

[0116] The first processing module 12 is coupled to the acquisition module 10 and is used to obtain and cache a first target tuple corresponding to the first logic code from a database through a selection node to generate a first tuple set.

[0117] The second processing module 14 is coupled to the first processing module 12, and is used for sending the first tuple set to the projection node and projecting the first target tuple according to the second logic code to obtain multiple corresponding second target tuples in response to the first target tuple cached in the first tuple set exceeding the threshold; wherein the first logic code and the second logic code are respectively generated by just-in-time compilation of the selection expression of the selection node and the projection expression of the projection node.

[0118] The aggregation module 16 is coupled to the second processing module 14, and is used to return the plurality of second target tuples to the aggregation plan node for aggregation processing.

[0119] See also Fig.13 , Fig.13 Schematic diagram of a framework of an embodiment of the executor of the present application. The executor includes a memory 20 and a processor 22 coupled to each other. Specifically, in the present embodiment, the memory 20 stores program instructions, and the processor 22 is used to execute the program instructions to implement the execution method of the executor mentioned in any of the above embodiments.

[0120] Specifically, the processor 22 may also be referred to as a CPU (Central Processing Unit). The processor 22 may be an integrated circuit chip having the ability to process signals. The processor 22 may also be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. A general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc. In addition, the processor 22 may be implemented by a plurality of integrated circuit chips.

[0121] See also Fig.14 , Fig.14It is a schematic diagram of a framework of an embodiment of a computer-readable storage medium of the present application. The computer-readable storage medium 30 stores a computer program 300, which can be read by a computer, and the computer program 300 can be executed by a processor to implement the execution method of the actuator mentioned in any of the above embodiments. Among them, the computer program 300 can be stored in the above-mentioned computer-readable storage medium 30 in the form of a software product, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor (processor) to perform all or part of the steps of the method described in each embodiment of the present application. The computer-readable storage medium 30 with a storage function can be a U disk, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, RandomAccess Memory), a disk or an optical disk, etc., which can store program codes, or a terminal device such as a computer, a server, a mobile phone, and a tablet.

[0122] In summary, different from the prior art, the execution method provided by the present application includes: obtaining an execution plan tree; wherein the execution plan tree includes a scan plan node and an aggregation plan node, and the nodes associated with the scan plan node include a selection node and a projection node; obtaining and caching the first target tuple corresponding to the first logic code from the database through the selection node to generate a first tuple set; in response to the cached first target tuple in the first tuple set exceeding the threshold, sending the first tuple set to the projection node and projecting the first target tuple according to the second logic code to obtain a plurality of corresponding second target tuples; wherein the first logic code and the second logic code are respectively generated by just-in-time compilation of the selection expression of the selection node and the projection expression of the projection node; returning the plurality of second target tuples to the aggregation plan node for aggregation processing. Through such a design method, the execution efficiency of the executor can be improved on the basis of maintaining the original compatibility, and there is no need to redesign a new executor architecture and a new data storage format.

[0123] The above description is only an implementation method of the present application, and does not limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly used in other related technical fields, are also included in the patent protection scope of the present application.

Claims

1. An execution method of an actuator, characterized in that: include: Obtaining an execution plan tree; wherein the execution plan tree includes a scan plan node and an aggregation plan node, and the nodes associated with the scan plan node include a selection node and a projection node; Obtaining and caching a first target tuple corresponding to the first logic code from a database through the selection node to generate a first tuple set; In response to the first target tuple cached in the first tuple set exceeding a threshold, the first tuple set is sent to the projection node and the first target tuple is projected according to a second logic code to obtain a plurality of corresponding second target tuples; wherein the first logic code and the second logic code are generated by just-in-time compilation of a selection expression of the selection node and a projection expression of the projection node, respectively; Return the plurality of the second target tuples to the aggregation plan node for aggregation processing.

2. The execution method of the actuator according to claim 1, characterized in that: Before the step of obtaining and caching the first target tuple corresponding to the first logic code from the database through the selection node to generate the first tuple set, the method includes: Obtain all scan plan nodes in the execution plan tree; In response to the global switch variable controlling the just-in-time compilation to be turned on and the scan plan node supporting the just-in-time compilation, the scan plan node is initialized to obtain the first logic code and the second logic code.

3. The execution method of the actuator according to claim 2, characterized in that: The step of initializing the scan plan node to obtain the first logic code and the second logic code includes: In response to the selection node needing to be just-in-time compiled and the selection node being able to be just-in-time compiled, just-in-time compiling the selection expression to generate the first logic code; In response to the projection node being capable of just-in-time compilation, the projection expression is just-in-time compiled to generate the second logic code.

4. The execution method of the actuator according to claim 3, characterized in that: In response to the selection node needing to be just-in-time compiled and the selection node being able to be just-in-time compiled, the step of just-in-time compiling the selection expression of the selection node to generate the first logic code includes: In response to the selection expression being of the first operation type and satisfying a preset complexity, it is determined that the selection node needs to be just-in-time compiled and the selection node can be just-in-time compiled, and the selection expression is just-in-time compiled to generate a first logic code corresponding to the selection expression.

5. The execution method of the actuator according to claim 4, characterized in that: In response to the projection node being capable of being just-in-time compiled, the step of just-in-time compiling the projection expression of the projection node to generate the second logic code comprises: In response to the projection expression being of the second operation type, it is determined that the projection node can be just-in-time compiled, and the projection expression is just-in-time compiled to generate a second logic code corresponding to the projection expression.

6. The execution method of the actuator according to claim 4, characterized in that: Before the step of just-in-time compiling the projection expression of the projection node to generate the second logic code in response to the projection node being capable of just-in-time compilation, the method further includes: In response to the global switch variable being set to correct and the data contained in the first target tuple being of the first data type, the associated variable of the scan plan node is marked as correct, and the step of compiling the projection expression of the projection node in real time in response to the projection node being able to be compiled just in time to generate the second logic code is entered.

7. The execution method of the actuator according to claim 1, characterized in that: The step of obtaining and caching the first target tuple corresponding to the first logic code from the database through the selection node to generate a first tuple set includes: Obtaining a first target tuple corresponding to the first logic code from a database through the selection node; In response to the associated variable of the scan plan node being marked as correct and the cache context of the scan plan node satisfying a first preset condition, the first target tuple is converted and saved in the cache context to generate a first tuple set.

8. The execution method of the actuator according to claim 1, characterized in that: Before the step of obtaining the execution plan tree, the following steps are included: In response to the central processor of the executor supporting the AVX instruction set, setting the global switch variable to be correct, and entering the step of running the database; In response to the central processor of the executor not supporting the AVX instruction set, a global switch variable is set to an error, and the step of running the database is entered.

9. An actuator, characterized in that: The invention comprises a memory and a processor coupled to each other, wherein the memory stores program instructions, and the processor is used to execute the program instructions to implement the execution method of the actuator according to any one of claims 1 to 8.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and the computer program is used to implement the execution method of the actuator according to any one of claims 1 to 8.