SQL statement execution method, system, terminal and medium

By dividing SQL statements into two stages and using pipelines and multiplexing mechanisms, the problem of inefficiency of multi-threaded solutions in MPP distributed databases is solved, and performance improvement and resource optimization are achieved.

CN112579637BActive Publication Date: 2024-12-17深圳市汉云科技有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202011480506.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-12-15
Publication Date
2024-12-17
Estimated Expiration
2040-12-15

AI Technical Summary

Technical Problem

In the prior art, the multi-threading scheme of MPP distributed databases is expensive, and each executed SQL needs to open a thread, resulting in low efficiency.

Method used

By obtaining the SQL statement to be issued and several target connection objects, the SQL statement is divided into two stages to execute: the first stage sends the SQL statement to the target node and generates the sending result, the second stage gets the target message and generates the final execution result. Adopt pipeline and multiplexing mechanisms to avoid multithreading overhead and asynchronous programming complexity.

Benefits of technology

Improves the performance of SQL execution, reduces the overhead of multi-threading, simplifies concurrent processing, and improves system efficiency and resource utilization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112579637B_ABST
    Figure CN112579637B_ABST
Patent Text Reader

Abstract

The present invention provides a SQL statement execution method, system, terminal and medium. The method obtains a SQL statement to be sent and several target connection objects, sends the SQL statement to be sent to a target node through the target connection object, generates an SQL sending result, obtains a target message, and generates a final execution result. The execution of SQL is divided into two stages, thereby avoiding the overhead of multi-threading and the complexity of asynchronous programming. The problem that the tasks executed by each node of an MPP distributed database in the related technology are often heavy and require a long execution time can be solved. Therefore, if a synchronous blocking API is used for serial execution, the performance will be very low. For a distributed database multi-threading solution, the overhead is large, and each executed SQL needs to start a thread, which is inefficient. The method improves the performance, reduces the overhead of concurrent multi-threading, and is simple and convenient.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a SQL statement execution method, system, terminal and medium. Background Art

[0002] MPP distributed databases are usually implemented based on mature single databases, such as MYSQL. Since the client libraries provided by current single databases are all blocking synchronous APIs, the conventional concurrent execution solution is to use multiple threads to implement it, with each thread executing a SQL statement and then aggregating the results.

[0003] For multi-threaded solutions, the overhead is large, and each SQL executed needs to start a thread, which is inefficient. Summary of the invention

[0004] The main purpose of the present invention is to provide a SQL statement execution method, system, terminal and medium, aiming to solve the technical problem that the multi-threaded solution for distributed database in the related technology has high overhead and each executed SQL needs to start a thread, which is inefficient.

[0005] In order to solve the above technical problems, a SQL statement execution method is provided, comprising:

[0006] Get the SQL statement to be issued and several target connection objects;

[0007] Send the SQL statement to be sent to each target node through the target connection object, and generate an SQL sending result;

[0008] A target message is obtained, and a final execution result is generated, wherein the target message includes a task cancellation message or a node execution result of each target node.

[0009] Optionally, obtaining the target message and generating the final execution result includes any one of the following:

[0010] If the target message includes node execution results of each of the target nodes, a result set is generated according to the execution results of each of the nodes, and the final execution result includes the result set;

[0011] If the target message includes a task cancellation message, the final execution result includes task cancellation.

[0012] Optionally, the execution result of each node is obtained as follows:

[0013] Obtaining a node execution result of the target node;

[0014] If the target message is not currently obtained, continue to obtain the node execution result of the next target node until the node execution results of each target node are obtained.

[0015] Optionally, also include:

[0016] If the target message is currently acquired and the target message includes a task cancellation message, the acquisition of the node execution result of the next target node is stopped, and the final execution result includes task cancellation.

[0017] Optionally, the execution result of each node is obtained as follows:

[0018] Initialize a poll object and a pipeline respectively, and monitor the readable events of the pipeline through the poll object, wherein the readable events of the pipeline include writing the cancel task message;

[0019] Monitor the readable events of each target connection object through the poll object, and wait for the readable events of each target connection object through poll_wait, where the readable events of the target connection object include the node execution result of the target node;

[0020] Get a readable event of the target connection object;

[0021] If the pipe is not readable, a readable event of the next target connection object is obtained until all readable events of the target objects are obtained.

[0022] Optionally, if the pipeline is readable, the final execution result includes task cancellation.

[0023] Optionally, if the final execution result includes task cancellation, it also includes any one of the following:

[0024] Add the target connection object to the task cancellation queue;

[0025] The target connection object is added to a task cancellation queue, and the tasks of each target connection object in the task cancellation queue are terminated.

[0026] The present invention also provides a SQL statement execution system, comprising:

[0027] The acquisition module is used to obtain the SQL statement to be issued and several target connection objects;

[0028] A sending module, used to send the SQL statement to be sent to each target node through the target connection object, and generate an SQL sending result;

[0029] The generation module is used to obtain a target message and generate a final execution result, wherein the target message includes a task cancellation message or a node execution result of each target node.

[0030] The present invention also provides a terminal, comprising a processor, a memory and a communication bus;

[0031] The communication bus is used to connect the processor and the memory;

[0032] The processor is used to execute the computer program stored in the memory to implement the SQL statement execution method as described in any one of the above embodiments.

[0033] The present invention also provides a computer-readable storage medium having a computer program stored thereon.

[0034] The computer program is used to enable the computer to execute the SQL statement execution method as described in any one of the above embodiments.

[0035] As described above, the SQL statement execution method, system, terminal and medium provided by the present invention have the following beneficial effects:

[0036] By obtaining the SQL statement to be issued and several target connection objects, the SQL statement to be issued is sent to the target node through the target connection object, the SQL sending result is generated, the target message is obtained, and the final execution result is generated. The execution of SQL is divided into two stages, which avoids the overhead of multi-threading and the complexity of asynchronous programming. It can solve the problem in related technologies that the tasks executed by each node of the MPP distributed database are often heavy and require a long execution time. Therefore, if a synchronous blocking API is used for serial execution, the performance will be very low. For the distributed database multi-threading solution, the overhead is large, and each executed SQL needs to start a thread, which is inefficient. It improves performance and reduces the overhead of concurrent multi-threading. It is simple and convenient. BRIEF DESCRIPTION OF THE DRAWINGS

[0037] Figure 1 A flowchart of a method for executing a SQL statement provided in the first embodiment of the present invention;

[0038] Figure 2 A specific flow chart of the SQL statement execution method provided in the first embodiment of the present invention;

[0039] Figure 3 Another specific flow chart of the SQL statement execution method provided in the first embodiment of the present invention;

[0040] Figure 4 Another specific flow chart of the SQL statement execution method provided in the first embodiment of the present invention;

[0041] Figure 5 A schematic diagram of the structure of a SQL statement execution system provided in Embodiment 2 of the present invention;

[0042] Figure 6 A schematic diagram of the structure of a terminal provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0043] The following describes the embodiments of the present invention by specific examples, and those skilled in the art can easily understand other advantages and effects of the present invention from the contents disclosed in this specification. The present invention can also be implemented or applied through other different specific embodiments, and the details in this specification can also be modified or changed in various ways based on different viewpoints and applications without departing from the spirit of the present invention. It should be noted that the following embodiments and features in the embodiments can be combined with each other without conflict.

[0044] It should be noted that the illustrations provided in the following embodiments are only schematic illustrations of the basic concept of the present invention, and thus the drawings only show components related to the present invention rather than being drawn according to the number, shape and size of components in actual implementation. In actual implementation, the type, quantity and proportion of each component may be changed arbitrarily, and the component layout may also be more complicated.

[0045] Embodiment 1

[0046] See also Figure 1 , an embodiment of the present invention provides a SQL statement execution method, comprising:

[0047] S101: Obtain the SQL statement to be issued and several target connection objects.

[0048] Optionally, the method of obtaining the SQL (Structured Query Language) statement to be issued and the plurality of target connection objects may be implemented by using existing related technical means, which is not limited here.

[0049] Optionally, the target connection object may be obtained by obtaining a corresponding number of connection objects from a connection pool according to the number of nodes required to execute the SQL statement to be issued.

[0050] S102: Send the SQL statement to be sent to each target node through the target connection object, and generate an SQL sending result.

[0051] Optionally, after sending the SQL statement to be sent to each target node through the target connection object, the SQL sending result is generated. In other words, after the normal sending of the SQL statement to be sent to each target node is completed, the SQL sending result can be generated without waiting for each target node to return the node execution result.

[0052] Optionally, the SQL statement to be sent is sent to the target node, and the SQL statement to be sent is returned after it is successfully sent through the TCP (Transmission Control Protocol) network without waiting for the node to respond.

[0053] Optionally, a connection object list may be generated according to the target connection object, and it may be determined whether to generate an SQL sending result by traversing whether the SQL statement to be sent has been sent through each target connection object in the connection object list. If the traversal is completed, that is, the work of distributing the SQL statement to be sent through each target connection object is completed, then an SQL sending result is generated; otherwise, the SQL statement to be sent continues to be sent to the corresponding target node through the target connection object that has not yet completed the distribution work.

[0054] S103: Obtain the target message and generate the final execution result.

[0055] Optionally, the target message includes a task cancellation message or a node execution result of each target node.

[0056] Optionally, after or at the same time as returning the SQL sending result, the target message is obtained, and the final execution result is generated according to the target message, wherein the target message includes a task cancellation message or a node execution result of each target node. In this way, the SQL execution process can be divided into two stages: the first stage is to send the SQL statement to be executed to the target node, and the SQL statement to be sent will be returned after it is successfully sent through the TCP network without waiting for the node response; the second stage is to call the result acquisition interface and wait for the target node to return the node execution result. Through the SQL statement execution method provided by this implementation, it is possible to first batch send the SQL statement to be sent to all target nodes, and the target node first executes the SQL statement to be sent concurrently, and then waits for the node execution results of each target node to be readable in batches. It can solve the technical problem that the tasks executed by each node of the MPP distributed database in the related technology are often heavy and take a long time to execute. Therefore, if the synchronous blocking API is used to execute serially, the performance will be very low, which improves the performance, reduces the overhead of concurrent multi-threading, and is simple and convenient.

[0057] In some embodiments, before acquiring the target message, after sending the SQL statement to be sent to each target node through the target connection object, the method further includes:

[0058] Control each target node to concurrently execute the SQL statements to be sent.

[0059] Optionally, the method of concurrently executing the SQL statements to be sent by each target node may be implemented by using technical means of related technologies, which is not limited here.

[0060] Optionally, the process of obtaining the target message is to monitor two message sources, on the one hand, to monitor whether there is a task cancellation message, and on the other hand, to monitor whether there is a node execution result of each target node. The node execution result of each target node means that all target nodes have completed the execution of the SQL statement to be issued and returned their respective node execution results.

[0061] Optionally, the target message is obtained on a first-come-first-served basis, that is, whichever of the cancel task message and the node execution result of each target node is obtained first is the current target message. Therefore, the target message will only include either the cancel task message or the node execution result of each target node, and there will not be a situation where both situations coexist.

[0062] In some embodiments, obtaining the target message and generating the final execution result includes any one of the following:

[0063] If the target message includes the node execution results of each target node, a result set is generated according to the execution results of each node, and the final execution result includes the result set;

[0064] If the target message includes a task cancellation message, the final execution result includes task cancellation.

[0065] Optionally, the result set is a set generated by the node execution results corresponding to all target nodes.

[0066] Optionally, in the related technology, there is another problem in the MPP distributed database, because the SQL tasks executed by each node are relatively heavy. After issuing a request to cancel the task, the node often needs to wait for a long time to actually cancel the task and return the error message. In the method provided by the embodiment of the present invention, before the node execution results of each target node are obtained, once the task cancellation message is obtained, the final execution result includes task cancellation, and there is no need to wait for the target node to actually cancel the task, and the task cancellation can be returned. Rapid task cancellation can be achieved, allowing the application layer to process other transactions more quickly, improving resource utilization and improving system efficiency.

[0067] The method provided by the embodiment of the present invention does not immediately block the reading of result sets after batches of SQL statements to be sent to target nodes and the target nodes are concurrently executed, but enters a process of waiting for the result sets to be readable or the tasks to be canceled, that is, enters the process of obtaining target messages, and when any one of the task cancellation messages or the node execution results of each target node is obtained, that is, waits for the node execution results of all target nodes to be readable, or receives a task cancellation event before returning. In this way, IO multiplexing can be achieved and system efficiency can be improved.

[0068] In some embodiments, if the final execution result includes task cancellation, the method further includes:

[0069] Add the target connection object to the task cancellation queue.

[0070] In some embodiments, see Figure 2 , the SQL statement execution method includes:

[0071] S201: Obtain a corresponding number of target connection objects from a connection pool according to the number of target nodes that need to be executed.

[0072] For example, if the number of target nodes to be executed is N, then N target connection objects are obtained from the connection pool.

[0073] S202: Obtain the SQL statement to be issued.

[0074] It should be noted that the execution order of step S201 and step S202 is not limited here.

[0075] S203: Traverse the connection object list consisting of target connection objects.

[0076] S204: Determine whether the traversal is completed, if so, execute step S206, if not, execute step S205.

[0077] S205: Send the SQL statement to be sent to the target node for execution through the target connection object.

[0078] Optionally, after completing step S205, continue to execute step S203.

[0079] S206: Wait in batches for the result set to be readable or the task to be canceled.

[0080] Optional, that is, obtaining the target message. Among them, batch waiting result set is to obtain the node execution results of each target node, and the task is cancelled, that is, to obtain the cancel task message.

[0081] S207: Determine whether the task is cancelled, if not, execute step S208, if yes, execute step S209.

[0082] That is, determine whether a task cancellation message is obtained.

[0083] S208: Read and merge the execution results of each node to generate a result set.

[0084] That is, the node execution results of each target node are read and a result set is generated.

[0085] S209: Add each target connection object to the task cancellation queue.

[0086] In some embodiments, the execution results of each node are obtained as follows:

[0087] Get the node execution result of a target node;

[0088] If the target message is not currently obtained, continue to obtain the node execution result of the next target node until the node execution results of each target node are obtained.

[0089] Optionally, the node execution result of the corresponding target node can be obtained by obtaining the readable event of the target connection object.

[0090] Optionally, the order of obtaining the node execution results of each target node may be sorted in advance, and the node execution results may be obtained one by one according to the sorting.

[0091] For example, if the node execution result of a target node is obtained, if the task cancellation message has not been obtained at this time, the target number is reduced by 1, and the node execution result of the next target node is obtained. Repeat the above steps until the node execution results of all target nodes are obtained. At this time, the target message includes the node execution results of each target node. At this time, the final execution result includes the result set generated according to the execution results of each node.

[0092] In some embodiments, if a target message is currently obtained and the target message includes a task cancellation message, the acquisition of the node execution result of the next target node is stopped, and the final execution result includes task cancellation.

[0093] Optionally, at this time, it is necessary to cancel the execution of the SQL statement to be issued by each target node, so the node execution results of the target nodes that have not yet been obtained are no longer needed. Therefore, stopping obtaining the node execution results of the remaining target nodes can effectively save resources and improve system efficiency.

[0094] In some embodiments, if a target message is obtained before the node execution result of the first target node is obtained, that is, a cancel task message is obtained, then similar to the above embodiment, the acquisition of the node execution results of all target nodes is canceled and the task cancellation is returned.

[0095] In some embodiments, the execution results of each node are obtained as follows:

[0096] Initialize the poll object and pipeline respectively, and listen to the readable events of the pipeline through the poll object. The readable events of the pipeline include writing the task cancellation message;

[0097] The poll object is used to monitor the readable events of each target connection object, and poll_wait is used to wait for the readable events of each target connection object. The readable events of the target connection object include the node execution results of the target node.

[0098] Get a readable event of a target connection object;

[0099] If the pipe is not readable, get the readable event of the next target connection object until all readable events of the target objects are obtained.

[0100] Optionally, before obtaining the readable event of the next target connection object, it also includes:

[0101] The Poll object removes the monitoring of the target connection object that has obtained the readable event. That is, the poll object only monitors the target connection object that has not obtained the readable event, and no longer monitors the target connection object that has completed the readable event acquisition.

[0102] Optionally, before obtaining the readable event of the next target connection object, at least one of the following is also included:

[0103] Check whether all readable events of the target connection objects waited by poll_wait are obtained;

[0104] The number of readable events currently obtained for the target connection object.

[0105] Optionally, if the readable events of each target connection object that poll_wait is waiting for are all obtained, and / or the number of readable events currently obtained is equal to the number of target connection objects corresponding to the SQL statement to be issued, it means that all connection objects have completed the execution of SQL, and return a target message containing the node execution results of each target node.

[0106] Optionally, if before obtaining the readable event of the next target connection object, the readable events of the target connection objects that poll_wait waits for are all obtained, but the number of readable events obtained before is less than the number of target connection objects corresponding to the SQL statement to be issued, the method further includes:

[0107] poll_wait waits for a readable event of the target connection object that has not yet been acquired.

[0108] Optionally, if target information is obtained before obtaining a readable event of the next target connection object, and the target information includes a task cancellation message, the task is canceled and the step of obtaining a readable event of the next target connection object is no longer performed.

[0109] In some embodiments, if the pipeline is readable, the final execution result includes task cancellation.

[0110] Optionally, the pipeline is readable, that is, the task cancellation message is written into the pipeline. At this time, the target message has been obtained, but the node execution result of the target node has not been obtained, that is, the node execution results of some target nodes have not been obtained. Therefore, the final execution result includes task cancellation. Optionally, the acquisition of the node execution result of the target node ends, that is, the monitoring of a readable event of a target connection object and related steps through the poll object ends.

[0111] Optional, see Figure 3 A more specific embodiment is provided for obtaining the target message and generating the final execution result. The specific method includes:

[0112] S301: Initialize the poll object.

[0113] S302: Initialize the pipeline and monitor the readability of the pipeline through the poll object.

[0114] S303: Initialize the number of finished nodes.

[0115] It should be noted that the sequence of steps S301 to S303 is not limited and they can be executed simultaneously or in any order.

[0116] Optionally, the pipe is used to write a cancel task message. When the cancel task message is written to the pipe, the pipe is readable, otherwise the pipe is not readable.

[0117] Optionally, when initializing the number of finished nodes, the number of initialized finished nodes is equal to the number of target nodes and also equal to the number of target connection objects.

[0118] S304: Traverse the target connection object list.

[0119] S305: Check whether the traversal is completed. If so, execute step S307; if not, execute step S306.

[0120] S306: Monitor the readable events of the target connection object through the poll object.

[0121] That is, it is necessary to monitor the readable events of all target connection objects through the poll object.

[0122] S307: Call poll_wait to wait for a readable event.

[0123] Optionally, multiple target connection objects are returned as readable through poll_wait. In this case, all target connection objects may be readable; or only some target connection objects may be readable, while other target connection objects are not readable.

[0124] S308: Traverse the readable events that occurred.

[0125] Optionally, traverse the readable events of each target connection object.

[0126] S309: Determine whether the traversal is completed, if not, execute step S310, if yes, execute step S307.

[0127] S310: Determine whether the pipe is readable, if so, execute step S311, if not, execute step S315.

[0128] S311: The number of finished nodes decreases by 1.

[0129] Optionally, obtain a readable event of a target connection object a returned by poll_wait, and the traversal of the readable events of the target connection object a is completed. If the current pipe is unreadable, the number of finished nodes is reduced by 1. If the number of finished nodes is not zero at this time, and there are readable events of multiple target connection objects b returned by poll_wait that have not been read, that is, the traversal is not completed, continue to obtain the readable event of the next target connection object b returned by poll_wait, and the traversal of the readable events of the target connection object b is completed... until the traversal is completed.

[0130] S312: Determine whether the number of finished nodes is equal to 0, if so, execute step S313, if not, execute step S314.

[0131] Optionally, when step S312 determines whether finished is equal to 0, if it is equal to 0, it means that all target connection objects have been checked, or when it is checked that the task is cancelled, the process will automatically exit the loop.

[0132] S313: Use the node execution result of each target node as the target message.

[0133] S314: Remove the monitoring of the target connection object from the poll object.

[0134] Optionally, after step S314 is completed, continue to execute step S308.

[0135] S315: Use the cancel task message as the target message.

[0136] S316: The final execution result includes task cancellation.

[0137] Optionally, if the pipeline is readable, that is, the cancel task message is written, then the readable events of the remaining target nodes are no longer obtained, and the cancel task message is directly used as the target message, and the final execution result includes task cancellation.

[0138] S317: The final execution result includes a result set.

[0139] The embodiment of the present invention solves the problem in the related art that in an MPP distributed database, since the SQL tasks executed by each node are relatively heavy, after issuing a request to cancel the task, the node often needs to wait for a long time to actually cancel the task and return an error message. After sending SQL in batches to the node for execution, the result set is not immediately blocked for reading, but a batch waiting process for the result set to be readable or the task to be canceled is entered (obtaining the target message). This process introduces IO multiplexing and pipeline mechanisms, waiting for all result sets to be readable, or receiving a task cancellation event before returning, thereby realizing rapid task cancellation and allowing the application layer to quickly handle other things.

[0140] When all target nodes are executed and the result set is readable (the node execution results of all target nodes are obtained), the logic can be returned, and non-blocking batch reading of the result set can be started. When the user wants to cancel the task, he only needs to write data to the pipeline, which will trigger the pipeline's readable event and return from poll_wait, which can immediately end the process of waiting for the result set, thereby quickly canceling the task.

[0141] In some embodiments, the method further comprises:

[0142] Add the target connection object to the task cancellation queue, and terminate the tasks of each target connection object in the task cancellation queue.

[0143] Since only the task cancellation is returned as the final execution result, the execution of the SQL statement to be sent is only completed at the application layer. In fact, from the perspective of each node, the task is not canceled and they are still running. It is just that the task is canceled from the perspective of the MPP distributed database. In order to truly cancel the task at the node level, the task cancellation operation must also be performed at the target node level.

[0144] Optionally, this can be achieved by introducing a thread dedicated to canceling tasks (kill thread). The kill thread is responsible for canceling tasks and reclaiming connections at the node level.

[0145] Optional, see Figure 4 , Figure 4 A specific example method for canceling a task at the node level is provided, and the method includes:

[0146] S401: Start the kill thread.

[0147] S402: Whether the exit signal is received, if not, execute step S403:

[0148] S403: Obtain the target connection object from the task cancellation queue.

[0149] S404: Kill the thread of the target connection object that is executing the SQL statement task to be issued.

[0150] S405: Return the target connection object to the connection pool.

[0151] Optionally, if an exit signal is received, that is, the system exits, the kill thread will also be terminated.

[0152] Optionally, if all target connection objects are returned to the connection pool, the kill thread is still maintained until the system exits, at which time the kill thread ends.

[0153] Optionally, the exit signal may also be other signals set by those skilled in the art, which is not limited here.

[0154] The embodiment of the present invention obtains the SQL statement to be issued and several target connection objects, sends the SQL statement to be issued to the target node through the target connection object, generates an SQL sending result, obtains the target message, and generates a final execution result. The execution of SQL is divided into two stages, thereby avoiding the overhead of multi-threading and the complexity of asynchronous programming. It can solve the problem in the related technology that the tasks executed by each node of the MPP distributed database are often heavy and require a long execution time. Therefore, if a synchronous blocking API is used for serial execution, the performance will be very low. For the multi-threaded solution of the distributed database, the overhead is large, and each executed SQL needs to start a thread, which is inefficient. The performance is improved, the overhead of concurrent multi-threading is reduced, and it is simple and convenient.

[0155] Embodiment 2

[0156] See also Figure 5 The embodiment of the present invention further provides a SQL statement execution system 500, including:

[0157] The acquisition module 501 is used to acquire the SQL statement to be issued and several target connection objects;

[0158] The sending module 502 is used to send the SQL statement to be sent to each target node through the target connection object and generate the SQL sending result;

[0159] The generating module 503 is used to obtain the target message and generate the final execution result. The target message includes the task cancellation message or the node execution result of each target node.

[0160] In this embodiment, the SQL statement execution system is essentially provided with multiple modules for executing the SQL statement execution method in the above embodiment. The specific functions and technical effects can be referred to in the above embodiment 1, which will not be repeated here.

[0161] See also Figure 6 , an embodiment of the present invention further provides a terminal 1100, including a processor 1101, a memory 1102 and a communication bus 1103;

[0162] The communication bus 1103 is used to connect the processor 1101 and the memory 1102;

[0163] The processor 1101 is used to execute the computer program stored in the memory 1102 to implement the SQL statement execution method as described in any one of the embodiments in the above-mentioned embodiment 1.

[0164] The embodiment of the present invention further provides a computer-readable storage medium, characterized in that a computer program is stored thereon.

[0165] The computer program is used to enable a computer to execute the SQL statement execution method as described in any one of the above-mentioned embodiments.

[0166] The embodiment of the present application also provides a non-volatile readable storage medium, which stores one or more modules (programs). When the one or more modules are applied to a device, the device can execute instructions (instructions) of the steps included in the embodiment 1 of the embodiment of the present application.

[0167] It should be noted that the computer-readable medium disclosed above may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, 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 wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in combination with an instruction execution system, device or device. In the present disclosure, 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. This propagated data signal may take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. The 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 for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.

[0168] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.

[0169] Computer program code for performing the operations of the present disclosure 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., through the Internet using an Internet service provider).

[0170] The flow chart and block diagram in the accompanying drawings illustrate the possible implementation architecture, function and operation of the method and computer program product according to various embodiments of the present disclosure. In this regard, each square box in the flow chart 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 a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square 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 square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart 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.

[0171] The above embodiments are merely illustrative of the principles and effects of the present invention, and are not intended to limit the present invention. Anyone familiar with the art may modify or alter the above embodiments without departing from the spirit and scope of the present invention. Therefore, all equivalent modifications or alterations made by a person of ordinary skill in the art without departing from the spirit and technical concept disclosed by the present invention shall still be covered by the claims of the present invention.

Claims

1. A method for executing SQL statements, characterized in that: include: Get the SQL statement to be issued and several target connection objects; Send the SQL statement to be sent to each target node through the target connection object, and generate an SQL sending result; Obtaining a target message and generating a final execution result, wherein the target message includes a task cancellation message or a node execution result of each target node; The execution results of each node are obtained as follows: Initialize a poll object and a pipeline respectively, and monitor the readable events of the pipeline through the poll object, wherein the readable events of the pipeline include writing the cancel task message; Monitor the readable events of each target connection object through the poll object, and wait for the readable events of each target connection object through poll_wait, where the readable events of the target connection object include the node execution result of the target node; Get a readable event of the target connection object; If the pipe is not readable, obtain the next readable event of the target connection object until all readable events of the target connection objects are obtained; If the pipeline is readable, the final execution result includes task cancellation; If the final execution result includes task cancellation, it also includes any one of the following: Add the target connection object to the task cancellation queue; The target connection object is added to a task cancellation queue, and the tasks of each target connection object in the task cancellation queue are terminated.

2. The SQL statement execution method according to claim 1, characterized in that: The obtaining of the target message and generating the final execution result includes any one of the following: If the target message includes node execution results of each of the target nodes, a result set is generated according to the execution results of each of the nodes, and the final execution result includes the result set; If the target message includes a task cancellation message, the final execution result includes task cancellation.

3. The SQL statement execution method according to claim 1, characterized in that: The execution results of each node are obtained as follows: Obtaining a node execution result of the target node; If the target message is not currently obtained, continue to obtain the node execution result of the next target node until the node execution results of each target node are obtained.

4. The SQL statement execution method according to claim 3, characterized in that: Also includes: If the target message is currently acquired and the target message includes a task cancellation message, the acquisition of the node execution result of the next target node is stopped, and the final execution result includes task cancellation.

5. A SQL statement execution system, characterized in that: include: The acquisition module is used to obtain the SQL statement to be issued and several target connection objects; A sending module, used to send the SQL statement to be sent to each target node through the target connection object, and generate an SQL sending result; A generation module, used to obtain a target message and generate a final execution result, wherein the target message includes a task cancellation message or a node execution result of each target node; Wherein, the generating module is also specifically used for: Initialize a poll object and a pipeline respectively, and monitor the readable events of the pipeline through the poll object, wherein the readable events of the pipeline include writing the cancel task message; Monitor the readable events of each target connection object through the poll object, and wait for the readable events of each target connection object through poll_wait, where the readable events of the target connection object include the node execution result of the target node; Get a readable event of the target connection object; If the pipe is not readable, obtain the next readable event of the target connection object until all readable events of the target connection objects are obtained; If the pipeline is readable, the final execution result includes task cancellation; Add the target connection object to the task cancellation queue; The target connection object is added to a task cancellation queue, and the tasks of each target connection object in the task cancellation queue are terminated.

6. A terminal, characterized in that: including a processor, a memory and a communication bus; The communication bus is used to connect the processor and the memory; The processor is used to execute the computer program stored in the memory to implement the SQL statement execution method according to any one of claims 1 to 4.

7. A computer-readable storage medium, characterized in that: A computer program is stored thereon, The computer program is used to enable the computer to execute the SQL statement execution method according to any one of claims 1 to 4.