Query execution method, device, electronic device and computer readable medium

By converting and pushing down the subqueries in the distributed database, the problem of the subqueries being difficult to push down to the sub-node execution is solved, and the overall computing power of the distributed database is utilized, reducing the pressure on the execution server.

CN112395303BActive Publication Date: 2024-12-03ALIBABA CLOUD COMPUTING CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN201910754045.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2019-08-15
Publication Date
2024-12-03
Estimated Expiration
2039-08-15

AI Technical Summary

Technical Problem

In distributed relational databases and KV databases, subqueries are difficult to push to sub-nodes to execute, resulting in the inability to fully utilize distributed computing power, increasing the computing pressure of executing the server.

Method used

By converting the subquery in the received SQL request, a relational algebraic expression is generated, and the part that can be pushed down to the execution of the child node of the distributed database is determined, and SQL instructions are generated to instruct the execution of the child node to realize the subquery push down execution.

Benefits of technology

Effectively push the subquery to the child nodes of the distributed database for execution, using the overall computing power to slow down the computing pressure of the execution server.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112395303B_ABST
    Figure CN112395303B_ABST
Patent Text Reader

Abstract

The embodiments of the present application provide a query execution method, device, electronic device and computer-readable medium, which relate to the field of databases. The method includes: converting a subquery in a received SQL request to obtain a relational algebraic expression corresponding to the subquery; determining the part of the relational algebraic expression that can be pushed down to the child node in the distributed database for execution; converting the part of the relational algebraic expression that can be pushed down to the child node in the distributed database for execution to obtain an SQL instruction for instructing the child node to execute the relevant operation of the subquery. The embodiments of the present application effectively combine the subnodes of the distributed database to execute the subquery by pushing the subquery down to the child node in the distributed database for execution, so as to fully utilize the overall computing power of the distributed database to effectively reduce the computing pressure of the execution server in the distributed database system.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the field of databases, and in particular, to a query execution method, device, electronic device, and computer-readable medium. Background Art

[0002] A subquery is a program module that is nested in a common computer language. When a query is a condition of another query, it is called a subquery. As a SQL (Structured Query Language) structure syntax that is easy to understand and build, the proportion of subqueries in SQL statements processed by distributed databases is currently on the rise.

[0003] In a distributed relational database, subqueries are non-standard relational algebra operators. If the distributed data structure is effectively combined to process the subqueries, the overall computing power of the distributed relational database can be fully utilized, thereby effectively alleviating the computing pressure of the execution server in the distributed relational database system. However, effectively combining distributed data structures to process subqueries has always been a difficult point in the research and development of distributed relational databases. Specifically, in a distributed relational database, the calculation process of the subquery is difficult to push down to the child nodes in the distributed relational database for execution.

[0004] In a distributed KV (Key-Value) database, a distributed database is constructed based on a KV structure. Since the database cannot provide good relational API (Application Programming Interface) semantics, the calculation process of the subquery is also difficult to push down to the child nodes in the distributed KV database for execution. In this way, the overall computing power of the distributed KV database cannot be fully utilized to effectively reduce the computing pressure of the execution server in the distributed relational database system.

[0005] Therefore, how to push subqueries down to subnodes in a distributed database for execution has become a technical problem that needs to be solved urgently. Summary of the invention

[0006] The purpose of the present application is to propose a query execution method, device, electronic device and computer-readable medium, which are used to solve the problem of how to push down a subquery to a subnode in a distributed database for execution in the prior art.

[0007] According to a first aspect of an embodiment of the present application, a query execution method is provided. The method comprises: converting a subquery in a received SQL request to obtain a relational algebraic expression corresponding to the subquery; determining a portion of the relational algebraic expression that can be pushed down to a child node in a distributed database for execution; converting a portion of the relational algebraic expression that can be pushed down to a child node in a distributed database for execution to obtain an SQL instruction for instructing the child node to execute a related operation of the subquery.

[0008] According to a second aspect of an embodiment of the present application, a query execution device is provided. The device comprises: a first conversion module, configured to convert a subquery in a received SQL request to obtain a relational algebraic expression corresponding to the subquery; a first determination module, configured to determine a portion of the relational algebraic expression that can be pushed down to a child node in a distributed database for execution; and a second conversion module, configured to convert a portion of the relational algebraic expression that can be pushed down to a child node in a distributed database for execution to obtain a SQL instruction for instructing the child node to execute a related operation of the subquery.

[0009] According to a third aspect of an embodiment of the present application, an electronic device is provided, comprising: one or more processors; and a computer-readable medium configured to store one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the query execution method as described in the first aspect of the above embodiment.

[0010] According to a fourth aspect of an embodiment of the present application, a computer-readable medium is provided, on which a computer program is stored. When the program is executed by a processor, the query execution method described in the first aspect of the above embodiment is implemented.

[0011] According to the technical solution provided in the embodiment of the present application, the subquery in the received SQL request is converted to obtain the relational algebraic expression corresponding to the subquery, and the part of the relational algebraic expression that can be pushed down to the child node in the distributed database for execution is determined, and then the part of the relational algebraic expression that can be pushed down to the child node in the distributed database for execution is converted to obtain an SQL instruction for instructing the child node to execute related operations of the subquery. Compared with other existing methods, by determining the part of the relational algebraic expression corresponding to the subquery that can be pushed down to the child node in the distributed database for execution, and converting the part of the relational algebraic expression that can be pushed down to the child node in the distributed database for execution, the subquery can be pushed down to the child node in the distributed database for execution, effectively combining the child nodes of the distributed database to execute the subquery, so that the overall computing power of the distributed database can be fully utilized to effectively alleviate the computing pressure of the execution server in the distributed database system. BRIEF DESCRIPTION OF THE DRAWINGS

[0012] Other features, objects and advantages of the present application will become more apparent by reading the detailed description of non-limiting embodiments made with reference to the following drawings:

[0013] Figure 1 A flowchart of the steps of the query execution method in the first embodiment of the present application;

[0014] Figure 2A A flowchart of the steps of the query execution method in the second embodiment of the present application;

[0015] Figure 2B A schematic diagram of the query execution process provided according to the second embodiment of the present application;

[0016] Figure 3 This is a schematic diagram of the structure of the execution device of the query in the third embodiment of the present application;

[0017] Figure 4 A schematic diagram of the structure of the execution device for query in the fourth embodiment of the present application;

[0018] Figure 5 A schematic diagram of the structure of the execution device for query in Embodiment 5 of the present application;

[0019] Figure 6 This is a schematic diagram of the structure of the distributed database system in Embodiment 6 of the present application;

[0020] Figure 7 This is a schematic diagram of the structure of an electronic device in Embodiment 7 of the present application;

[0021] Figure 8 This is the hardware structure of the electronic device in Example 8 of the present application. DETAILED DESCRIPTION

[0022] The present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It is to be understood that the specific embodiments described herein are only configured to explain the relevant invention, rather than to limit the invention. It is also necessary to explain that, for ease of description, only the parts related to the relevant invention are shown in the accompanying drawings.

[0023] It should be noted that, in the absence of conflict, the embodiments and features in the embodiments of the present application can be combined with each other. The present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.

[0024] Reference Figure 1 , showing a step flow chart of the query execution method of the first embodiment of the present application.

[0025] Specifically, the query execution method of this embodiment includes the following steps:

[0026] In step S101, a subquery in a received SQL request is converted to obtain a relational algebra expression corresponding to the subquery.

[0027] In an embodiment of the present application, the SQL request may be an SQL request sent by a user through a client to a subquery parser in an execution server of a distributed database system. The client includes a MySQL client or other applications. A subquery is a program module of a nested query layer in a commonly used computer language SELECT-SQL language. When a query A is a condition of another query B, it is called a subquery, such as query A is a subquery. A relational algebra expression can be understood as an expression formed by a finite number of compound relational algebra operations. The result of such an expression is still a relation. A relational algebra expression can be used to represent query and update operations on a database. It can be understood that the above description is only exemplary and the embodiments of the present application do not impose any limitation on this.

[0028] In some optional embodiments, when converting a subquery in a received SQL request, based on the type of the subquery, the subquery is converted to obtain a connection operator between relations in the relational algebra expression and a connection condition of the connection operator; based on the connection operator and the connection condition, a relational algebra expression corresponding to the subquery is generated. In this way, the subquery can be semantically understood based on the relational algebra expression corresponding to the subquery. It can be understood that the above description is only exemplary and the embodiments of the present application do not limit this in any way.

[0029] In a specific example, the relationship can be understood as a data table in the database field. The connection operator can be understood as a symbol representing the connection operation between relations in relational algebra. The connection operator can include a Semijoin operator, an Antisemijoin operator, a Left Join with max1row operator, and an Inner Join with max1row operator. The types of subqueries include IN subqueries, EXISTS subqueries, ANY subqueries, NOT IN subqueries, NOTEXISTS subqueries, ALL subqueries, and scalar subqueries. Specifically, the corresponding tables of various types of subqueries converted to connection operators are as follows:

[0030] Types of subqueries Connection Operator IN / EXISTS / ANY Semijoin NOT IN / NOT EXISTS / ALL Antisemijoin Scalar subquery in project Left Join with max1row Scalar subquery in filter Inner Join with max1row

[0031] Subqueries of the IN / EXISTS / ANY type can be converted to Semijoin operators. Semijoin is used to return records from one table after a matching record is found in another table. The operands of IN and ANY subqueries will be converted into join conditions together with the associated items, while EXISTS subqueries will only convert the associated items into join conditions. For example, the subquery "select * from t1as a where a.id in(select id from t2 where a.name=name)" can be converted into "semijoin(a.id=t2.id and a.name=t2.name)", where "id" is the operand, "name" is the associated item, and "(a.id=t2.id and a.name=t2.name)" is the join condition.

[0032] Subqueries of the NOT IN / NOT EXISTS / ALL type can be converted to Antisemijoin operators. Anti-semi-join operators are used to return mismatched data when performing incomplete join queries on rows returned from one table and data rows in another table. The operands of NOT IN subqueries will be converted into join conditions together with the associated items, the NOT EXISTS subquery will only convert the associated items into join conditions, and the operands of ALL subqueries will be converted into join conditions together with the associated items, and the operators will be reversed. The conversion relationship is shown in the operator reversal table shown below:

[0033]

[0034] For example, the subquery "select * from t1 as a where a.id>all(select id from t2where a.name=name)" can be converted to "antisemijoin(a.id<=t2.id and a.name=t2.name)", and the operator is reversed from ">" to "<=".

[0035] If the subquery is of scalar type, an inner join operator or a left join operator is used in combination with a semantic operator to obtain the join operator, and the associated items of the subquery of the scalar type are converted into the join condition, wherein the semantic operator is used to express the error semantics when the return result of the scalar subquery exceeds one row. Specifically, scalar subqueries include Scalar subquery in project subqueries and Scalar subquery in filter subqueries. When the subquery is of Scalar subquery in project subquery, a left join operator is used in combination with a semantic operator to obtain the join operator, for example, "Left Join with max1row". When the subquery is of Scalarsubquery in filter subquery, an inner join operator is used in combination with a semantic operator to obtain the join operator, for example, "Inner Join with max1row". Among them, "max1row" is a semantic operator. Through the above method, the subquery is converted into a join operator, and the associated items are extracted as join conditions, ready for push-down judgment. It should be understood that the above description is merely exemplary and the embodiments of the present application do not impose any limitation thereto.

[0036] In step S102, the part of the relational algebra expression that can be pushed down to the child nodes in the distributed database for execution is determined.

[0037] In the embodiment of the present application, the subnode can be understood as a server loaded with a MySQL database or any other database that can recognize or support the subquery semantics of standard SQL. It can be understood that the above description is only exemplary and the embodiment of the present application does not make any limitation to this.

[0038] In some optional embodiments, when determining the part of the relational algebra expression that can be pushed down to the child node in the distributed database for execution, if it is determined that the split data structures of the relations on both sides of the connection operator in the relational algebra expression are consistent, the connection condition of the connection operator is converted into a conjunction logic expression; it is cyclically determined whether each sub-item in the conjunction logic expression is an equivalent condition, and whether the operand of the equal sign of each sub-item is the column name of the relation; if the collection of all equivalent conditions in the conjunction logic expression covers the split column of the relation, it is determined that the relational algebra expression is a part that can be pushed down to the child node in the distributed database for execution. Thus, by combining the split data structure of the table in the subquery and decomposing the relationship between the tables in the subquery, it is possible to determine the part that can be pushed down to the child node in the distributed database for execution. It can be understood that the above description is only exemplary, and the embodiments of the present application do not make any limitation to this.

[0039] In a specific example, the split data structure of the relationship can be understood as the number and attributes of the split columns of the data table. If it is determined that the split data structures of the relationships on both sides of the connection operator in the relational algebraic expression are inconsistent, or the collection of all equivalent conditions in the conjunction logic expression does not cover the split columns of the relationship, then it is determined that the relational algebraic expression cannot be pushed down to the child nodes in the distributed database for execution. It can be understood that the above description is only exemplary and the embodiments of the present application do not impose any limitation on this.

[0040] In a specific example, the subquery "select * from t1 as a where a.id in (select id from t2 where a.name = name)" can be converted to "semijoin (a.id = t2.id and a.name = t2.name)". The split columns of the t1 table are the id column and the name column, and the split columns of the t2 table are also the id column and the name column. The attributes of the split columns of the two tables are the same, both representing the identifier and the name. Therefore, the split data structure of the t1 table and the t2 table is the same. "a.id = t2.id" and "a.name = t2.name" can be sub-items in the converted conjunction logic expression. These two sub-items are both equal conditions, and the operands of the equal signs of the two sub-items are both the column names of the relation. In addition, the collection of all equal conditions in the conjunction logic expression covers the split columns of tables t1 and t2. Among them, the truth value form p∧q is called "conjunctive logic expression", read as "p conjunction q" or "p and q", and p and q are both conjunctive branches of p∧q. The meaning of the conjunction "∧" is: when all the conjunctive branches of the conjunctive logic expression are true, the conjunctive logic expression is true; as long as one of the conjunctive branches is false, the conjunctive logic expression is false. It can be determined that the relational algebra expression "semijoin(a.id=t2.id and a.name=t2.name)" can be pushed down to the child nodes in the distributed database for execution. It can be understood that the above description is only exemplary, and the embodiments of the present application do not impose any limitation on this.

[0041] In some optional embodiments, after determining the part of the relational algebra expression that can be pushed down to the child node in the distributed database for execution, the method further includes: determining the execution cost of the part of the relational algebra expression that can be pushed down to the child node in the distributed database for execution; based on the execution cost, determining the part of the relational algebra expression to be pushed down to the child node in the distributed database for execution. In this way, the part of the relational algebra expression that is executed by the child node can be reasonably pushed down. It can be understood that the above description is only exemplary and the embodiments of the present application do not make any limitation to this.

[0042] In a specific example, the CBO (Cost-Based Optimization) optimizer in the execution server of the distributed database can be used to determine the execution cost of the part of the relational algebra expression that can be pushed down to the child node in the distributed database for execution, and based on the execution cost, determine the part of the relational algebra expression to be pushed down to the child node in the distributed database for execution. It can be understood that the above description is only exemplary and the embodiments of the present application do not impose any limitation on this.

[0043] In step S103, the part of the relational algebra expression that can be pushed down to the child node in the distributed database for execution is converted to obtain an SQL instruction for instructing the child node to execute the relevant operation of the subquery.

[0044] In some optional embodiments, when converting the part of the relational algebra expression that can be pushed down to the child node in the distributed database for execution, the execution plan of the part of the relational algebra expression that can be pushed down to the child node in the distributed database for execution is converted to obtain an abstract syntax tree corresponding to the execution plan; the abstract syntax tree is traversed to generate a hierarchical namespace and connection relationship; based on the hierarchical namespace and connection relationship, SQL instructions for instructing the child node to execute the relevant operation of the subquery are generated layer by layer from bottom to top. Thus, by converting the part of the relational algebra expression that can be pushed down to the child node in the distributed database for execution into an SQL instruction for instructing the child node to execute the relevant operation of the subquery, the push-down execution plan of the subquery can be described using the SQL protocol, and the push-down execution plan of the subquery can be expressed to the child node of the distributed database using the SQL protocol. It can be understood that the above description is only exemplary, and the embodiments of the present application do not make any limitation to this.

[0045] In a specific example, the abstract syntax tree can be understood as an abstract representation of the syntax structure of the source code. It represents the syntax structure of the programming language in a tree-like form, and each node on the tree represents a structure in the source code. The namespace can be understood as a form of code organization used by various languages, which is classified by namespace to distinguish different code functions. It can be understood that the above description is only exemplary and the embodiments of the present application do not make any limitation to this.

[0046] In a specific example, after the CBO optimizer in the execution server of the distributed database determines the part of the relational algebra expression to be pushed down to the child node in the distributed database for execution, the part of the relational algebra expression to be pushed down to the child node in the distributed database for execution can be converted to obtain an SQL instruction for instructing the child node to perform the relevant operation of the subquery. The specific conversion process is similar to the above conversion process and will not be repeated here. It can be understood that the above description is only exemplary and the embodiments of the present application do not limit this in any way.

[0047] By using the query execution method provided in the embodiment of the present application, the subquery in the received SQL request is converted to obtain the relational algebraic expression corresponding to the subquery, and the part of the relational algebraic expression that can be pushed down to the child node in the distributed database for execution is determined, and then the part of the relational algebraic expression that can be pushed down to the child node in the distributed database for execution is converted to obtain an SQL instruction for instructing the child node to execute related operations of the subquery. Compared with other existing methods, by determining the part of the relational algebraic expression corresponding to the subquery that can be pushed down to the child node in the distributed database for execution, and converting the part of the relational algebraic expression that can be pushed down to the child node in the distributed database for execution, the subquery can be pushed down to the child node in the distributed database for execution, effectively combining the child nodes of the distributed database to execute the subquery, so as to fully utilize the overall computing power of the distributed database, so as to effectively alleviate the computing pressure of the execution server in the distributed database system.

[0048] The query execution method of this embodiment can be executed by any appropriate device with data processing capabilities, including but not limited to: cameras, terminals, mobile terminals, PCs, servers, vehicle-mounted devices, entertainment equipment, advertising equipment, personal digital assistants (PDAs), tablet computers, laptop computers, handheld game consoles, smart glasses, smart watches, wearable devices, virtual display devices or display enhancement devices (such as Google Glass, Oculus Rift, Hololens, Gear VR), etc.

[0049] Reference Figure 2A , showing a step flow chart of the query execution method of the second embodiment of the present application.

[0050] Specifically, the query execution method of this embodiment includes the following steps:

[0051] In step S201, the subquery in the received SQL request is converted to obtain a relational algebra expression corresponding to the subquery.

[0052] Since step S201 is similar to step S101 described above, it will not be described again here.

[0053] In step S202, the part of the relational algebra expression that can be pushed down to the child nodes in the distributed database for execution is determined.

[0054] Since step S202 is similar to step S102 described above, it will not be described again here.

[0055] In step S203, the part of the relational algebra expression that can be pushed down to the child node in the distributed database for execution is converted to obtain an SQL instruction for instructing the child node to execute the relevant operation of the subquery.

[0056] Since step S203 is similar to step S103 described above, it will not be described again here.

[0057] In step S204, the execution result of the SQL instruction returned by the child node is received.

[0058] In the embodiment of the present application, the executor in the execution server of the distributed database system receives the execution results of the SQL instructions returned by each child node. It can be understood that the above description is only exemplary and the embodiment of the present application does not make any limitation to this.

[0059] In step S205, based on the overall execution plan of the subquery, the execution result returned by the sub-node is processed to obtain a result set for the SQL request.

[0060] In the embodiment of the present application, the overall execution plan can be understood as the execution plan represented by the relational algebra expression corresponding to the subquery. Based on the overall execution plan of the subquery, the execution results returned by the child nodes can be clustered or merged to obtain a result set for the SQL request. It can be understood that the above description is only exemplary and the embodiment of the present application does not impose any limitation on this.

[0061] In step S206, a result set for the SQL request is returned to the client.

[0062] In the embodiment of the present application, the execution server in the distributed database system returns the result set for the SQL request to the client. It can be understood that the above description is only exemplary and the embodiment of the present application does not make any limitation to this.

[0063] In a specific example, Figure 2BAs shown, the distributed database system includes a client, an execution server connected to the client, and each sub-node connected to the execution server, for example, sub-nodes MySQL A, MySQL B, etc. The execution server includes a sub-query parser connected to the client, a CBO optimizer connected to the sub-query parser, and an executor connected to the CBO optimizer. The overall execution process of the sub-query is as follows: the user sends an SQL request to the sub-query parser through the client. The sub-query parser parses the received sub-query to obtain the semi-join operator and the connection condition of the semi-join operator in the relational algebraic expression corresponding to the sub-query, and generates the relational algebraic expression corresponding to the sub-query based on the semi-join operator and the connection condition of the semi-join operator, and then passes the converted execution plan (relational algebraic expression) to the CBO optimizer. The CBO optimizer determines the execution plan that can be pushed down according to the connection condition, and then determines the execution plan to be pushed down according to the execution cost of the execution plan that can be pushed down. After determining the execution plan to be pushed down, the CBO optimizer passes the overall execution plan of the sub-query (including the execution plan to be pushed down and the execution plan not pushed down) to the executor for execution. The executor converts the execution plan of the part to be pushed down into SQL instructions and sends them to the MySQL database of the child node for execution. The MySQL databases of each child node in the distributed database system execute the received SQL instructions in parallel and feed back the execution results to the executor. The executor processes the execution results returned by the child node according to the overall execution plan, obtains the result set for the SQL request, and feeds back the result set to the user's client. Among them, the upper-level processing in the figure can be understood as the processing performed by the executor on the execution results returned by the child node according to the overall execution plan. It can be understood that the above description is only exemplary and the embodiments of the present application do not impose any limitations on this.

[0064] On the basis of Example 1 of the present application, the execution result for the SQL instruction returned by the child node is received, and based on the overall execution plan of the subquery, the execution result returned by the child node is processed to obtain a result set for the SQL request, and then the result set for the SQL request is returned to the client. Compared with other existing methods, based on the overall execution plan of the subquery, the execution result for the SQL instruction returned by the child node is processed to obtain a result set for the SQL request, and the result set for the SQL request is returned to the client, and a set of execution results of the child node for the subquery can be returned to the client.

[0065] The query execution method of this embodiment can be executed by any appropriate device with data processing capabilities, including but not limited to: cameras, terminals, mobile terminals, PCs, servers, vehicle-mounted devices, entertainment equipment, advertising equipment, personal digital assistants (PDAs), tablet computers, laptop computers, handheld game consoles, smart glasses, smart watches, wearable devices, virtual display devices or display enhancement devices (such as Google Glass, Oculus Rift, Hololens, Gear VR), etc.

[0066] Reference Figure 3 , showing a schematic diagram of the structure of the query execution device in Example 3 of the present application.

[0067] The query execution device of this embodiment includes: a first conversion module 301, which is used to convert the subquery in the received SQL request to obtain the relational algebraic expression corresponding to the subquery; a first determination module 302, which is used to determine the part of the relational algebraic expression that can be pushed down to the child node in the distributed database for execution; a second conversion module 303, which is used to convert the part of the relational algebraic expression that can be pushed down to the child node in the distributed database for execution to obtain an SQL instruction for instructing the child node to execute the relevant operation of the subquery.

[0068] The query execution device of this embodiment is used to implement the corresponding query execution methods in the aforementioned multiple method embodiments, and has the beneficial effects of the corresponding method embodiments, which will not be described in detail here.

[0069] Reference Figure 4 , showing a schematic diagram of the structure of the query execution device in Example 4 of the present application.

[0070] The query execution device of this embodiment includes: a first conversion module 401, which is used to convert the subquery in the received SQL request to obtain the relational algebraic expression corresponding to the subquery; a first determination module 402, which is used to determine the part of the relational algebraic expression that can be pushed down to the child node in the distributed database for execution; a second conversion module 405, which is used to convert the part of the relational algebraic expression that can be pushed down to the child node in the distributed database for execution to obtain an SQL instruction for instructing the child node to execute the relevant operation of the subquery.

[0071] Optionally, the first conversion module 401 includes: an acquisition module 4011, which is used to convert the subquery based on the type of the subquery to obtain the connection operator between the relations in the relational algebraic expression and the connection condition of the connection operator; a generation module 4012, which is used to generate a relational algebraic expression corresponding to the subquery based on the connection operator and the connection condition.

[0072] Optionally, the acquisition module 4011 is specifically used to: if the type of the subquery is a scalar type, use an inner join operator or a left join operator in conjunction with a semantic operator to obtain the join operator, and convert the associated items of the scalar type subquery into the join condition, wherein the semantic operator is used to express the error semantics when the return result of the scalar subquery exceeds one row.

[0073] Optionally, the first determination module 402 is specifically used to: if it is determined that the split data structures of the relations on both sides of the connection operator in the relational algebraic expression are consistent, then convert the connection condition of the connection operator into a conjunction logic expression; loop to determine whether each sub-item in the conjunction logic expression is an equivalent condition, and whether the operand of the equal sign of each sub-item is the column name of the relation; if the collection of all equivalent conditions in the conjunction logic expression covers the split column of the relation, then determine that the relational algebraic expression is a part that can be pushed down to the child node in the distributed database for execution.

[0074] Optionally, the device also includes: a second determination module 403, used to determine the execution cost of the part of the relational algebra expression that can be pushed down to the child nodes in the distributed database for execution after the first determination module 402 determines the part that can be pushed down to the child nodes in the distributed database for execution; a third determination module 404, used to determine the part of the relational algebra expression to be pushed down to the child nodes in the distributed database for execution based on the execution cost.

[0075] The query execution device of this embodiment is used to implement the corresponding query execution methods in the aforementioned multiple method embodiments, and has the beneficial effects of the corresponding method embodiments, which will not be described in detail here.

[0076] Reference Figure 5 , showing a schematic diagram of the structure of the query execution device in Example 5 of the present application.

[0077] The query execution device of this embodiment includes: a first conversion module 501, which is used to convert the subquery in the received SQL request to obtain the relational algebraic expression corresponding to the subquery; a first determination module 502, which is used to determine the part of the relational algebraic expression that can be pushed down to the child node in the distributed database for execution; a second conversion module 503, which is used to convert the part of the relational algebraic expression that can be pushed down to the child node in the distributed database for execution to obtain an SQL instruction for instructing the child node to execute the relevant operation of the subquery.

[0078] Optionally, the second conversion module 503 is specifically used to: convert the execution plan of the part of the relational algebra expression that can be pushed down to the child node in the distributed database to obtain an abstract syntax tree corresponding to the execution plan; traverse the abstract syntax tree to generate a hierarchical namespace and connection relationship; based on the hierarchical namespace and connection relationship, generate SQL instructions for instructing the child node to execute related operations of the subquery from bottom to top layer by layer.

[0079] Optionally, the device also includes: a receiving module 504, which is used to receive the execution result of the SQL instruction returned by the child node after the second conversion module 503 converts the part of the relational algebra expression that can be pushed down to the child node in the distributed database; a processing module 505, which is used to process the execution result returned by the child node based on the overall execution plan of the subquery to obtain a result set for the SQL request; and a returning module 506, which is used to return the result set for the SQL request to the client.

[0080] The query execution device of this embodiment is used to implement the corresponding query execution methods in the aforementioned multiple method embodiments, and has the beneficial effects of the corresponding method embodiments, which will not be described in detail here.

[0081] Reference Figure 6 , showing a schematic diagram of the structure of the distributed database system in Example 6 of the present application.

[0082] The distributed database system provided in this embodiment includes: a client, an execution server connected to the client, and a subnode connected to the execution server; the client is used to send an SQL request to the execution server in response to a user operation; the execution server is used to convert the subquery in the received SQL request to obtain a relational algebraic expression corresponding to the subquery; determine the part of the relational algebraic expression that can be pushed down to the subnode in the distributed database for execution; convert the part of the relational algebraic expression that can be pushed down to the subnode in the distributed database for execution to obtain an SQL instruction for instructing the subnode to execute the relevant operation of the subquery; the subnode is used to execute the relevant operation of the subquery based on the SQL instruction. Wherein, the subnode is a subnode of the distributed database.

[0083] In a specific example, the number of sub-nodes of the distributed database is multiple, and the execution server is connected to the sub-nodes of multiple distributed databases. In addition, each sub-node of the distributed database has a corresponding storage disk. The storage disk can store the logical table of the database, such as a sub-table, a single table, or a broadcast table, etc. Among them, the sub-table can be understood as a data table split by a splitting rule. The single table can be understood as a data table that is not split by a splitting rule and is stored in the storage disk of the main node of the distributed database. The broadcast table can be understood as a data table that is not split by a splitting rule and is distributed and stored on the storage disk of the distributed database node. It can be understood that the above description is only exemplary, and the embodiments of the present application do not impose any limitation on this.

[0084] The distributed database system of this embodiment is used to implement the corresponding query execution methods in the aforementioned multiple method embodiments, and has the beneficial effects of the corresponding method embodiments, which will not be described in detail here.

[0085] Figure 7 This is a schematic diagram of the structure of an electronic device in Embodiment 6 of the present application; the electronic device may include:

[0086] One or more processors 601;

[0087] The computer readable medium 602 may be configured to store one or more programs,

[0088] When the one or more programs are executed by the one or more processors, the one or more processors implement the query execution method as described in the above-mentioned embodiment 1 or embodiment 2.

[0089] Figure 8 The hardware structure of the electronic device in the seventh embodiment of the present application; Figure 8 As shown, the hardware structure of the electronic device may include: a processor 701, a communication interface 702, a computer readable medium 703 and a communication bus 704;

[0090] The processor 701, the communication interface 702, and the computer readable medium 703 communicate with each other via a communication bus 704;

[0091] Optionally, the communication interface 702 may be an interface of a communication module, such as an interface of a GSM module;

[0092] Among them, the processor 701 can be specifically configured to: convert the subquery in the received SQL request to obtain the relational algebraic expression corresponding to the subquery; determine the part of the relational algebraic expression that can be pushed down to the child node in the distributed database for execution; convert the part of the relational algebraic expression that can be pushed down to the child node in the distributed database for execution to obtain an SQL instruction for instructing the child node to execute related operations of the subquery.

[0093] The processor 701 may be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it may also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present application may be implemented or executed. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.

[0094] The computer readable medium 703 can be, but is not limited to, a random access memory medium (RAM), a read-only memory medium (ROM), a programmable read-only memory medium (PROM), an erasable programmable read-only memory medium (EPROM), an electrically erasable read-only memory medium (Electric Erasable Programmable Read-Only Memory, EEPROM), etc.

[0095] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code configured to execute the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through a communication part, and / or installed from a removable medium. When the computer program is executed by a central processing unit (CPU), the above functions defined in the method of the present application are executed. It should be noted that the computer-readable medium described in the present application can be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable medium can be, for example, but not limited to, a system, device or device of electricity, magnetism, light, electromagnetic, infrared, or semiconductor, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to, an electrical connection with one or more conductors, a portable computer disk, a hard disk, a random access storage medium (RAM), a read-only storage medium (ROM), an erasable programmable read-only storage medium (EPROM or flash memory), an optical fiber, a portable compact disk read-only storage medium (CD-ROM), an optical storage medium, a magnetic storage medium, or any suitable combination of the above. In the present application, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, an apparatus or a device. In the present application, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a computer-readable program code is carried. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate, or transmit a program configured to be used by or in combination with an instruction execution system, an apparatus or a device. The program code embodied on the computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.

[0096] Computer program code configured to perform the operations of the present application may 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 may 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 may 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 may be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0097] The flowchart and block diagram in the accompanying drawings illustrate the possible architecture, functions and operations of the system, method and computer program product according to various embodiments of the present application. In this regard, each box in the flowchart or block diagram can represent a module, a program segment, or a part of a code, and the module, program segment, or a part of the code contains one or more executable instructions configured to implement the specified logical function. There are specific sequential relationships in the above-mentioned specific embodiments, but these sequential relationships are only exemplary. When the specific implementation is implemented, these steps may be less, more, or the execution order may be adjusted. That is, in some implementations as replacements, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of boxes in the block diagram and / or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0098] The modules involved in the embodiments of the present application may be implemented in software or hardware. The modules described may also be set in a processor, for example, may be described as: a processor includes a first conversion module, a first determination module, and a second conversion module. The names of these modules do not constitute a limitation on the modules themselves in some cases. For example, the first conversion module may also be described as "a module for converting a subquery in a received SQL request to obtain a relational algebra expression corresponding to the subquery".

[0099] As another aspect, the present application further provides a computer-readable medium on which a computer program is stored. When the program is executed by a processor, the query execution method described in the above-mentioned embodiment 1 or embodiment 2 is implemented.

[0100] As another aspect, the present application also provides a computer-readable medium, which may be included in the device described in the above embodiment; or may exist independently without being assembled into the device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by the device, the device: converts the subquery in the received SQL request to obtain the relational algebraic expression corresponding to the subquery; determines the part of the relational algebraic expression that can be pushed down to the child node in the distributed database for execution; converts the part of the relational algebraic expression that can be pushed down to the child node in the distributed database for execution to obtain the SQL instruction for instructing the child node to execute the relevant operation of the subquery.

[0101] The expressions "first", "second", "the first" or "the second" used in various embodiments of the present disclosure may modify various components regardless of order and / or importance, but these expressions do not limit the corresponding components. The above expressions are only configured for the purpose of distinguishing an element from other elements. For example, a first user device and a second user device represent different user devices, although both are user devices. For example, a first element may be referred to as a second element, and similarly, a second element may be referred to as a first element without departing from the scope of the present disclosure.

[0102] When one element (e.g., a first element) is referred to as being "(operably or communicatively) coupled" or "(operably or communicatively) coupled to" or "connected to" another element (e.g., a second element), it is understood that the one element is directly connected to the other element or the one element is indirectly connected to the other element via yet another element (e.g., a third element). Conversely, it is understood that when an element (e.g., a first element) is referred to as being "directly connected" or "directly coupled" to another element (the second element), no element (e.g., a third element) is interposed between the two.

[0103] The above description is only a preferred embodiment of the present application and an explanation of the technical principles used. Those skilled in the art should understand that the scope of the invention involved in the present application is not limited to the technical solution formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above invention concept. For example, the above features are replaced with the technical features with similar functions disclosed in this application (but not limited to) by each other to form a technical solution.

Claims

1. A query execution method, characterized in that: The method comprises: Converting a subquery in a received SQL request to obtain a relational algebra expression corresponding to the subquery; Determining a portion of the relational algebra expression that can be pushed down to a child node in a distributed database for execution; Converting the part of the relational algebra expression that can be pushed down to the child node in the distributed database to obtain an SQL instruction for instructing the child node to execute the related operation of the subquery; The determining of the part of the relational algebra expression that can be pushed down to the child node in the distributed database for execution comprises: If it is determined that the split data structures of the relations on both sides of the connection operator in the relational algebra expression are consistent, converting the connection condition of the connection operator into a conjunction logic expression; Looping to determine whether each sub-item in the conjunction logic expression is an equal value condition, and whether the operand of the equal sign of each sub-item is a column name of the relation; If the collection of all equivalent conditions in the conjunction logic expression covers the split columns of the relation, it is determined that the relational algebra expression is a part that can be pushed down to a child node in a distributed database for execution.

2. The method according to claim 1, characterized in that: The converting the subquery in the received SQL request to obtain a relational algebra expression corresponding to the subquery includes: Based on the type of the subquery, the subquery is converted to obtain a connection operator between relations in the relational algebra expression and a connection condition of the connection operator; Based on the join operator and the join condition, a relational algebra expression corresponding to the subquery is generated.

3. The method according to claim 2, characterized in that The converting of the subquery based on the type of the subquery to obtain the connection operator between relations in the relational algebra expression and the connection condition of the connection operator includes: If the type of the subquery is a scalar type, an inner join operator or a left join operator is used in conjunction with a semantic operator to obtain the join operator, and the associated items of the scalar type subquery are converted into the join condition, wherein the semantic operator is used to express the error semantics when the return result of the scalar subquery exceeds one row.

4. The method according to claim 1, characterized in that: After determining the part of the relational algebra expression that can be pushed down to the child nodes in the distributed database for execution, the method further includes: Determining the execution cost of a portion of the relational algebra expression that can be pushed down to a child node in a distributed database for execution; Based on the execution cost, a portion of the relational algebra expression to be pushed down to a child node in a distributed database for execution is determined.

5. The method according to claim 1, characterized in that The converting the part of the relational algebra expression that can be pushed down to the child node in the distributed database to obtain an SQL instruction for instructing the child node to perform an operation includes: Converting the execution plan of the part of the relational algebra expression that can be pushed down to the child node in the distributed database for execution, so as to obtain an abstract syntax tree corresponding to the execution plan; Traversing the abstract syntax tree to generate hierarchical namespaces and connection relationships; Based on the hierarchical namespace and connection relationship, SQL instructions for instructing the sub-node to execute related operations of the sub-query are generated layer by layer from bottom to top.

6. The method according to any one of claims 1 to 5, characterized in that: After converting the part of the relational algebra expression that can be pushed down to the child nodes in the distributed database for execution, the method further includes: Receive the execution result of the SQL instruction returned by the child node; Based on the overall execution plan of the subquery, processing the execution result returned by the child node to obtain a result set for the SQL request; The result set for the SQL request is returned to the client.

7. A query execution device, characterized in that: The device comprises: A first conversion module, configured to convert a subquery in a received SQL request to obtain a relational algebra expression corresponding to the subquery; A first determination module, used to determine a portion of the relational algebra expression that can be pushed down to a child node in a distributed database for execution; A second conversion module is used to convert the part of the relational algebra expression that can be pushed down to the child node in the distributed database for execution, so as to obtain an SQL instruction for instructing the child node to execute the relevant operation of the subquery; The first determining module is specifically configured to: If it is determined that the split data structures of the relations on both sides of the connection operator in the relational algebra expression are consistent, converting the connection condition of the connection operator into a conjunction logic expression; Looping to determine whether each sub-item in the conjunction logic expression is an equal value condition, and whether the operand of the equal sign of each sub-item is a column name of the relation; If the collection of all equivalent conditions in the conjunction logic expression covers the split columns of the relation, it is determined that the relational algebra expression is a part that can be pushed down to a child node in a distributed database for execution.

8. The device according to claim 7, characterized in that The first conversion module includes: An acquisition module, used for converting the subquery based on the type of the subquery to obtain a connection operator between relations in the relational algebra expression and a connection condition of the connection operator; A generation module is used to generate a relational algebra expression corresponding to the subquery based on the connection operator and the connection condition.

9. The device according to claim 8, characterized in that The obtaining module is specifically used for: If the type of the subquery is a scalar type, an inner join operator or a left join operator is used in conjunction with a semantic operator to obtain the join operator, and the associated items of the scalar type subquery are converted into the join condition, wherein the semantic operator is used to express the error semantics when the return result of the scalar subquery exceeds one row.

10. The device according to claim 7, characterized in that The device also includes: A second determination module, configured to determine the execution cost of the part of the relational algebra expression that can be pushed down to the child node in the distributed database for execution after the first determination module determines the part that can be pushed down to the child node in the distributed database for execution; The third determination module is used to determine the part of the relational algebra expression to be pushed down to the child node in the distributed database for execution based on the execution cost.

11. The device according to claim 7, characterized in that The second conversion module is specifically used to: Converting the execution plan of the part of the relational algebra expression that can be pushed down to the child node in the distributed database for execution, so as to obtain an abstract syntax tree corresponding to the execution plan; Traversing the abstract syntax tree to generate hierarchical namespaces and connection relationships; Based on the hierarchical namespace and connection relationship, SQL instructions for instructing the sub-node to execute related operations of the sub-query are generated layer by layer from bottom to top.

12. The device according to any one of claims 7 to 11, characterized in that: The device also includes: A receiving module, configured to receive an execution result of the SQL instruction returned by the child node after the second conversion module converts the part of the relational algebra expression that can be pushed down to the child node in the distributed database for execution; A processing module, configured to process the execution result returned by the sub-node based on the overall execution plan of the sub-query to obtain a result set for the SQL request; The return module is used to return the result set for the SQL request to the client.

13. A distributed database system, characterized in that: The system comprises: A client, an execution server connected to the client, and a subnode connected to the execution server; The client is used to send an SQL request to the execution server in response to a user operation; The execution server is used to convert the subquery in the received SQL request to obtain the relational algebraic expression corresponding to the subquery; determine the part of the relational algebraic expression that can be pushed down to the child node in the distributed database for execution; convert the part of the relational algebraic expression that can be pushed down to the child node in the distributed database for execution to obtain the SQL instruction for instructing the child node to execute the relevant operation of the subquery; The sub-node is used to execute the related operations of the sub-query based on the SQL instruction; The execution server is specifically used to convert the connection condition of the connection operator into a conjunction logic expression if it is determined that the split data structures of the relations on both sides of the connection operator in the relational algebra expression are consistent; Looping to determine whether each sub-item in the conjunction logic expression is an equal value condition, and whether the operand of the equal sign of each sub-item is a column name of the relation; If the collection of all equivalent conditions in the conjunction logic expression covers the split columns of the relation, it is determined that the relational algebra expression is a part that can be pushed down to a child node in a distributed database for execution.

14. An electronic device comprising: one or more processors; A computer readable medium configured to store 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 query execution method as described in any one of claims 1 to 6.

15. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the query execution method according to any one of claims 1 to 6 is implemented.