Plan Scheduling Method, Device and System for Distributed Database
By analyzing execution dependencies in a distributed database, skipping the sub-plan that does not give up data, the problem of unnecessary scheduling is solved and data query efficiency is improved.
Patent Information
- Application Number
- CN202210386473.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-11
- Publication Date
- 2025-07-04
- Estimated Expiration
- 2042-04-11
AI Technical Summary
In distributed databases, in the prior art, the distributed logical sub-plan still performs scheduling without giving up data, resulting in unnecessary scheduling overhead and reduced data query efficiency.
By analyzing the execution dependencies of the distributed logical subplan, skip the subplan that does not give up data during the scheduling process, and determine the next subplan to be scheduled based on the execution dependencies to avoid unnecessary scheduling.
Reduces scheduling overhead and improves data query efficiency.
Smart Images

Figure CN114661752B_ABST
Abstract
Description
Technical Field
[0001] Embodiments of this specification generally relate to the field of databases, and in particular, to a plan scheduling method and apparatus for a distributed database, a data query method and data query engine, and a distributed database. Background Art
[0002] A distributed database consists of multiple distributed data storage nodes. Each distributed data storage node includes a data query engine and a data storage engine. Distributed databases usually adopt a share noting architecture, such as the OceanBase database. In such a distributed database, data is stored distributively in each data storage engine.
[0003] When performing a data query on a distributed database, after a distributed data storage node receives a data query statement, the distributed data storage node generates a distributed execution plan based on the received data query statement, converts the generated distributed execution plan into multiple distributed logical sub-plans, and these multiple distributed logical sub-plans are formed into a tree structure. These multiple distributed logical sub-plans are scheduled to multiple distributed data storage nodes in parallel according to a certain logical order to perform the data query. When scheduling the distributed logical sub-plans, all the distributed logical sub-plans are scheduled layer by layer in sequence to be executed once. According to this scheduling method, in the case where there is a distributed logical sub-plan that does not return data to the upper-layer logical sub-plan, if the upper-layer logical sub-plan of this distributed logical sub-plan is still scheduled to be executed, then since the data returned by this distributed logical sub-plan to the upper-layer logical sub-plan is an empty set, the execution result of this upper-layer logical sub-plan must be an empty set, thus making the scheduling execution of the upper-layer logical execution sub-plan an unnecessary scheduling process. Summary of the Invention
[0004] In view of the above, embodiments of this specification provide a plan scheduling method and apparatus for a distributed database, a data query method and data query engine, and a distributed database. By using this plan scheduling method and apparatus, during the plan scheduling process, once a distributed logical sub-plan that does not return data upward is encountered, the next distributed logical sub-plan to be scheduled is determined according to the execution dependency relationship of the distributed logical sub-plan, rather than according to the scheduling order of the distributed logical sub-plan, so that some distributed logical sub-plans that have an execution dependency relationship with this non-data-returning distributed logical sub-plan can be skipped during scheduling, thereby reducing the scheduling overhead and improving the data query efficiency.
[0005] According to one aspect of the embodiments of the present specification, a method for scheduling distributed logical sub-plans of a distributed database is provided. The distributed database includes a plurality of distributed data storage nodes. The distributed logical sub-plan is obtained by logically transforming a distributed execution plan and has a tree structure. The method includes: obtaining the execution result of the currently scheduled distributed logical sub-plan; in response to the execution result indicating that the currently scheduled distributed logical sub-plan does not spit back data, determining the next distributed logical sub-plan to be scheduled according to the execution dependency relationship and the scheduling order of the distributed logical sub-plan, where the execution dependency relationship of the distributed logical sub-plan is obtained when generating the distributed execution plan; and scheduling the determined next distributed logical sub-plan to the corresponding distributed data storage node for parallel execution, where, when scheduling and executing the determined next distributed logical sub-plan to be scheduled, an indication message for indicating that the currently scheduled distributed logical sub-plan does not spit back data is returned to the determined next distributed logical sub-plan to be scheduled.
[0006] Optionally, in an example of the above aspect, the method may further include: in response to the execution result indicating that the currently scheduled distributed logical sub-plan spits back data, determining the next distributed logical sub-plan to be scheduled according to the scheduling order of the distributed logical sub-plan.
[0007] Optionally, in an example of the above aspect, determining the next distributed logical sub-plan to be scheduled according to the execution dependency relationship and the scheduling order of the distributed logical sub-plan may include: when there is an unexecuted distributed logical sub-plan having an execution dependency relationship with the currently scheduled distributed logical sub-plan, determining the top-level distributed logical sub-plan among the unexecuted distributed logical sub-plans having an execution dependency relationship with the currently scheduled distributed logical sub-plan as the next distributed logical sub-plan to be scheduled; when there is no unexecuted distributed logical sub-plan having an execution dependency relationship with the currently scheduled distributed logical sub-plan, determining the next unexecuted distributed logical sub-plan in the scheduling order as the next distributed logical sub-plan to be scheduled.
[0008] Optionally, in an example of the above aspect, the distributed logical sub-plan is obtained by logically transforming the distributed execution plan with data redistribution points as boundaries.
[0009] Optionally, in an example of the above aspect, the distributed logical sub-plan includes a plurality of data processing operators and / or data exchange operators, and the plurality of data processing operators and / or data exchange operators are scheduled to a plurality of distributed data storage nodes in the distributed database for parallel processing.
[0010] Optionally, in an example of the above aspect, the scheduling order of the distributed logic sub-plans includes the traversal scheduling order of the distributed logic sub-plans.
[0011] Optionally, in an example of the above aspect, the traversal scheduling order of the distributed logic sub-plans and the current execution parallelism of the distributed logic sub-plans are determined according to the tree structure of the distributed logic sub-plans.
[0012] According to another aspect of the embodiments of the present specification, a method for querying data in a distributed database is provided. The distributed database includes a plurality of distributed data storage nodes, and each distributed data storage node includes a data query engine and a data storage engine. The data query method is executed by the data query engine, and the data query method includes: receiving a data query statement provided by a user; generating a distributed execution plan according to the received data query statement; performing logical transformation on the distributed execution plan to obtain a plurality of distributed logic sub-plans, and the plurality of distributed logic sub-plans are formed into a tree structure; scheduling the plurality of distributed logic sub-plans to corresponding distributed data storage nodes in sequence according to the scheduling strategy as described above for parallel execution; and providing the execution result of the top-level distributed logic sub-plan as the data query result to the user.
[0013] According to another aspect of the embodiments of the present specification, a plan scheduling device for scheduling distributed logic sub-plans of a distributed database is provided. The distributed database includes a plurality of distributed data storage nodes, and the distributed logic sub-plans are obtained by performing logical transformation on the distributed execution plan. The plan scheduling device includes: an execution result acquisition unit that acquires the execution result of the currently scheduled distributed logic sub-plan; a scheduling plan determination unit that, in response to the execution result indicating that the currently scheduled distributed logic sub-plan does not spit back data, determines the next distributed logic sub-plan to be scheduled according to the execution dependency relationship and the scheduling order of the distributed logic sub-plans, and the execution dependency relationship of the distributed logic sub-plans is obtained when generating the distributed execution plan; and a plan scheduling unit that schedules the determined next distributed logic sub-plan to the corresponding distributed data storage node for parallel execution, where, when scheduling and executing the determined next distributed logic sub-plan to be scheduled, an indication message for indicating that the currently scheduled distributed logic sub-plan does not spit back data is returned to the determined next distributed logic sub-plan to be scheduled.
[0014] Optionally, in an example of the above aspect, in response to the execution result indicating that the currently scheduled distributed logic sub-plan spits back data, the scheduling plan determination unit determines the next distributed logic sub-plan to be scheduled according to the scheduling order of the distributed logic sub-plans.
[0015] Optionally, in an example of the above aspect, in response to the execution result indicating that the currently scheduled distributed logic sub-plan does not spit out data, the scheduling plan determination unit is configured to, when there is an unexecuted distributed logic sub-plan having an execution dependency on the currently scheduled distributed logic sub-plan, determine the top-level distributed logic sub-plan among the unexecuted distributed logic sub-plans having an execution dependency on the currently scheduled distributed logic sub-plan as the next distributed logic sub-plan to be scheduled, and when there is no unexecuted distributed logic sub-plan having an execution dependency on the currently scheduled distributed logic sub-plan, determine the next unexecuted distributed logic sub-plan in the scheduling order as the next distributed logic sub-plan to be scheduled.
[0016] Optionally, in an example of the above aspect, the distributed logic sub-plan is obtained by logically transforming a distributed execution plan with data redistribution points as boundaries.
[0017] Optionally, in an example of the above aspect, the distributed logic sub-plan includes multiple data processing operators and / or data exchange operators, and the plan scheduling unit schedules the multiple data processing operators and / or data exchange operators to multiple distributed data storage nodes in the distributed database for parallel processing.
[0018] Optionally, in an example of the above aspect, the plan scheduling device may further include: a scheduling order determination unit that determines the scheduling order of the distributed logic sub-plan according to the tree structure of the distributed logic sub-plan.
[0019] Optionally, in an example of the above aspect, the scheduling order of the distributed logic sub-plan includes the traversal scheduling order of the distributed logic sub-plan.
[0020] Optionally, in an example of the above aspect, the scheduling order determination unit determines the traversal scheduling order of the distributed logic sub-plan and the current execution parallelism of the distributed logic sub-plan according to the tree structure of the distributed logic sub-plan.
[0021] According to another aspect of the embodiments of the present specification, there is provided a data query engine for a distributed database, the distributed database including a plurality of distributed data storage nodes, each distributed data storage node including a data query engine and a data storage engine, the data query engine including: a data query statement receiving device for receiving a data query statement provided by a user; a plan generating device for generating a distributed execution plan according to the received data query statement; a plan converting device for logically converting the distributed execution plan to obtain a plurality of distributed logical sub-plans; a plan scheduling device for sequentially scheduling the plurality of distributed logical sub-plans to corresponding distributed data storage nodes for parallel execution according to the scheduling strategy as described above; a plan executing device for executing the distributed logical sub-plan scheduled to the local distributed data storage node by the plan scheduling device; and a query result providing device for providing the execution result of the top-level distributed logical sub-plan to the user as the data query result.
[0022] According to another aspect of the embodiments of the present specification, there is provided a distributed database including: at least two distributed storage nodes, each storage node including a data storage engine and the data query engine as described above.
[0023] According to another aspect of the embodiments of the present specification, there is provided an execution plan scheduling device for a distributed database, including: at least one processor, a memory coupled to the at least one processor, and a computer program stored in the memory, the at least one processor executing the computer program to implement the plan scheduling method as described above.
[0024] According to another aspect of the embodiments of the present specification, there is provided a data query engine for a distributed database, including: at least one processor, a memory coupled to the at least one processor, and a computer program stored in the memory, the at least one processor executing the computer program to implement the data query method as described above.
[0025] According to another aspect of the embodiments of the present specification, there is provided a computer-readable storage medium storing executable instructions, the instructions when executed causing a processor to execute the plan scheduling method as described above or execute the data query method as described above.
[0026] According to another aspect of the embodiments of the present specification, there is provided a computer program product including a computer program, the computer program being executed by a processor to implement the plan scheduling method as described above or execute the data query method as described above. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] A further understanding of the essence and advantages of the content of this specification can be achieved by referring to the following drawings. In the drawings, similar components or features may have the same reference numerals.
[0028] Figure 1 An exemplary schematic diagram of a distributed database is shown.
[0029] Figure 2 An exemplary block diagram of an existing data query engine is shown.
[0030] Figure 3 Shows a Figure 2 An exemplary flowchart of a data query process of a distributed database implemented based on the data query engine in
[0031] Figure 4 An exemplary schematic diagram of a distributed execution plan is shown.
[0032] Figure 5 Shows a Figure 4 An exemplary schematic diagram of a distributed logical sub-plan obtained after logically transforming the distributed execution plan shown in
[0033] Figure 6 Shows a Figure 3 An exemplary schematic diagram of the data query process shown in
[0034] Figure 7 An exemplary block diagram of a data query engine according to an embodiment of this specification is shown.
[0035] Figure 8 An exemplary flowchart of a data query process of a distributed database according to an embodiment of this specification is shown.
[0036] Figure 9 Shows a Figure 5 An exemplary schematic diagram of the execution dependency relationship of the distributed logical sub-plan in
[0037] Figures 10A - 10E An exemplary schematic diagram of the tree structure of the distributed logical sub-plan is shown.
[0038] Figure 11 An exemplary flowchart of a plan scheduling method for a distributed database according to an embodiment of this specification is shown.
[0039] Figure 12 An exemplary schematic diagram of a plan scheduling device implemented based on a computer system according to an embodiment of this specification is shown.
[0040] Figure 13 An exemplary schematic diagram of a data query engine implemented based on a computer system according to an embodiment of this specification is shown. Detailed Implementation Manner
[0041] The subject matter described herein will now be discussed with reference to exemplary embodiments. It should be understood that discussing these embodiments is only to enable those skilled in the art to better understand and thus implement the subject matter described herein, and is not a limitation on the scope of protection, applicability, or examples set forth in the claims. Changes can be made to the functions and arrangements of the elements discussed without departing from the scope of protection of the content of this specification. Each example can omit, substitute, or add various processes or components as needed. For example, the methods described can be performed in a different order from the described order, and each step can be added, omitted, or combined. Additionally, the features described relative to some examples can also be combined in other examples.
[0042] As used herein, the term "comprising" and its variants represent open terms, meaning "including but not limited to". The term "based on" means "at least partially based on". The term "one embodiment" and "an embodiment" mean "at least one embodiment". The term "another embodiment" means "at least one other embodiment". The terms "first", "second", etc. can refer to different or the same objects. Other definitions, whether explicit or implicit, may be included below. Unless clearly specified in the context, the definition of a term is consistent throughout the specification.
[0043] Figure 1 An example schematic diagram of the distributed database 1 is shown. As Figure 1 shown, the distributed database system 1 includes multiple storage nodes 10-1 to 10-4. The storage nodes 10-1 to 10-4 are distributed storage nodes, and each storage node includes a data query engine and a data storage engine. It should be noted that Figure 1 the example shown is merely illustrative. In other embodiments, the distributed database system 1 may include more or fewer storage nodes.
[0044] The distributed database 1 can, for example, adopt a share noting architecture, such as, for example, the OceanBase database. In such a distributed database, data is stored distributively in the storage engines of each storage node. For example, the data can be divided into multiple data partitions (which can also be referred to as data chunks), and the divided data partitions are respectively stored in different storage engines. Each storage engine can store one or more data partitions. The CPU resources and IO resources required for data access involved in each storage node occur locally and are executed by the data query engine on that storage node.
[0045] After the local data query engine of the storage node receives a data query statement and generates a distributed execution plan, the local data query engine converts the distributed execution plan logic into multiple logical sub-plans (e.g., logical conversion according to semantics). In this specification, the logical sub-execution sub-plan can be referred to as DFO (Data Flow Operation). After completing the DFO conversion, the local data query engine schedules the generated DFOs in parallel to multiple storage nodes for parallel execution.
[0046] Figure 2 shows an example block diagram of an existing data query engine 200, and Figure 3 shows a Figure 2 sample flowchart of a data query process 300 of a distributed database implemented based on the data query engine in
[0047] As Figure 2 shown, the data query engine 200 includes a data query statement receiving device 210, a plan generating device 220, a plan converting device 230, a plan scheduling device 240, and a plan executing device 250.
[0048] When performing a data query, as Figure 3 shown, at 310, a data query statement is received via the data query statement receiving device 210. For example, in one example, the data query can be, for example, an SQL query, and the data query statement can include an SQL statement. For example, the received SQL statement can be, for example, "select t2.a,t2.b,(select sum(c)from t5where t1.b=t5.a)as sum from t1,t2,t3,t4 where t1.a=1and t1.b=t2.a and t1.b=t3.aand t1.b=t4.a". In one example, the data query statement receiving device 210 can be implemented as an input interface, input unit, or input device of the data query engine. For example, the data query statement receiving device 210 can be an input box on the client interface of the data query engine, etc.
[0049] At 320, a distributed execution plan is generated by the plan generation device 220 according to the received data query statement. The plan generation device 220 may include an optimizer, for example, an SQL optimizer. The distributed execution plan may include, for example, an SQL execution plan having a tree structure composed of multiple SQL operators. An SQL operator is the basic building block that makes up an SQL execution plan and is used to describe the basic operations corresponding to specific SQL semantics. For example, TABLE SCAN operator, TABLE INSERT operator, TABLE UPDATE operator, TABLE DELETE operator, JOIN operator, GROUP BY operator, ORDER BY operator, EXCHANGE operator, etc. Figure 4 The example schematic diagram of the SQL execution plan is shown.
[0050] At 330, the distributed execution plan is logically converted into multiple DFOs by the plan conversion device 230. For example, the plan conversion device 230 may logically convert the SQL execution plan into multiple DFOs according to SQL semantics. For the Figure 4 SQL execution plan shown in, the SQL execution plan can be logically converted with the EXCHANGE OUT operator (send operator) / EXCHANGE IN operator (receive operator) as the boundary, and the obtained logical conversion result is as shown in Figure 5 shown. In the Figure 5 example, the SQL operators are assigned numbers (ID column). For example, the 0th operator is UNION ALL. As shown in Figure 5 shown, the 0th operator, the 1st operator, and the 20th operator form DFO0 (Root DFO or root DFO). The 2nd operator - the 4th operator and the 18th operator - the 19th operator form DFO1. The 5th operator - the 7th operator and the 16th operator - the 17th operator form DFO2. The 8th operator - the 10th operator and the 14th operator - the 15th operator form DFO3. The 11th operator - the 13th operator form DFO4. The 21st operator - the 23rd operator and the 37th operator - the 38th operator form DFO5. The 24th operator - the 26th operator and the 35th operator - the 36th operator form DFO6. The 27th operator - the 29th operator and the 33rd operator - the 34th operator form DFO7. The 30th operator - the 32nd operator form DFO8. It should be noted that Figure 5 the English characters at each node in are the abbreviations of the corresponding execution operators in the distributed execution plan.
[0051] Each obtained DFO operator may include multiple serially executed operators, for example, multiple SQL operators. For example, one DFO contains a scan partition operator, an aggregation operator, and a send operator, and another DFO contains a collection operator, an aggregation operator, etc.
[0052] Next, loop and execute from 340 to 370 until the query result of the output data is obtained.
[0053] Specifically, in each loop, at 340, the generated DFOs are sequentially scheduled and executed via the planning and scheduling device 240. When performing DFO scheduling, at 350, it is determined whether the scheduling is completed, that is, whether the scheduling process is completed for all DFOs. If the scheduling process is completed for all DFOs, then at 380, the processing result of the current DFO (i.e., Root DFO) is provided to the user as the data query result. If there are still unscheduled DFOs, then at 360, the next DFO to be scheduled is determined according to a certain logical order, and the DFO to be scheduled is scheduled to a suitable distributed data storage node. The data query engines of each distributed data storage node execute the received DFOs in parallel. Then, at 370, after the DFOs at each distributed data storage node are executed in parallel, the data is streamed back to the parent DFO (Patent DFO). If there are no unscheduled DFOs, the data query result is output to the user. If there are unscheduled DFOs, return to 340 and loop.
[0054] Figure 6 shows Figure 3 an example schematic diagram of the data query process shown in Figure 6 In the example of Figure 6 when performing data query, the PX Operator in the distributed storage node that receives the data query statement initiated by the user acts as the query coordinator (QC). This distributed storage node reserves sufficient thread resources. When the distributed execution plan needs to be executed in parallel, the QC determines the degree of parallelism and sends a working thread acquisition request (QC request) to the sub-query coordinators (SQC) on each distributed storage node. The SQC is the thread on each distributed storage node for processing the QC request. The SQC is responsible for applying for execution resources for the DFO on the local distributed storage node, constructing the execution context environment, etc., and then scheduling the working thread (Worker) to execute the DFO in parallel on each distributed storage node. As
[0055] As Figure 6 shown, the QC distributes the DFOs that need to be executed in parallel to the appropriate distributed storage nodes in the form of RPC. The SQC in the distributed storage node schedules the PX thread to execute the received DFO. When the DFOs of each distributed storage node are executed, the execution results are streamed back to the parent DFO.
[0056] In the above data query solution, when scheduling DFOs, all DFOs are scheduled layer by layer in sequence to execute once. According to this scheduling method, in the case where a DFO does not spit back data to the upper-layer DFO (parent DFO), the upper-layer DFO of this DFO is still scheduled to execute. During actual execution, since the data spit back by this DFO to the upper-layer DFO is an empty set, the execution result of this upper-layer DFO must be an empty set, which makes the scheduling execution of the upper-layer DFO an unnecessary scheduling execution. Each scheduling execution will generate scheduling overheads (such as computing resource overheads) and processing time, thus causing unnecessary scheduling overheads and reducing the data query efficiency.
[0057] In view of the above, an embodiment of this specification proposes a plan scheduling solution for a distributed database. By using this plan scheduling solution, during the generation process of a distributed execution plan, each execution operator is analyzed to determine whether there is a semantic dependency between the execution operators, thereby determining the execution dependency relationship between each DFO. During the plan scheduling process, once a DFO that does not spit back data upward is encountered, the next DFO to be scheduled is determined according to the execution dependency relationship of the DFO, rather than according to the scheduling order of the DFO, so that some DFOs that have an execution dependency relationship with this DFO that does not spit back data can be skipped without scheduling, thereby reducing the scheduling overhead and improving the data query efficiency.
[0058] Figure 7 An example block diagram of a data query engine 700 according to an embodiment of this specification is shown.
[0059] As Figure 7 shown, the data query engine 700 includes a data query statement receiving device 710, a plan generation device 720, a plan conversion device 730, a plan scheduling device 740, a plan execution device 750, and a query result providing device 760.
[0060] The data query statement receiving device 710 is configured to receive a data query statement. For example, in one example, the data query can be, for example, an SQL query, and the data query statement can include an SQL statement. For example, the received SQL statement can be, for example, "select t2.a,t2.b,(select sum(c)from t5 where t1.b=t5.a)as sumfrom t1,t2,t3,t4 where t1.a=1and t1.b=t2.a and t1.b=t3.a and t1.b=t4.a". In one example, the data query statement receiving device 210 can be implemented as an input interface, an input unit, or an input device of a data query engine. For example, the data query statement receiving device 210 can be an input box on the client interface of the data query engine, etc.
[0061] The plan generation device 720 is configured to generate a distributed execution plan according to the received data query statement. Examples of the plan generation device 720 can include, for example, an optimizer, for example, an SQL optimizer. Figure 4 A schematic diagram of an example of an SQL execution plan is shown.
[0062] The plan conversion device 730 is configured to perform a logical transformation on the distributed execution plan to obtain a plurality of distributed logical sub-plans (DFOs). In one example, the plan conversion device 730 can perform a logical transformation on the distributed execution plan with data redistribution points as boundaries to obtain a plurality of DFOs, as Figure 5 shown. In this specification, the term "data redistribution" refers to, for example, a data distribution process of redistributing data from storage node A to storage node B, and this data distribution process can be implemented by operators responsible for data sending and data receiving in the distributed execution plan (for example, Exchange out operator and Exchange in operator). The splitting of DFOs will be split into two DFOs according to the Exchange out operator and the Exchange in operator. Among them, one DFO is responsible for sending data after executing all the execution operators of this DFO, and the other DFO is responsible for executing all the execution operators of this DFO after receiving the data. In addition to the Exchange operator, data redistribution can also be implemented using the PX COORD operator. The PX COORD operator is a special Exchange in operator. In addition to having the function of receiving data, it also has the function of scheduling the execution of sub-DFOs.
[0063] In addition, the plan generation device 720 can also perform semantic analysis on each execution operator of the distributed execution plan to determine the semantic dependency relationships between the execution operators. After converting the distributed execution plan into DFOs, the plan generation device 720 determines the execution dependency relationships between the respective DFOs based on the semantic dependency relationships between the execution operators. For example, for the operator inner_join, as long as any of its sub-operators does not return data, the operator inner_join will not return data either. When determining the semantic dependency relationships between the operators, semantic analysis is performed from bottom to top. For aggregate function operations such as count / sum, even if the sub-operator has no data, data still needs to be returned, and the dependency relationship will be interrupted in the DFO containing such an operator.
[0064] For DFOs formed into a tree structure, there are dependency relationships between the multiple tree-shaped DFOs, and the upper-level parent DFO depends on the data of the lower-level child DFOs. If a child DFO has no data, the intermediate parent DFOs of that child DFO can be skipped and execution can proceed directly to the top-level parent DFO in the dependency relationship.
[0065] Figure 9 shows Figure 5 an example schematic diagram of the execution dependency relationships of the distributed logical sub-plan in Figure 9 the example. In
[0066] the example, DFO0 has an execution dependency relationship with DFO1 and DFO5. DFO1 has dependency relationships with DFO2, DFO3, and DFO4. DFO2 has dependency relationships with DFO3 and DFO4. DFO3 has a dependency relationship with DFO4. DFO5 has dependency relationships with DFO6, DFO7, and DFO8. DFO6 has dependency relationships with DFO7 and DFO8. DFO7 has a dependency relationship with DFO8. In addition, DFO1, DFO2, DFO3, and DFO4 form a dependency relationship link, and DFO1 is the top-level DFO in this dependency relationship link. DFO5, DFO6, DFO7, and DFO8 form a dependency relationship link, and DFO5 is the top-level DFO in this dependency relationship link. It should be noted that when confirming the dependency relationships, the root DFO (i.e., DFO0) is not considered.
[0067] Figures 10A - 10EThe example schematic diagram showing the tree structure of the distributed logic sub-plan is shown.
[0068] In Figure 10A In the shown tree structure, the parallel execution degree of the DFO is 2, that is, 2 DFOs are executed simultaneously. The scheduling order of the DFO is DFO2 → DFO1 → DFO4 → DFO3 → DFO8 → DFO7 → DFO6 → DFO5. In Figure 10B In the shown tree structure, the parallel execution degree of the DFO is 2 or 3, that is, 2 DFOs or 3 DFOs are executed simultaneously. The scheduling order of the DFO is DFO4 → DFO3 → DFO2 → DFO1 → DFO8 → DFO7 → DFO6 → DFO5. In Figure 10C In the shown tree structure, the parallel execution degree of the DFO is 2, that is, 2 DFOs are executed simultaneously. The scheduling order of the DFO is DFO4 → DFO2 → DFO1 → DFO3 → DFO8 → DFO7 → DFO6 → DFO5. In Figure 10D In the shown tree structure, the parallel execution degree of the DFO is 2 or 3, that is, 2 DFOs or 3 DFOs are executed simultaneously. The scheduling order of the DFO is DFO4 → DFO2 → DFO1 → DFO10 → DFO9 → DFO3 → DFO8 → DFO7 → DFO6 → DFO5. Figure 10E In the shown tree structure, the parallel execution degree of the DFO is 2 or 3, that is, 2 DFOs or 3 DFOs are executed simultaneously. The scheduling order of the DFO is DFO10 → DFO9 → DFO3 → DFO4 → DFO2 → DFO1 → DFO8 → DFO7 → DFO6 → DFO5.
[0069] The plan scheduling device 740 is configured to schedule multiple DFOs to corresponding distributed data storage nodes in sequence for parallel execution according to the execution results of the DFOs. Each DFO may include multiple data processing operators and / or data exchange operators. When the DFO is executed, the multiple data processing operators and / or data exchange operators may be scheduled to multiple distributed data storage nodes in the distributed database for parallel processing.
[0070] The DFO scheduling process of the plan scheduling device 740 is a cyclic execution process. In each cyclic process, the plan scheduling device 740 determines the next DFO to be scheduled according to the execution results of the current DFO, and schedules the determined next DFO to the distributed data storage node for parallel execution.
[0071] Specifically, in response to the execution result of the currently scheduled DFO indicating that the DFO does not spit out data, the plan scheduling device 740 determines the next DFO to be scheduled according to the execution dependency and scheduling order of the DFO. In response to the execution result of the currently scheduled DFO indicating that the DFO spits out data, the plan scheduling device 740 determines the next DFO to be scheduled according to the scheduling order of the DFO.
[0072] In one example, in response to the execution result of the currently scheduled DFO indicating that the DFO does not spit out data, when there is an unexecuted DFO that has an execution dependency with the currently scheduled DFO, the plan scheduling device 740 determines the topmost DFO among the unexecuted DFOs as the next DFO to be scheduled. When there is no unexecuted DFO that has an execution dependency with the currently scheduled DFO, the plan scheduling device 740 determines the next unexecuted DFO in the scheduling order as the next DFO to be scheduled.
[0073] The plan execution device 750 is configured to execute the DFO scheduled by the plan scheduling device 740 to the distributed data storage node where it is located. The query result providing device is configured to provide the execution result of the topmost DFO (i.e., the root DFO) as the data query result to the user.
[0074] Figure 8 An example flowchart of the data query process 1100 of the distributed database according to an embodiment of the present specification is shown.
[0075] As Figure 8 shown, at 810, the data query statement receiving device receives the data query statement provided by the user. At 820, the plan generating device generates a distributed execution plan according to the received data query statement.
[0076] At 830, the plan conversion device performs a logical transformation on the distributed execution plan to obtain a plurality of distributed logical sub-plans, and the obtained plurality of distributed logical sub-plans are formed into a tree structure.
[0077] At 840, the plan scheduling device schedules the plurality of distributed logical sub-plans to the corresponding distributed data storage nodes in sequence for parallel execution.
[0078] Figure 11 An example flowchart of the plan scheduling method 1100 of the distributed database according to an embodiment of the present specification is shown. Figure 11 The shown plan scheduling method is repeatedly executed by the plan scheduling device.
[0079] As Figure 11As shown, during each loop, at 1110, the currently scheduled DFO is scheduled to multiple suitable distributed data storage nodes for parallel execution. In response to the completion of the parallel execution of the DFO at multiple distributed data nodes, at 1120, the execution result of the currently scheduled DFO is obtained. For example, each distributed data node streams back its respective execution result to the plan scheduling device, and the plan scheduling device determines the execution result of the currently scheduled DFO based on the execution results returned by each distributed data node and provides it to the parent DFO of the currently scheduled DFO. Alternatively, the plan scheduling device directly provides the execution results returned by each distributed data node to the parent DFO of the currently scheduled DFO.
[0080] At 1130, it is determined whether the scheduling is completed. If the scheduling is completed, the execution result of the current DFO (i.e., the top-level DFO) is provided to the user as the data query result.
[0081] If the scheduling is not completed, then at 1140, based on the execution result of the current DFO, the next DFO to be scheduled is determined. Specifically, in response to the execution result of the currently scheduled DFO indicating that the DFO does not spit out data, the next DFO to be scheduled is determined according to the execution dependency relationship and the scheduling order of the DFO. In response to the execution result of the currently scheduled DFO indicating that the DFO spits out data, the next DFO to be scheduled is determined according to the scheduling order of the DFO.
[0082] In one example, in response to the execution result of the currently scheduled DFO indicating that the DFO does not spit out data, when there is an unexecuted DFO that has an execution dependency relationship with the currently scheduled DFO, the top-level DFO among the unexecuted DFOs is determined as the next DFO to be scheduled. When there is no unexecuted DFO that has an execution dependency relationship with the currently scheduled DFO, the next unexecuted DFO in the scheduling order is determined as the next DFO to be scheduled.
[0083] After determining the next DFO to be scheduled, it returns to 1110 to execute the next loop process. When the determined next DFO to be scheduled is determined according to the execution dependency relationship and the scheduling order of the DFO, an indication message for indicating that the currently scheduled DFO does not spit out data is also returned to the determined next DFO to be scheduled, for example, an EOF (End of File) message.
[0084] As described above with reference to Figures 1 to 11 , a plan scheduling method, a plan scheduling device, a data query method, a data query engine, and a distributed database for a distributed database according to an embodiment of the present specification are described. The above plan scheduling device and data query engine can be implemented in hardware, or can be implemented in software or a combination of hardware and software.
[0085] Figure 12 FIG. 2 shows a schematic diagram of a computer system-implemented plan scheduling apparatus 1200 according to an embodiment of the present specification. As Figure 12 shown, the plan scheduling apparatus 1200 may include at least one processor 1210, a memory (e.g., a non-volatile memory) 1220, a memory 1230, and a communication interface 1240, and the at least one processor 1210, the memory 1220, the memory 1230, and the communication interface 1240 are connected together via a bus 1260. The at least one processor 1210 executes at least one computer-readable instruction stored or encoded in the memory (i.e., the above-mentioned elements implemented in software form).
[0086] In one embodiment, computer-executable instructions are stored in the memory, which when executed cause the at least one processor 1210 to: obtain the execution result of the currently scheduled distributed logical sub-plan; in response to the execution result indicating that the currently scheduled distributed logical sub-plan does not spit back data, determine the next distributed logical sub-plan to be scheduled according to the execution dependency relationship and the scheduling order of the distributed logical sub-plan, where the execution dependency relationship of the distributed logical sub-plan is obtained when generating the distributed execution plan; and schedule the determined next distributed logical sub-plan to the corresponding distributed data storage node for parallel execution, where, when scheduling the execution of the determined next distributed logical sub-plan to be scheduled, an indication message for indicating that the currently scheduled distributed logical sub-plan does not spit back data is returned to the determined next distributed logical sub-plan to be scheduled.
[0087] It should be understood that the computer-executable instructions stored in the memory, when executed, cause the at least one processor 1210 to perform the various operations and functions described above in the various embodiments of the present specification in combination with Figures 1 - 11 the description.
[0088] Figure 13 FIG. 3 shows a schematic diagram of a computer system-implemented data query engine 1300 according to an embodiment of the present specification. As Figure 13 shown, the data query engine 1300 may include at least one processor 1310, a memory (e.g., a non-volatile memory) 1320, a memory 1330, and a communication interface 1340, and the at least one processor 1310, the memory 1320, the memory 1330, and the communication interface 1340 are connected together via a bus 1360. The at least one processor 1310 executes at least one computer-readable instruction stored or encoded in the memory (i.e., the above-mentioned elements implemented in software form).
[0089] In one embodiment, computer-executable instructions are stored in a memory, which when executed cause at least one processor 1310 to: receive a data query statement provided by a user; generate a distributed execution plan according to the received data query statement; perform a logical transformation on the distributed execution plan to obtain a plurality of distributed logical sub-plans, and the plurality of distributed logical sub-plans are formed into a tree structure; according to the scheduling strategy as described above, sequentially schedule the plurality of distributed logical sub-plans to corresponding distributed data storage nodes for parallel execution; and provide the execution result of the top-level distributed logical sub-plan to the user as a data query result.
[0090] It should be understood that the computer-executable instructions stored in the memory, when executed, cause at least one processor 1310 to perform the various operations and functions described above in the respective embodiments of this specification in combination with Figures 1 - 11 the description.
[0091] According to one embodiment, a program product such as a machine-readable medium (e.g., a non-transitory machine-readable medium) is provided. The machine-readable medium may have instructions (i.e., the elements implemented in software as described above), which when executed by the machine cause the machine to perform the various operations and functions described above in the respective embodiments of this specification in combination with Figures 1 - 11 the description. Specifically, a system or device equipped with a readable storage medium may be provided, on which software program code for implementing the functions of any one of the above embodiments is stored, and cause a computer or processor of the system or device to read and execute the instructions stored in the readable storage medium.
[0092] In this case, the program code read from the readable medium itself can implement the functions of any one of the above embodiments, so the machine-readable code and the readable storage medium storing the machine-readable code constitute a part of the present invention.
[0093] Examples of the readable storage medium include floppy disks, hard disks, magneto-optical disks, optical disks (such as CD-ROM, CD-R, CD-RW, DVD-ROM, DVD-RAM, DVD-RW, DVD-RW), magnetic tapes, non-volatile memory cards, and ROMs. Optionally, the program code can be downloaded from a server computer or the cloud via a communication network.
[0094] According to one embodiment, a computer program product is provided, which includes a computer program that, when executed by a processor, causes the processor to perform the various operations and functions described above in the respective embodiments of this specification in combination with Figures 1 - 11 the description.
[0095] Those skilled in the art should understand that various modifications and changes can be made to the above-disclosed embodiments without departing from the essence of the invention. Therefore, the protection scope of the present invention should be defined by the appended claims.
[0096] It should be noted that not all steps and units in the above-mentioned processes and system structure diagrams are necessary, and some steps or units can be ignored according to actual needs. The execution order of each step is not fixed and can be determined according to needs. The device structures described in the above embodiments can be physical structures or logical structures, that is, some units may be implemented by the same physical entity, or some units may be implemented by multiple physical entities respectively, or some components in multiple independent devices may be jointly implemented.
[0097] In the above embodiments, the hardware units or modules can be implemented mechanically or electrically. For example, a hardware unit, module or processor can include permanent dedicated circuits or logics (such as dedicated processors, FPGAs or ASICs) to complete corresponding operations. The hardware unit or processor can also include programmable logics or circuits (such as general-purpose processors or other programmable processors), which can be temporarily set by software to complete corresponding operations. The specific implementation method (mechanical method, or dedicated permanent circuit, or temporarily set circuit) can be determined based on cost and time considerations.
[0098] The specific embodiments described above in conjunction with the accompanying drawings describe exemplary embodiments, but do not represent all embodiments that can be implemented or fall within the protection scope of the claims. The term "exemplary" used throughout this specification means "serving as an example, instance, or illustration", and does not mean "preferred" or "having advantages" over other embodiments. For the purpose of providing an understanding of the described technology, the specific embodiments include specific details. However, these technologies can be implemented without these specific details. In some instances, well-known structures and devices are shown in block diagram form to avoid obscuring the concepts of the described embodiments.
[0099] The above description of the present disclosure is provided to enable any ordinary person skilled in the art to implement or use the present disclosure. Various modifications to the present disclosure are obvious to those of ordinary skill in the art, and the general principles defined herein can also be applied to other variations without departing from the protection scope of the present disclosure. Therefore, the present disclosure is not limited to the examples and designs described herein, but is consistent with the broadest scope that conforms to the principles and novel features disclosed herein.
Claims
1. A method for scheduling distributed logical sub - plans of a distributed database, the distributed database including a plurality of distributed data storage nodes, the distributed logical sub - plan being obtained by logically transforming a distributed execution plan and having a tree - like structure, the method comprising: Obtaining the execution result of the currently scheduled distributed logical sub - plan; In response to the execution result indicating that the currently scheduled distributed logical sub - plan does not spit back data, determining the next distributed logical sub - plan to be scheduled according to the execution dependency relationship and the scheduling order of the distributed logical sub - plan, the execution dependency relationship of the distributed logical sub - plan being obtained when generating the distributed execution plan; And Scheduling the determined next distributed logical sub - plan to the corresponding distributed data storage node for parallel execution, wherein when scheduling and executing the determined next distributed logical sub - plan to be scheduled, an indication message for indicating that the currently scheduled distributed logical sub - plan does not spit back data is returned to the determined next distributed logical sub - plan to be scheduled, wherein determining the next distributed logical sub - plan to be scheduled according to the execution dependency relationship of the distributed logical sub - plan and the scheduling order of the distributed logical sub - plan includes: When there is an unexecuted distributed logical sub - plan having an execution dependency relationship with the currently scheduled distributed logical sub - plan, determining the top - most distributed logical sub - plan among the unexecuted distributed logical sub - plans having an execution dependency relationship with the currently scheduled distributed logical sub - plan as the next distributed logical sub - plan to be scheduled, When there is no unexecuted distributed logical sub - plan having an execution dependency relationship with the currently scheduled distributed logical sub - plan, determining the next unexecuted distributed logical sub - plan in the scheduling order as the next distributed logical sub - plan to be scheduled.
2. The method according to claim 1, further comprising: In response to the execution result indicating that the currently scheduled distributed logical sub - plan spits back data, determining the next distributed logical sub - plan to be scheduled according to the scheduling order of the distributed logical sub - plan.
3. The method according to claim 1, wherein, The distributed logical sub - plan is obtained by logically transforming the distributed execution plan with data redistribution points as boundaries.
4. The method according to claim 3, wherein, The distributed logical sub - plan includes a plurality of data processing operators and / or data exchange operators, and the plurality of data processing operators and / or data exchange operators are scheduled to a plurality of distributed data storage nodes in the distributed database for parallel processing.
5. The method according to claim 4, wherein The scheduling order of the distributed logical sub - plan includes the traversal scheduling order of the distributed logical sub - plan.
6. The method according to claim 5, wherein, The traversal scheduling order of the distributed logical sub - plan and the current execution parallelism of the distributed logical sub - plan are determined according to the tree - like structure of the distributed logical sub - plan.
7. A data query method for a distributed database, the distributed database including a plurality of distributed data storage nodes, each distributed data storage node including a data query engine and a data storage engine, the data query method being executed by the data query engine, the data query method comprising: Receiving a data query statement provided by a user; Generate a distributed execution plan according to the received data query statement; Perform a logical transformation on the distributed execution plan to obtain multiple distributed logical sub-plans, and the multiple distributed logical sub-plans are formed into a tree structure; According to the method described in any one of claims 1 to 6, schedule the multiple distributed logical sub-plans to corresponding distributed data storage nodes in sequence for parallel execution; And Provide the execution result of the top-level distributed logical sub-plan as the data query result to the user.
8. A plan scheduling device for scheduling distributed logical sub-plans of a distributed database, the distributed database includes multiple distributed data storage nodes, the distributed logical sub-plans are obtained by performing a logical transformation on a distributed execution plan, and the plan scheduling device includes: An execution result acquisition unit that acquires the execution result of the currently scheduled distributed logical sub-plan; A scheduling plan determination unit that, in response to the execution result indicating that the currently scheduled distributed logical sub-plan does not spit back data, determines the next distributed logical sub-plan to be scheduled according to the execution dependency relationship and the scheduling order of the distributed logical sub-plan, and the execution dependency relationship of the distributed logical sub-plan is obtained when generating the distributed execution plan; And A plan scheduling unit that schedules the determined next distributed logical sub-plan to the corresponding distributed data storage node for parallel execution, wherein when scheduling and executing the determined next distributed logical sub-plan to be scheduled, an indication message for indicating that the currently scheduled distributed logical sub-plan does not spit back data is returned to the determined next distributed logical sub-plan to be scheduled, wherein, in response to the execution result indicating that the currently scheduled distributed logical sub-plan does not spit back data, the scheduling plan determination unit is configured to: When there are unexecuted distributed logical sub-plans that have an execution dependency relationship with the currently scheduled distributed logical sub-plan, determine the top-level distributed logical sub-plan among the unexecuted distributed logical sub-plans that have an execution dependency relationship with the currently scheduled distributed logical sub-plan as the next distributed logical sub-plan to be scheduled, When there are no unexecuted distributed logical sub-plans that have an execution dependency relationship with the currently scheduled distributed logical sub-plan, determine the next unexecuted distributed logical sub-plan in the scheduling order as the next distributed logical sub-plan to be scheduled.
9. The planned scheduling device according to claim 8, wherein, In response to the execution result indicating that the currently scheduled distributed logical sub-plan spits back data, the scheduling plan determination unit determines the next distributed logical sub-plan to be scheduled according to the scheduling order of the distributed logical sub-plan.
10. The planned scheduling device according to claim 8, wherein, The distributed logical sub-plans are obtained by performing a logical transformation on the distributed execution plan with data redistribution points as boundaries.
11. The planned scheduling device according to claim 10, wherein, The distributed logical sub-plans include multiple data processing operators and / or data exchange operators, and the plan scheduling unit schedules the multiple data processing operators and / or data exchange operators to multiple distributed data storage nodes in the distributed database for parallel processing.
12. The plan scheduling device according to claim 11, further comprising: A scheduling order determination unit determines the scheduling order of the distributed logical sub - plans according to the tree - like structure of the distributed logical sub - plans.
13. The planned scheduling device according to claim 12, wherein, The scheduling order of the distributed logical sub - plans includes the traversal scheduling order of the distributed logical sub - plans.
14. The planned scheduling device according to claim 12, wherein, The scheduling order determination unit determines the traversal scheduling order of the distributed logical sub - plans according to the tree - like structure of the distributed logical sub - plans.
15. A data query engine for a distributed database, the distributed database includes a plurality of distributed data storage nodes, each distributed data storage node includes a data query engine and a data storage engine, and the data query engine includes: A data query statement receiving device that receives a data query statement provided by a user; A plan generation device that generates a distributed execution plan according to the received data query statement; A plan conversion device that performs logical transformation on the distributed execution plan to obtain a plurality of distributed logical sub - plans; A plan scheduling device that schedules the plurality of distributed logical sub - plans to corresponding distributed data storage nodes in sequence to execute in parallel according to the method described in any one of claims 1 to 6; A plan execution device that executes the distributed logical sub - plan scheduled to the local distributed data storage node by the plan scheduling device; And A query result providing device that provides the execution result of the top - level distributed logical sub - plan to the user as the data query result.
16. A distributed database includes: At least two distributed storage nodes, and each storage node includes a data storage engine and the data query engine described in claim 15.
17. A plan scheduling device for a distributed database includes: At least one processor, A memory coupled to the at least one processor, and A computer program stored in the memory, and the at least one processor executes the computer program to implement the method described in any one of claims 1 to 6.
18. A data query engine for a distributed database includes: At least one processor, A memory coupled to the at least one processor, and A computer program stored in the memory, and the at least one processor executes the computer program to implement the method described in claim 7.
19. A computer - readable storage medium stores executable instructions, and when the instructions are executed, the processor executes the method described in any one of claims 1 to 6 or executes the method described in claim 7.
20. A computer program product includes a computer program, and the computer program is executed by a processor to implement the method described in any one of claims 1 to 6 or execute the method described in claim 7.
Citation Information
Patent Citations
Parallelism determination method and device and equipment and storage medium
CN112035523A