A plan execution method, device, database node and medium

By partitioning and cutting the sending operator based on query statement cropping information in a distributed database system, determining its execution node location and changing the execution mode, the problem of inefficient planning reuse in the distributed database system is solved, and more efficient planning execution is achieved.

CN114090617BActive Publication Date: 2025-08-29SHANGHAI DAMENG DATABASE
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111442810.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-30
Publication Date
2025-08-29
Estimated Expiration
2041-11-30

AI Technical Summary

Technical Problem

When planning to reuse existing distributed database systems, there are unnecessary communication overhead and excessive number of planned caches, resulting in inefficient execution.

Method used

By partitioning and cropping the sending operator in the execution plan based on the crop information in the query statement, determining the location of its execution node, and changing the execution mode of the data distribution operator according to the node position, the executable plan is constructed.

Benefits of technology

Effectively reduce the number of planned caches, improve the efficiency of plan execution, and avoid unnecessary communication overhead.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114090617B_ABST
    Figure CN114090617B_ABST
Patent Text Reader

Abstract

Embodiments of the present invention disclose a plan execution method, device, database node, and medium. The method includes: partitioning and pruning the sending operator in the to-be-executed plan based on pruning information in a query statement to obtain a partition pruning result, wherein the partition pruning result includes the execution node position of the sending operator; constructing an executable plan based on the to-be-executed plan and the partition pruning result; determining the execution mode of the data distribution operator in the executable plan based on the execution node position of the sending operator, and executing the executable plan based on the execution mode. This method can effectively improve the efficiency of plan execution by changing the execution mode of the data distribution operator based on the execution node position of the sending operator and executing the executable plan according to different execution modes.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present invention relate to the technical field of distributed databases, and in particular to a plan execution method, device, database node, and medium. Background Art

[0002] One architecture of a distributed database cluster is one in which every node in the cluster is peer-to-peer, and each node includes functions such as plan generation and execution. Data is distributed across the cluster nodes according to specific rules. When a user request R reaches an intermediate node X, if the data required for R is only on node X, the query plan can be executed locally on node X. If the data required for R involves other nodes besides node X, the query plan requires collaboration between node X and other nodes. In a distributed database cluster, the former type of query plan is typically called a local plan, while the latter type is called a distributed plan or remote plan. Local plans do not involve data exchange or transmission, allowing for more efficient execution. Distributed plans, on the other hand, introduce communication overhead during execution, but their execution can adapt to various data node distributions and are more widely applicable.

[0003] Currently, distributed database products use one approach to plan reuse: regardless of whether the query plan is local or distributed, they execute it as a distributed plan. This results in unnecessary communication overhead for local query plans, sacrificing execution efficiency when data is local. Another approach is to distinguish between local and distributed plans for query plans, storing multiple plans to match the same query statement across different data node locations, which results in an excessively large plan cache.

[0004] Therefore, how to reduce the number of plan caches and improve the efficiency of plan execution is a technical problem that needs to be solved urgently. Summary of the Invention

[0005] The embodiments of the present invention provide a plan execution method, device, database node and medium to improve the efficiency of plan execution.

[0006] In a first aspect, an embodiment of the present invention provides a plan execution method, comprising:

[0007] Performing partition pruning on the send operator in the execution plan based on the pruning information in the query statement to obtain a partition pruning result, wherein the partition pruning result includes an execution node position of the send operator;

[0008] Constructing an executable plan based on the to-be-executed plan and the partition pruning result;

[0009] An execution mode of the data distribution operator in the executable plan is determined according to the execution node position of the send operator, and the executable plan is executed according to the execution mode.

[0010] In a second aspect, an embodiment of the present invention further provides a plan execution device, comprising:

[0011] a pruning module, configured to perform partition pruning on the send operator in the execution plan based on the pruning information in the query statement, and obtain a partition pruning result, wherein the partition pruning result includes the execution node position of the send operator;

[0012] A construction module, configured to construct an executable plan based on the to-be-executed plan and the partition pruning result;

[0013] An execution module is used to determine an execution mode of the data distribution operator in the executable plan according to the execution node position of the sending operator, and execute the executable plan according to the execution mode.

[0014] In a third aspect, an embodiment of the present invention further provides a database node, including:

[0015] one or more processors;

[0016] a storage device for storing one or more programs;

[0017] The one or more programs are executed by the one or more processors, so that the one or more processors implement the plan execution method provided by the embodiment of the present invention.

[0018] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the plan execution method provided by an embodiment of the present invention.

[0019] Embodiments of the present invention provide a plan execution method, apparatus, database node, and medium. First, based on the pruning information in the query statement, the send operator in the to-be-executed plan is partition-pruned to obtain a partition pruning result, wherein the partition pruning result includes the execution node position of the send operator. Then, based on the to-be-executed plan and the partition pruning result, an executable plan is constructed. Finally, based on the execution node position of the send operator, the execution mode of the data distribution operator in the executable plan is determined, and the executable plan is executed according to the execution mode. The above technical solution effectively improves the efficiency of plan execution by changing the execution mode of the data distribution operator according to the execution node position of the send operator and executing the executable plan according to different execution modes. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] Figure 1A A schematic diagram of a distributed database cluster architecture provided by an embodiment of the present invention;

[0021] Figure 1B A schematic diagram of an implementation of a query plan corresponding to a query statement Q1 provided in an embodiment of the present invention;

[0022] Figure 1C A schematic diagram of an implementation of a query plan corresponding to a query statement Q2 provided in an embodiment of the present invention;

[0023] Figure 2 A flowchart of a plan execution method provided in Example 1 of the present invention;

[0024] Figure 3 A flowchart of a plan execution method provided in the second embodiment of the present invention;

[0025] Figure 4 A schematic diagram of implementing plan cache matching provided in the second embodiment of the present invention;

[0026] Figure 5 A schematic diagram of the structure of a plan execution device provided in the third embodiment of the present invention;

[0027] Figure 6 A schematic diagram of the structure of a database node provided in the fourth embodiment of the present invention. DETAILED DESCRIPTION

[0028] The present invention will be further described in detail below with reference to the accompanying drawings and examples. It will be understood that the specific embodiments described herein are intended only to illustrate the present invention and are not intended to limit the present invention. It should also be noted that, for ease of description, the accompanying drawings only illustrate portions relevant to the present invention, not all structures.

[0029] It should be mentioned before discussing exemplary embodiments in more detail that some exemplary embodiments are described as processes or methods depicted as flow charts. Although flow charts describe various operations (or steps) as sequential processes, many operations therein can be implemented in parallel, concurrently or simultaneously. In addition, the order of various operations can be rearranged. When its operation is completed, the process can be terminated, but can also have additional steps not included in the accompanying drawings. The process can correspond to methods, functions, procedures, subroutines, subprograms, etc. In addition, the features in the embodiments of the present invention and the embodiments can be combined with each other without conflict.

[0030] The term "including" and its variations used in the present invention are open inclusions, that is, "including but not limited to." The term "based on" means "based at least in part on." The term "one embodiment" means "at least one embodiment."

[0031] It should be noted that the concepts of "first" and "second" mentioned in the present invention are only used to distinguish the corresponding contents, and are not used to limit the order or mutual dependence.

[0032] It should be noted that the modifications of "one" and "multiple" mentioned in the present invention are illustrative rather than restrictive. Those skilled in the art should understand that unless otherwise clearly indicated in the context, it should be understood as "one or more".

[0033] Based on the existing plan reuse method, the embodiment of the present invention proposes a method for improving plan reuse efficiency by changing the execution mode of the data distribution operator in a distributed database environment. When the data is distributed on the local node, the data distribution operator is regarded as being executed in pipeline mode; when the data is distributed on nodes other than the local node, the data distribution operator is regarded as being executed in normal mode, thereby effectively utilizing the plan reuse efficiency and reducing the plan cache volume.

[0034] Figure 1A A schematic diagram of a distributed database cluster architecture provided by an embodiment of the present invention. Figure 1A As shown, a distributed database cluster can have n (n > 1) nodes, such as bp1, bp2, ..., bpn (nodes can be understood as servers). Each node has its own central processing unit (CPU), memory, and disk. There is no shared storage between nodes, and they are connected via a high-speed network. Users can connect to any node in bp1-bpn through a client (such as client 1, ..., client n). The client-to-node connection method can be a direct connection to the node, or it can be selected by a third-party component according to load balancing or pre-set routing policies. There are no restrictions on this.

[0035] The user table data in a database can be distributed across one or more nodes. For example, create a range-partitioned table T1 with two partitions, p1 and p2. p1 and p2 can be stored on nodes bp1 and bp2, respectively. The table creation statement for table T1 can be expressed as:

[0036] create table T1(c1 int,c2 int)partition by range(c1)

[0037] (partition p1 values ​​less than(100)storage(on bp1),

[0038] Partition p2 values ​​less than(200)storage(on bp2));

[0039] The table creation statement corresponding to table T1 can be understood as follows: c1 and c2 are input, table T1 partitions are created according to the range of c1, data with a median value of c1 less than 100 (i.e., c1 < 100) is partitioned into p1 and stored on the bp1 node, and data with a median value of c1 greater than 100 and less than 200 (i.e., 100 ≤ c1 < 200) is partitioned into p2 and stored on the bp2 node.

[0040] Create a common table T2. All data in table T2 can be stored on the bp3 node. The table creation statement corresponding to table T2 can be expressed as:

[0041] create table T2(d1 int,d2 int)storage(on bp3);

[0042] The table creation statement corresponding to table T2 can be understood as taking d1 and d2 as input to create a table T2, in which all data is stored on the bp3 node.

[0043] When a user connects to node bp1 through client 1 and issues query Q1, which can be expressed as select * from T1 where c1 = 50, it can be understood as querying data from the partition corresponding to c1 = 50 in table TI. Table T1 shows that the data that meets the query condition (c1 = 50) is located in partition p1, which is distributed on node bp1. Partition pruning was performed during the planning phase.

[0044] Figure 1B Schematic diagram of the implementation of a query plan corresponding to a query statement Q1 provided in an embodiment of the present invention. Figure 1B As shown, SCAN(T1_p1) can represent a scan operator (i.e., the SCAN operator) responsible for scanning the data in partition p1 of table T1; FILTER(c1=50) can represent a filter operator (i.e., the FILTER operator) responsible for filtering data according to a filter condition (in this case, the query condition c1=50 can be used as a filter condition); PROJECT can represent a projection operator, which can be used to calculate the query term expression returned to the client. Specifically, the SCAN operator first scans the data in partition p1 of table T1; then the obtained data is passed to the FILTER operator with the filter condition c1=50. Data that meets this filter condition is further sent to the PROJECT operator through the FILTER operator; finally, the final query is completed, and the query results are returned to the client through the PROJECT operator.

[0045] When the user slightly changes the query condition, the query statement Q2 is obtained. Q2 can be expressed as select * from T1 where c1 = 150, which can be understood as querying data from the partition corresponding to c1 = 150 in the TI table. From table T1, we can see that the data that meets the query condition (i.e. c1 = 150) is located in the p2 partition and is distributed on the bp2 node. It can be understood that the location of the node distribution of the queried data has changed, so the above Figure 1B The query plan of query statement Q1 shown cannot be directly reused for query statement Q2.

[0046] Figure 1C Schematic diagram of the implementation of a query plan corresponding to a query statement Q2 provided in an embodiment of the present invention. Figure 1C As shown, SCAN(T1_p2) indicates that the SCAN operator is responsible for scanning the data in partition p2 of table T1; FILTER(c1=50) indicates that the FILTER operator is responsible for filtering data based on the filter condition (in this case, the query condition c1=150 can be used as the filter condition); SEND represents the send operator, and RECV represents the receive operator, used for sending and receiving data, respectively. Compared to Q1, the query plan for Q2 includes the SEND and RECV operators, which can be used for cross-node data transfer (for example, between nodes bp1 and bp2). Specifically, the local plan containing the SEND-FILTER-SCAN operator is first sent to the node corresponding to the query condition c1=150, namely, node bp2. The SCAN operator scans the data in partition p2 of table T1 and passes the obtained data to the FILTER operator with the filter condition c1=150. Data that meets this filter condition is then sent to the SEND operator via the FILTER operator. The RECV operator then waits to receive data from the SEND operator. Finally, when the SEND operator has sent all the data and the RECV operator has received it, the RECV operator sends the data to the PROJECT operator to complete the final query, and the query results are returned to the client through the PROJECT operator.

[0047] Obviously, if Q1 directly adopts the planning method of Q2, it can also complete the query function normally, but it will incur the cost of sending the SEND-FILTER-SCAN local plan and the communication overhead between SEND-RECV.

[0048] In existing distributed database systems, for the same query statement, different partition pruning results are either uniformly based on the Q2 query plan, or using both local and distributed plan caches based on the partition pruning results. The former results in unnecessary performance waste when the partition location happens to be local, while the latter results in an excessively large plan cache.

[0049] An embodiment of the present invention proposes a method in which, in the plan generation stage, the query plan is no longer distinguished between local plans and distributed plans, and the data distribution operators (i.e., SEND / RECV operators) can be uniformly retained; in the plan reuse stage, the execution mode of the SEND / RECV operator is determined according to the actual partition position of the SEND / RECV operator (i.e., which node position it is actually located at), and the execution plan is executed accordingly according to the execution mode. For example, the query plans corresponding to Q1 and Q2 in the above embodiment can be uniformly represented by the query plan corresponding to Q2 in the plan generation stage of the embodiment of the present invention. Before executing the plan, the node position of each SEND operator is calculated. If the calculated node positions are all local nodes, then the execution mode of all SEND / RECV operators in the query plan is set to pipeline mode; otherwise, the execution mode of the SEND / RECV operator is set to normal mode. This effectively utilizes the efficiency of plan reuse and reduces the volume of the plan cache.

[0050] Example 1

[0051] Figure 2 A flow chart of a plan execution method provided in Example 1 of the present invention is applicable to situations where a corresponding plan is executed by changing the execution mode of a data distribution operator to effectively improve the efficiency of plan execution. The method can be executed by a plan execution device, wherein the device can be implemented by software and / or hardware and is generally integrated with any device that provides database node management functions.

[0052] like Figure 2 As shown, a plan execution method provided in the first embodiment of the present invention includes the following steps:

[0053] S110 , performing partition pruning on the sending operator in the execution plan based on the pruning information in the query statement to obtain a partition pruning result, wherein the partition pruning result includes the execution node position of the sending operator.

[0054] In this embodiment, the query statement may refer to a query instruction statement entered by a user through a client. The tailoring information may refer to the query condition in the query statement, such as c1=50 or c1=150 in the above embodiment. The to-be-executed plan may be an existing plan matched from the plan cache based on the query statement. If no corresponding plan is found in the plan cache, a new query plan may be generated based on the query statement.

[0055] The sending operator may refer to the SEND operator. Partition pruning may refer to the process of pruning the SEND operator according to the pruning information to obtain the corresponding partition and partition position. The partition and partition position obtained in the process may refer to the partition pruning result; wherein, the partition may refer to the partition p1 or p2 in the above embodiment, and the partition position may refer to the node position where the partition is located, such as the node bp1 or bp2 corresponding to p1 or p2 in the above embodiment. The execution node position may refer to the node where the SEND operator can execute data sending, such as which node is the partition position of the SEND operator, the node is the node where the SEND operator can execute data sending, that is, the execution node position; that is, the partition pruning result may include the execution node position of the SEND operator. The plan to be executed may contain multiple SEND operators, and each SEND operator may correspond to a partition pruning result, which can be understood as each SEND operator may correspond to an execution node position.

[0056] S120: Construct an executable plan based on the to-be-executed plan and the partition pruning result.

[0057] In this embodiment, the executable plan may refer to a plan constructed by adding the partition pruning result information obtained based on the to-be-executed plan. It is understood that the executable plan may include a SEND operator and its corresponding execution node position.

[0058] S130 : Determine an execution mode of the data distribution operator in the executable plan according to the execution node position of the send operator, and execute the executable plan according to the execution mode.

[0059] In this embodiment, the data dispatch operator may refer to a SEND / RECV operator, which can be understood as an operator that combines the SEND operator and the RECV operator and can be used to send and receive data. The execution mode may refer to the mode of the SEND / RECV operator when executing a plan. The execution mode of the SEND / RECV operator in the executable plan can be determined based on the execution node position of the SEND operator.

[0060] Optionally, the execution mode includes pipeline mode and normal mode.

[0061] The pipeline mode can refer to treating the SEND / RECV operator as a pipeline operator, which can directly transfer the data passed by the child operator to the corresponding parent operator without any other data processing. The parent operator can be understood as the destination operator to which the data is to be transferred during the execution of the plan. For example, Figure 1CFor example, the SEND operator passes data to the RECV operator, and the RECV operator passes data to the PROJECT operator. This means that the destination operator to which the SEND operator passes data is the RECV operator, and the destination operator to which the RECV operator passes data is the PROJECT operator. This means that the parent operator of the SEND operator is the RECV operator, and the parent operator of the RECV operator is the PROJECT operator. It is understandable that the PROJECT operator is the parent operator of the SEND / RECV operators.

[0062] The child operator can be relative to the parent operator. The child operator can be understood as the source operator of data during the execution of the plan. Figure 1C For example, the SEND operator receives data from the FILTER operator, and the RECV operator receives data from the SEND operator. This means that the source operator for the SEND operator's data is the FILTER operator, and the source operator for the RECV operator's data is the SEND operator. This means that the child operator for the SEND operator is the FILTER operator, and the child operator for the RECV operator is the SEND operator. It's understandable that the child operator for both the SEND and RECV operators is the FILTER operator.

[0063] The normal mode may refer to a SEND operator in a SEND / RECV operator that needs to perform data transmission with a RECV operator across nodes.

[0064] On this basis, the data transmission of SEND / RECV operators can be controlled according to different execution modes to execute the executable plan accordingly.

[0065] A plan execution method provided in a first embodiment of the present invention first partitions and prunes the send operator in a pending execution plan based on pruning information in a query statement, obtaining a partition pruning result, wherein the partition pruning result includes the execution node position of the send operator. An executable plan is then constructed based on the pending execution plan and the partition pruning result. Finally, the execution mode of the data distribution operator in the executable plan is determined based on the execution node position of the send operator, and the executable plan is executed according to the execution mode. This method effectively improves the efficiency of plan execution by changing the execution mode of the data distribution operator based on the execution node position of the send operator and executing the executable plan according to different execution modes.

[0066] Example 2

[0067] Figure 3This is a flowchart of a plan execution method provided in the second embodiment of the present invention. This second embodiment refines the above embodiments. This embodiment specifically describes the process of determining the execution mode of the data distribution operator in an executable plan and executing the executable plan based on the execution mode. It should be noted that any technical details not fully described in this embodiment can be referred to in any of the above embodiments.

[0068] like Figure 3 As shown, a plan execution method provided in the second embodiment of the present invention includes the following steps:

[0069] S210: Perform plan cache matching on the obtained query statement.

[0070] S220: Determine the plan to be executed based on the matching result.

[0071] In this embodiment, the plan cache may refer to existing execution plans of certain query statements cached in the database, and the pending execution plan may refer to a plan waiting to be executed.

[0072] Exemplarily, a plan cache match is performed on the obtained query statement, and a plan to be executed is determined based on the matching result. It can be understood that for the query statement obtained from the client, a search can be made from the plan cache based on the query statement to see whether there is an existing execution plan that can be used for the query statement (i.e., to see whether there is an existing execution plan corresponding to the query statement), and the result of the search is the matching result; if a corresponding existing execution plan is found, the found existing execution plan can be used as the plan to be executed; if no corresponding existing execution plan is found, a plan can be regenerated based on the query statement as the plan to be executed.

[0073] Optionally, based on the matching result, a plan to be executed is determined, including: if the matching result is a successful match, obtaining the matched plan from the plan cache as the plan to be executed; if the matching result is a failed match, generating and optimizing a plan for the query statement, and using the obtained plan as the plan to be executed.

[0074] The plan to be executed is determined based on the matching result of the plan cache. If the matching result is successful, that is, a corresponding existing execution plan is found in the plan cache, the matched plan can be retrieved from the plan cache as the plan to be executed. If the matching result is unsuccessful, that is, no corresponding existing execution plan is found in the plan cache, a plan can be generated and optimized for the query statement, and the resulting plan can be used as the plan to be executed.

[0075] Figure 4 This is a schematic diagram of an implementation of plan cache matching provided by the second embodiment of the present invention. Figure 4As shown, first, the obtained query statement is parsed; then, the obtained query statement is matched with the plan cache according to the analysis result of the query statement; finally, if the match is successful, the matched execution plan can be used as the plan to be executed; if the match fails, semantic analysis, plan generation and plan optimization can be performed according to the query statement, and the obtained plan can be used as the plan to be executed.

[0076] S230 , partition pruning is performed on the sending operator in the execution plan based on the pruning information in the query statement to obtain a partition pruning result, wherein the partition pruning result includes the execution node position of the sending operator.

[0077] S240: Construct an executable plan based on the plan to be executed and the partition pruning result.

[0078] In this embodiment, an executable plan is constructed based on the pending plan and the partition pruning results. During the conversion of the pending plan into an executable plan, the execution node positions after partition pruning are calculated for all encountered SEND operators. Based on this, the execution mode of the SEND / RECV operators in the executable plan is determined based on the execution node position results.

[0079] S250 , determining whether the execution node locations of the sending operator are all local nodes, if so, executing S260 ; if not, executing S270 .

[0080] S260: Determine that the execution mode of the data distribution operator in the executable plan is pipeline mode.

[0081] In this embodiment, if the execution node locations of the send operators are all local nodes, it can be determined that the execution mode of the data distribution operator (ie, the SEND / RECV operator) in the executable plan is the pipeline mode.

[0082] S270: Determine that the execution mode of the data distribution operator in the executable plan is the normal mode.

[0083] In this embodiment, if the execution node locations of the send operator are not all local nodes, for example, they are all nodes other than the local node, or there are both local nodes and other nodes, then it can be determined that the execution mode of the SEND / RECV operator in the executable plan is normal mode.

[0084] S280: Execute the executable plan according to the execution mode.

[0085] In this embodiment, different execution modes may correspond to different execution methods of the executable plan.

[0086] Optionally, executing the executable plan according to the execution mode includes: if the execution mode is pipeline mode, executing the executable plan according to stand-alone mode, wherein the data distribution operator serves as a pipeline operator to send the received data to the corresponding parent operator.

[0087] Standalone mode refers to executing the executable plan directly on the local node without sending it to other nodes or the current node. If the execution mode is pipeline mode, the executable plan can be executed in standalone mode, where the SEND / RECV operators in the executable plan act as pipeline operators, without any data processing, and directly sending the received data to the corresponding parent operator.

[0088] Optionally, executing the executable plan according to the execution mode includes: if the execution mode is normal mode, sending the sub-plan with the sending operator as the root node to the corresponding execution node position; sending the data uploaded by the corresponding child operator to the corresponding receiving operator according to the destination node setting through the sending operator; after receiving the data, the receiving operator sends the data to the corresponding parent operator until the receiving stop condition is met; wherein, the receiving stop condition is that the data received by the receiving operator contains a stop mark.

[0089] Among them, Figure 1C For example, the subplan with the SEND operator as its root node can be understood as a partial plan consisting of the SEND-FILTER-SCAN operator. The destination node can refer to the node where the receive operator (i.e., the RECV operator) resides. The node where the RECV operator resides can be the node accessed by the user, that is, the node that first receives the user's query statement from the client.

[0090] Specifically, if the execution mode is normal mode, the sub-plan with the SEND operator as the root node can be sent to the execution node position corresponding to the SEND operator; then the data uploaded by the corresponding child operator is sent to the corresponding RECV operator according to the destination node setting through the SEND operator; finally, after receiving the data, the RECV operator sends the data to the corresponding parent operator until the receiving stop condition is met.

[0091] The receiving stop condition can be that the data received by the RECV operator contains a stop mark. The stop mark can be a mark added to the last data sent by the SEND operator. The stop mark can be flexibly set by relevant technical personnel. For example, it can be a mark composed of a string of characters to indicate that the data is the last data sent. The specific form of the stop mark is not limited here. If the data received by the RECV operator contains a stop mark, it can be understood that the data is the last data sent by the SEND operator. At this time, the RECV operator can stop receiving data after receiving this data.

[0092] A plan execution method provided in the second embodiment of the present invention specifies the process of determining the execution mode of the data distribution operator in the executable plan and executing the executable plan according to the execution mode. This method no longer distinguishes between local plans and remote plans during the plan generation phase. The SEND / RECV operators are uniformly retained in the generated plans. When the plan is reused, the execution mode of SEND / RECV is determined based on the actual execution node location of SEND. This method can effectively utilize the efficiency of plan reuse, reduce the size of the plan cache, and thus improve the efficiency of plan execution.

[0093] Example 3

[0094] Figure 5 This is a schematic diagram of the structure of a plan execution device provided by the third embodiment of the present invention, which can be implemented by software and / or hardware. Figure 5 As shown, the apparatus includes: a cutting module 310, a construction module 320 and an execution module 330;

[0095] The pruning module 310 is configured to perform partition pruning on the send operator in the execution plan based on the pruning information in the query statement to obtain a partition pruning result, wherein the partition pruning result includes the execution node position of the send operator;

[0096] A construction module 320, configured to construct an executable plan based on the to-be-executed plan and the partition pruning result;

[0097] The execution module 330 is configured to determine an execution mode of the data distribution operator in the executable plan according to the execution node position of the send operator, and execute the executable plan according to the execution mode.

[0098] In this embodiment, the device first uses a pruning module to partition and prune the send operator in the execution plan based on the pruning information in the query statement, obtaining a partition pruning result, wherein the partition pruning result includes the execution node position of the send operator. Then, a construction module constructs an executable plan based on the execution plan and the partition pruning result. Finally, an execution module determines the execution mode of the data distribution operator in the executable plan based on the execution node position of the send operator and executes the executable plan according to the execution mode. By changing the execution mode of the data distribution operator based on the execution node position of the send operator and executing the executable plan according to different execution modes, the device can effectively improve the efficiency of plan execution.

[0099] Optionally, the device further includes:

[0100] A matching module is used to perform plan cache matching on the obtained query statement before partition pruning of the send operator in the execution plan based on the pruning information in the query statement;

[0101] The determination module is used to determine the plan to be executed according to the matching result.

[0102] Optionally, determine the module, including:

[0103] If the matching result is successful, the matched plan is obtained from the plan cache as the plan to be executed;

[0104] If the matching result is a matching failure, a plan is generated and optimized for the query statement, and the obtained plan is used as a plan to be executed.

[0105] Optionally, the execution mode includes pipeline mode and normal mode.

[0106] Optionally, when executing the operation of “determining the execution mode of the data distribution operator in the executable plan according to the execution node position of the sending operator”, the execution module 330 specifically includes:

[0107] a first determining unit, configured to determine that the execution mode of the data distribution operator in the executable plan is a pipeline mode if the execution node locations of the sending operator are all local nodes;

[0108] The second determining unit is configured to determine that the execution mode of the data distribution operator in the executable plan is a normal mode otherwise.

[0109] Optionally, when executing the operation of “executing the executable plan according to the execution mode”, the execution module 330 specifically includes:

[0110] The first execution unit is configured to execute the executable plan in a stand-alone mode if the execution mode is a pipeline mode, wherein the data distribution operator serves as a pipeline operator to send received data to a corresponding parent operator.

[0111] Optionally, when executing the operation of “executing the executable plan according to the execution mode”, the execution module 330 specifically includes:

[0112] a first sending unit, configured to send the sub-plan with the sending operator as the root node to the corresponding execution node position if the execution mode is the normal mode;

[0113] A second sending unit is configured to send the data uploaded by the corresponding child operator to the corresponding receiving operator according to the destination node setting through the sending operator;

[0114] a third sending unit, configured for the receiving operator to send the data to the corresponding parent operator after receiving the data, until a receiving stop condition is met;

[0115] The receiving stop condition is that the data received by the receiving operator contains a stop mark.

[0116] The above-mentioned plan execution device can execute the plan execution method provided by any embodiment of the present invention, and has corresponding functional modules and beneficial effects of the execution method.

[0117] Example 4

[0118] Figure 6 This is a schematic diagram of the structure of a database node provided by the fourth embodiment of the present invention. Figure 6 As shown, the database node provided by the fourth embodiment of the present invention includes: a storage device 42 and one or more processors 41; the processor 41 in the database node can be one or more, Figure 6 Take a processor 41 as an example; the storage device 42 is used to store one or more programs; the one or more programs are executed by the one or more processors 41, so that the one or more processors 41 implement the plan execution method as described in any one of the embodiments of the present invention.

[0119] The database node may further include: a communication device 43 , an input device 44 and an output device 45 .

[0120] The processor 41, storage device 42, communication device 43, input device 44 and output device 45 in the database node can be connected through a bus or other means. Figure 6 The bus connection is taken as an example.

[0121] The storage device 42 in the database node is a computer-readable storage medium that can be used to store one or more programs, which can be software programs, computer executable programs, and modules, such as the program instructions / modules corresponding to the plan execution method provided in the first or second embodiment of the present invention (for example, the attached Figure 5 The modules in the plan execution device shown include: a cutting module 310, a construction module 320, and an execution module 340. The processor 41 executes the software programs, instructions, and modules stored in the storage device 42 to execute various functional applications and data processing of the database node, that is, to implement the plan execution method in the above method embodiment.

[0122] The storage device 42 may include a program storage area and a data storage area, wherein the program storage area may store an operating system and at least one application required for a function; the data storage area may store data created based on the use of the database node, etc. In addition, the storage device 42 may include a high-speed random access memory and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. In some instances, the storage device 42 may further include a memory remotely located relative to the processor 41, and these remote memories may be connected to the database node via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0123] The communication device 43 may include a receiver and a transmitter. The communication device 43 is configured to perform information transmission and reception communication according to the control of the processor 41.

[0124] The input device 44 may be used to receive input digital or character information and generate key signal input related to user settings and function control of the database node. The output device 45 may include a display device such as a display screen.

[0125] Moreover, when one or more programs included in the above-mentioned database node are executed by the one or more processors 41, the program performs the following operations: partitioning and pruning the sending operator in the to-be-executed plan based on the pruning information in the query statement to obtain a partition pruning result, wherein the partition pruning result includes the execution node position of the sending operator; constructing an executable plan based on the to-be-executed plan and the partition pruning result; determining the execution mode of the data distribution operator in the executable plan according to the execution node position of the sending operator, and executing the executable plan according to the execution mode.

[0126] Example 5

[0127] Embodiment 5 of the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is used to execute a plan execution method, the method comprising: partitioning and pruning a sending operator in a plan to be executed based on pruning information in a query statement to obtain a partition pruning result, wherein the partition pruning result includes an execution node position of the sending operator; constructing an executable plan based on the plan to be executed and the partition pruning result; determining an execution mode of a data distribution operator in the executable plan according to the execution node position of the sending operator, and executing the executable plan according to the execution mode.

[0128] Optionally, when the program is executed by a processor, it can also be used to execute the plan execution method provided by any embodiment of the present invention.

[0129] The computer storage medium of the embodiment of the present invention may adopt any combination of one or more computer-readable media. The computer-readable medium may be a computer-readable signal medium or a computer-readable storage medium. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or component, or any combination thereof. More specific examples (a non-exhaustive list) of computer-readable storage media include: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM), a flash memory, an optical fiber, a portable CD-ROM, an optical storage device, a magnetic storage device, or any suitable combination thereof. The computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, device or device.

[0130] A computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such a propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium that can transmit, propagate, or transport a program for use by or in conjunction with an instruction execution system, apparatus, or device.

[0131] The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wire, optical cable, or radio frequency (RF), etc., or any suitable combination thereof.

[0132] The computer program code for performing the operations of the present invention can be written in one or more programming languages, or a combination thereof, including object-oriented programming languages ​​such as Java, Smalltalk, C++, and conventional procedural programming languages ​​such as "C" or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0133] Note that the above are only preferred embodiments of the present invention and the technical principles employed. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and that various obvious changes, readjustments, and substitutions can be made by those skilled in the art without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in detail through the above embodiments, the present invention is not limited to the above embodiments and may include many other equivalent embodiments without departing from the concept of the present invention. The scope of the present invention is determined by the scope of the appended claims.

Claims

1. A plan execution method, characterized in that: The method comprises: Performing partition pruning on the send operator in the execution plan based on the pruning information in the query statement to obtain a partition pruning result, wherein the partition pruning result includes an execution node position of the send operator; Constructing an executable plan based on the to-be-executed plan and the partition pruning result; determining an execution mode of a data distribution operator in the executable plan according to an execution node position of the send operator, and executing the executable plan according to the execution mode; During the plan generation phase, local plans and remote plans are no longer distinguished, and the send operator and receive operator are uniformly retained in the generated execution plan.

2. The method according to claim 1, characterized in that Before partition pruning is performed on the send operators in the execution plan based on the pruning information in the query statement, the following is also included: Perform plan cache matching on the obtained query statement; The plan to be executed is determined according to the matching result.

3. The method according to claim 2, characterized in that Determining the plan to be executed based on the matching result includes: If the matching result is successful, the matched plan is obtained from the plan cache as the plan to be executed; If the matching result is a matching failure, a plan is generated and optimized for the query statement, and the obtained plan is used as a plan to be executed.

4. The method according to claim 1, wherein The execution mode includes pipeline mode and normal mode.

5. The method according to claim 4, characterized in that The determining, according to the execution node position of the sending operator, the execution mode of the data distribution operator in the executable plan includes: If the execution node locations of the sending operator are all local nodes, determining that the execution mode of the data distribution operator in the executable plan is pipeline mode; Otherwise, it is determined that the execution mode of the data distribution operator in the executable plan is a normal mode.

6. The method according to claim 4, characterized in that The executing the executable plan according to the execution mode includes: If the execution mode is pipeline mode, the executable plan is executed in stand-alone mode, wherein the data dispatch operator serves as a pipeline operator for sending received data to a corresponding parent operator.

7. The method according to claim 4, characterized in that The executing the executable plan according to the execution mode includes: If the execution mode is normal mode, the sub-plan with the send operator as the root node will be sent to the corresponding execution node position; The data uploaded by the corresponding child operator is sent to the corresponding receiving operator according to the destination node setting through the sending operator; After receiving the data, the receiving operator sends the data to the corresponding parent operator until a receiving stop condition is met; The receiving stop condition is that the data received by the receiving operator contains a stop mark.

8. A plan execution device, characterized in that: include: a pruning module, configured to perform partition pruning on the send operator in the execution plan based on the pruning information in the query statement, and obtain a partition pruning result, wherein the partition pruning result includes the execution node position of the send operator; A construction module, configured to construct an executable plan based on the to-be-executed plan and the partition pruning result; an execution module, configured to determine an execution mode of a data distribution operator in the executable plan according to an execution node position of the send operator, and execute the executable plan according to the execution mode; During the plan generation phase, local plans and remote plans are no longer distinguished, and the send operator and receive operator are uniformly retained in the generated execution plan.

9. A database node, characterized in that: include: one or more processors; a storage device for storing one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the plan execution method according to any one of claims 1 to 7.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the plan execution method as described in any one of claims 1 to 7 is implemented.

Citation Information

Patent Citations

  • Database system and distributed SQL statement execution plan reuse method

    CN101567006A

  • Distributed database system without sharing structure and realizing method thereof

    CN102201010A