Structured query statement processing method, apparatus, device, and readable storage medium
Patent Information
- Application Number
- CN202311369348.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-10-20
- Publication Date
- 2026-08-21
- Estimated Expiration
- 2043-10-20
AI Technical Summary
[0004]但是,Postgres在OLAP场景下有很多问题
[0023]本公开实施例提供的结构化查询语句处理方法、装置、设备及可读存储介质,通过获取多条待处理的结构化查询语句,对于所述多条待处理的结构化查询语句中的每条结构化查询语句,为所述每条结构化查询语句生成各自对应的目标计划树,对所述每条结构化查询语句对应的目标计划树进行映射,得到所述每条结构化查询语句的向量计划树,基于所述每条结构化查询语句的向量计划树,调用专用数据处理器对所述每条结构化查询语句进行处理,得到所述每条结构化查询语句的处理结果。相较于现有技术,本公开通过基于所述每条结构化查询语句的向量计划树,调用专用数据处理器对所述每条结构化查询语句进行处理,得到所述每条结构化查询语句的处理结果,可以对每条结构化查询语句内部的处理函数进行批量处理,提高处理效率,减少函数调用次数,有效利用缓存,提高缓存命中率。
Smart Images

Figure CN118093618B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of computer technology, and in particular to a method, apparatus, device and readable storage medium for processing structured query statements. Background Technology
[0002] Postgres, as a widely used open-source database, is characterized by its reliability, scalability, and compatibility. It has been widely adopted in applications of various sizes and types, such as online analytical processing (OLAP).
[0003] Online analytical processing (OLAP) is a database processing approach used to support complex analytics and decision support systems. OLAP systems are primarily used to extract, analyze, and report data from large-scale datasets to gain business insights and support strategic decision-making.
[0004] However, Postgres has many problems in OLAP scenarios. For example, each data scan is very cumbersome, requiring multiple rows, and each row has multiple attribute values. This means that each data scan needs to process a lot of useless (unrelated) data, resulting in a large amount of data to be processed and low processing efficiency. Although the advantage of Postgres's executor streaming structure is that it does not need to store a large amount of intermediate data, this design leads to a large number of function calls, cannot effectively utilize the cache, reduces the cache hit rate, and is inconvenient for batch computing. Summary of the Invention
[0005] To solve the above-mentioned technical problems, or at least partially solve them, this disclosure provides a method, apparatus, device, and readable storage medium for processing structured query statements in batches, thereby improving processing efficiency, reducing the number of function calls, effectively utilizing cache, and improving cache hit rate.
[0006] In a first aspect, embodiments of this disclosure provide a method for processing structured query statements, the method comprising:
[0007] Retrieve multiple structured query statements to be processed;
[0008] For each of the multiple structured query statements to be processed, generate a corresponding target plan tree for each structured query statement;
[0009] Map the target plan tree corresponding to each structured query statement to obtain the vector plan tree for each structured query statement;
[0010] Based on the vector plan tree of each structured query statement, a dedicated data processor is invoked to process each structured query statement, and the processing result of each structured query statement is obtained.
[0011] Secondly, embodiments of this disclosure provide a structured query statement processing apparatus, the apparatus comprising:
[0012] The acquisition module is used to acquire multiple structured query statements to be processed;
[0013] The generation module is used to generate a corresponding target plan tree for each of the multiple structured query statements to be processed.
[0014] The mapping module is used to map the target plan tree corresponding to each structured query statement to obtain the vector plan tree of each structured query statement;
[0015] The processing module is used to call a dedicated data processor to process each structured query statement based on the vector plan tree of each structured query statement, and obtain the processing result of each structured query statement.
[0016] Thirdly, embodiments of this disclosure provide an electronic device, including:
[0017] Memory;
[0018] Processor; and
[0019] Computer programs;
[0020] The computer program is stored in the memory and configured to be executed by the processor to implement the method as described in the first aspect.
[0021] Fourthly, embodiments of this disclosure provide a computer-readable storage medium having a computer program stored thereon, the computer program being executed by a processor to implement the method as described in the first aspect.
[0022] Fifthly, embodiments of this disclosure also provide a computer program product comprising a computer program or instructions that, when executed by a processor, implement the method described in the first aspect.
[0023] The structured query processing method, apparatus, device, and readable storage medium provided in this disclosure acquire multiple structured query statements to be processed. For each structured query statement, a corresponding target plan tree is generated. The target plan tree corresponding to each structured query statement is mapped to obtain a vector plan tree for each structured query statement. Based on the vector plan tree of each structured query statement, a dedicated data processor is invoked to process each structured query statement, thereby obtaining a processing result for each structured query statement. Compared with the prior art, this disclosure, by invoking a dedicated data processor to process each structured query statement based on its vector plan tree, and obtaining a processing result for each structured query statement, allows for batch processing of the processing functions within each structured query statement, improving processing efficiency, reducing the number of function calls, effectively utilizing cache, and improving cache hit rate. Attached Figure Description
[0024] The accompanying drawings, which are incorporated in and form a part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure.
[0025] To more clearly illustrate the technical solutions in the embodiments of this disclosure or the prior art, the accompanying drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0026] Figure 1 A flowchart of a structured query statement processing method provided in this embodiment of the disclosure;
[0027] Figure 2 A flowchart of a structured query statement processing method provided in another embodiment of this disclosure;
[0028] Figure 3 A flowchart of a structured query statement processing method provided in another embodiment of this disclosure;
[0029] Figure 4 This is a schematic diagram illustrating the conversion of row storage format to column storage format according to an embodiment of this disclosure;
[0030] Figure 5 This is a schematic diagram of the structure of the structured query statement processing apparatus provided in the embodiments of this disclosure;
[0031] Figure 6 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this disclosure. Detailed Implementation
[0032] To better understand the above-mentioned objectives, features, and advantages of this disclosure, the solutions disclosed herein will be further described below. It should be noted that, unless otherwise specified, the embodiments and features described herein can be combined with each other.
[0033] Numerous specific details are set forth in the following description in order to provide a full understanding of this disclosure, but this disclosure may also be implemented in other ways different from those described herein; obviously, the embodiments in the specification are only some, and not all, of the embodiments of this disclosure.
[0034] Postgres, as a widely used open-source database, is characterized by its reliability, scalability, and compatibility. It has been widely adopted in applications of various sizes and types, such as online analytical processing (OLAP).
[0035] Online analytical processing (OLAP) is a database processing approach used to support complex analytics and decision support systems. OLAP systems are primarily used to extract, analyze, and report data from large-scale datasets to gain business insights and support strategic decision-making.
[0036] However, Postgres has many problems in OLAP scenarios. For example, each data scan is cumbersome, requiring multiple rows, and each row has multiple attribute values. This means that each scan needs to process a lot of useless (unrelated) data, resulting in a large amount of data processed and low efficiency. Although Postgres's executor streaming structure has the advantage of not needing to store large amounts of intermediate data, this design leads to a high number of function calls, ineffective cache utilization, reduced cache hit rate, and inconvenience for batch computation. To address this problem, this disclosure provides a structured query statement processing method, which will be described below with reference to specific embodiments.
[0037] Figure 1 This is a flowchart illustrating a structured query processing method provided in this embodiment. The method is executed by an electronic device. The electronic device can be a database server, which can be a single server, a server cluster, a distributed cluster, or a centralized cluster. This method can be applied to scenarios involving the processing of structured query statements. It is understood that the structured query processing method provided in this embodiment can also be applied to other scenarios.
[0038] The following is about Figure 1 The method for processing structured query statements is described below, and the specific steps included in this method are as follows:
[0039] S101. Obtain multiple structured query statements to be processed.
[0040] In this step, the database server obtains multiple structured query statements to be processed. Specifically, the client sends multiple structured query statements to the database server, and the database server receives these statements, thus obtaining the multiple structured query statements to be processed.
[0041] In some alternative implementations, the access methods layer in the database server retrieves multiple structured query statements to be processed.
[0042] S102. For each of the multiple structured query statements to be processed, generate a corresponding target plan tree for each structured query statement.
[0043] After obtaining multiple structured query statements to be processed, the database server generates a corresponding target plan tree for each structured query statement. The target plan tree represents the processing logic for each structured query statement. For example, the target plan tree for structured query statement A is to first scan the data, then perform hash joins, and finally aggregate the data.
[0044] S103. Map the target plan tree corresponding to each structured query statement to obtain the vector plan tree of each structured query statement.
[0045] After generating a corresponding target plan tree for each structured query statement, the database server maps the target plan tree for each structured query statement to obtain a vector plan tree for each structured query statement. Specifically, the query planning unit in the database server maps the target plan tree for each structured query statement to obtain a vector plan tree for each structured query statement.
[0046] S104. Based on the vector plan tree of each structured query statement, call a dedicated data processor to process each structured query statement to obtain the processing result of each structured query statement.
[0047] A Data Processing Unit (DPU) is a dedicated hardware accelerator used to accelerate data processing and computationally intensive tasks. Compared to traditional general-purpose processors (such as CPUs), DPUs can effectively relieve CPU load. For example, offloading specific data processing tasks to a DPU can free up CPU resources, allowing it to focus on other computational tasks. This improves overall system performance and responsiveness, and allows for more parallel processing. Secondly, DPUs are typically equipped with dedicated instruction sets and hardware accelerators, providing faster computation speeds and lower latency, thus accelerating task execution. Furthermore, the memory architecture of DPUs can provide higher bandwidth and lower latency, thereby improving computational efficiency. Finally, DPUs are flexible and scalable; they can be flexibly integrated into systems, functioning as standalone hardware accelerators or working in conjunction with other processors such as CPUs and GPUs. They can also be expanded as needed to meet data processing tasks of different scales and requirements.
[0048] In this step, the database server, based on the vector plan tree of each structured query statement, calls a dedicated data processor to process each structured query statement, obtains the processing result of each structured query statement, and calls a dedicated data processing unit (DPU) to process each structured query statement, offloading the computation to the DPU chip. By connecting to the DPU for computation, the effect of computation acceleration can be achieved.
[0049] This disclosure, through its embodiments, acquires multiple structured query statements to be processed. For each structured query statement, it generates a corresponding target plan tree, maps the target plan tree to obtain a vector plan tree for each structured query statement, and, based on the vector plan tree, calls a dedicated data processor to process each structured query statement, obtaining a processing result for each structured query statement. Compared to existing technologies, this disclosure, by using the vector plan tree of each structured query statement and calling a dedicated data processor to process each structured query statement to obtain a processing result, allows for batch processing of the processing functions corresponding to each structured query statement, improving processing efficiency, reducing the number of function calls, effectively utilizing cache, and improving cache hit rate.
[0050] Figure 2 Here is a flowchart of a structured query processing method provided in another embodiment of this disclosure, such as... Figure 2 As shown, the method includes the following steps:
[0051] S201. Obtain a structured query statement with multiple rows stored in a structured format.
[0052] In this step, the database server retrieves multiple structured query statements in row-based storage format. In row-based storage format, only one data tuple can be transmitted or processed at a time.
[0053] S202. Convert multiple row-stored structured query statements into column-stored format to obtain multiple structured query statements to be processed.
[0054] The vectorized executor in the database server converts multiple row-oriented structured query statements into column-oriented format, resulting in multiple structured query statements to be processed. In column-oriented format, a batch of data tuples can be transmitted or processed simultaneously. For example... Figure 4 As shown, for example, a row-stored structured query statement has five attribute information, namely V0, V1, V2, V3, and V4. Converting multiple row-stored structured query statements into column-stored format yields multiple structured query statements to be processed, such as... Figure 4 The diagram shows how to convert five row-formatted structured query statements into column-formatted structured query statements, resulting in five unprocessed structured query statements. Since each row-formatted structured query statement has five attribute information, converting them into column-formatted structured query statements results in a 5×5 vector of column-formatted structured query statements. The five attribute information for the first unprocessed structured query statement are V00, V01, V02, V03, and V04; the five attribute information for the second unprocessed structured query statement are V10, V11, V12, V13, and V14; the five attribute information for the third unprocessed structured query statement are V20, V21, V22, V23, and V24; the five attribute information for the fourth unprocessed structured query statement are V30, V31, V32, V33, and V34; and the five attribute information for the fifth unprocessed structured query statement are V40, V41, V42, V43, and V44.
[0055] S203. For each of the multiple structured query statements to be processed, determine multiple execution plan trees for each structured query statement.
[0056] A Structured Query Language (SQL) statement can be executed in multiple ways. In this step, the database server determines multiple execution plan trees for each structured query statement. Each execution plan tree represents one execution method for the structured query statement.
[0057] S204. Based on the cost model, traverse the multiple execution plan trees of each structured query statement to obtain the cost of the multiple execution plan trees of each structured query statement.
[0058] Furthermore, the optimizer in the database server will traverse every possible execution plan tree and calculate its cost value as much as possible within its computing capabilities.
[0059] S205. The execution plan tree with the lowest value among the various execution plan trees is determined as the target plan tree for each structured query statement.
[0060] The optimizer in the database server determines the execution plan tree with the lowest cost among the various execution plan trees as the target plan tree for each structured query statement. For example, the execution plan tree with the lowest cost is selected and used as the target plan tree for each structured query statement.
[0061] S206. Map the target plan tree corresponding to each structured query statement to obtain the vector plan tree of each structured query statement.
[0062] Specifically, the implementation process and principle of S206 and S103 are the same, and will not be repeated here.
[0063] In some embodiments, when S206 maps the target plan tree corresponding to each structured query statement to obtain the vector plan tree of each structured query statement, it specifically includes, but is not limited to, S2061 and S2062:
[0064] S2061. Determine each node in the target plan tree corresponding to each structured query statement.
[0065] In this embodiment, the database server determines each node in the target plan tree corresponding to each structured query statement. For example, the target plan tree for structured query statement A is to first scan the data, then perform hash joins, and finally aggregate the data; that is, the target plan tree contains scan nodes, join nodes, and aggregation nodes.
[0066] In some embodiments, each node in the target plan tree includes at least one of the following: a scan node, a connection node, an aggregation node, and a sorting node.
[0067] Optionally, each node in the target plan tree may include any one of the following: scan node, connect node, aggregate node, and sort node; or any combination of these nodes; or other nodes, without specific limitations.
[0068] S2062. Modify each node in the target plan tree corresponding to each structured query statement into a vectorized node to obtain the vector plan tree of each structured query statement.
[0069] In this embodiment, the database server modifies each node in the target plan tree corresponding to each structured query statement into a vectorized node, thereby obtaining a vector plan tree for each structured query statement. Specifically, the query planning in the database server modifies nodes into custom scan nodes, and modifies the column attributes involved in the nodes into vector attributes, which facilitates the subsequent vectorized calculation of each operator node by the executor in the database server.
[0070] S207. Based on the vector plan tree of each structured query statement, call a dedicated data processor to process each structured query statement to obtain the processing result of each structured query statement.
[0071] Specifically, the implementation process and principle of S207 and S104 are the same, and will not be repeated here.
[0072] This embodiment of the disclosure obtains multiple row-formatted structured query statements, converts them into column-formatted structured query statements, and obtains multiple structured query statements to be processed. Further, for each structured query statement, multiple execution plan trees are determined. Based on a cost model, these execution plan trees are traversed to obtain their cost values. The execution plan tree with the lowest cost value is determined as the target plan tree for each structured query statement. The target plan tree for each structured query statement is then mapped to obtain a vector plan tree for each structured query statement. Finally, based on the vector plan tree, a dedicated data processor is invoked to process each structured query statement, yielding the processing result. Compared to existing technologies, the embodiments of this disclosure call a dedicated data processor to process each structured query statement, offloading the computation to the DPU chip. By accessing the DPU for computation, the computation speed can be accelerated. The processing functions corresponding to each structured query statement can be processed in batches, improving processing efficiency, reducing the number of function calls, effectively utilizing the cache, and improving the cache hit rate.
[0073] Figure 3 Here is a flowchart of a structured query processing method provided in another embodiment of this disclosure, such as... Figure 3 As shown, the method includes the following steps:
[0074] S301. Obtain multiple structured query statements to be processed.
[0075] Specifically, the implementation process and principle of S301 and S101 are the same, and will not be repeated here.
[0076] S302. For each of the multiple structured query statements to be processed, generate a corresponding target plan tree for each structured query statement.
[0077] Specifically, the implementation process and principle of S302 and S102 are the same, and will not be repeated here.
[0078] S303. Determine each node in the target plan tree corresponding to each structured query statement.
[0079] In this embodiment, the database server determines each node in the target plan tree corresponding to each structured query statement. For example, the target plan tree for structured query statement A is to first scan the data, then perform hash joins, and finally aggregate the data; that is, the target plan tree contains scan nodes, join nodes, and aggregation nodes.
[0080] In some embodiments, each node in the target plan tree includes at least one of the following: a scan node, a connection node, an aggregation node, and a sorting node.
[0081] Optionally, each node in the target plan tree may include any one of the following: scan node, connect node, aggregate node, and sort node; or any combination of these nodes; or other nodes, without specific limitations.
[0082] S304. For any node in the target plan tree corresponding to each structured query statement, determine the data type and processing function of that node.
[0083] Furthermore, for any node in the target plan tree corresponding to each structured query statement, the database server determines the data type and processing function of that node.
[0084] S305. Modify the data type and processing function of the node to vectorized data type and vectorized processing function respectively to obtain the vectorized node corresponding to the node.
[0085] In this embodiment, the database server modifies the data type of the node to a vectorized data type and the processing function to a vectorized processing function, thus obtaining the corresponding vectorized node. Specifically, the executor in the database server can implement vector tuple slot related functions and inject SQL, enabling the system table to automatically find the vectorized calculation function and perform vectorized calculation. Modifying each node to a vectorized node and changing the data data on each node to the corresponding vectorized data type aims to allow the database server's native logic to find the corresponding vectorized processing function during the execution phase. Automatic switching can be achieved through the database server kernel logic without the need for additional logic.
[0086] S306. Replace each node in the target plan tree corresponding to each structured query statement with the vectorized node corresponding to each node to obtain the vector plan tree of each structured query statement.
[0087] In this embodiment, the database server replaces each node in the target plan tree corresponding to each structured query statement with the corresponding vectorized node to obtain the vector plan tree of each structured query statement. It can inherit the existing data structure to realize the vectorized data structure, so that the data processed inside the executor in the database server is in a multi-row column storage format, inheriting various types of nodes and adaptively connecting to the vectorized executor.
[0088] S307. For any vectorized node in the vector plan tree of each structured query statement, perform expression calculation on the vectorized data type and vectorized processing function of the vectorized node.
[0089] After obtaining the vector plan tree for each structured query statement, the database server performs expression computation on any vectorized node in the vector plan tree for that node, along with its vectorized data type and vectorized processing function. In this embodiment, heterogeneous computing is introduced when the database server is actually performing computation. The database server integrates computation into the expression computation process, choosing to connect to the heterogeneous platform only when the expression computation actually calls functions for computation acceleration. This achieves smooth integration, maximizes advantages, and minimizes disruption to the existing functions of the database server. In some embodiments, during heterogeneous computing, the database server needs to prepare and offload vectorized data into the expression computation process, and then call a dedicated data processor to perform vectorized data operations and integrate the results.
[0090] S308. The dedicated data processor is invoked to process each structured query statement based on the vectorized data type and the vectorized processing function to obtain the processing result of each structured query statement.
[0091] In this step, the database server invokes a dedicated data processor to process each structured query statement according to the vectorized data type and the vectorized processing function, obtaining the processing result for each structured query statement. In some embodiments, after obtaining the processing result for each structured query statement, the database server will feed back the processing result of each structured query statement to the client.
[0092] This embodiment of the disclosure acquires multiple structured query statements to be processed. For each structured query statement, a corresponding target plan tree is generated, and the nodes in the target plan tree for each structured query statement are determined. Further, for any node in the target plan tree for each structured query statement, the data type and processing function of that node are determined. The data type and processing function of that node are modified to vectorized data type and vectorized processing function, respectively, to obtain the corresponding vectorized node. Each node in the target plan tree for each structured query statement is replaced with its corresponding vectorized node, resulting in a vectorized plan tree for each structured query statement. Then, for any vectorized node in the vectorized plan tree for each structured query statement, the vectorized data type and vectorized processing function of that vectorized node are used to perform expression calculations. The dedicated data processor is then invoked to process each structured query statement based on the vectorized data type and vectorized processing function, obtaining the processing result for each structured query statement. Compared to existing technologies, the embodiments of this disclosure call a dedicated data processor to process each structured query statement, offloading the computation to the DPU chip. By accessing the DPU for computation, the computation speed can be accelerated. The processing functions corresponding to each structured query statement can be processed in batches, improving processing efficiency, reducing the number of function calls, effectively utilizing the cache, and improving the cache hit rate.
[0093] Figure 5 This is a schematic diagram of the structure of a structured query statement processing device provided in an embodiment of this disclosure. The structured query statement processing device may be an electronic device as described in the above embodiment, or it may be a component or assembly within that electronic device. The structured query statement processing device provided in this embodiment of the disclosure can execute the processing flow provided in the embodiment of the structured query statement processing method, such as... Figure 5As shown, the structured query statement processing device 50 includes: an acquisition module 51, a generation module 52, a mapping module 53, and a processing module 54; wherein, the acquisition module 51 is used to acquire multiple structured query statements to be processed; the generation module 52 is used to generate a corresponding target plan tree for each structured query statement among the multiple structured query statements to be processed; the mapping module 53 is used to map the target plan tree corresponding to each structured query statement to obtain a vector plan tree for each structured query statement; the processing module 54 is used to call a dedicated data processor to process each structured query statement based on the vector plan tree of each structured query statement to obtain the processing result of each structured query statement.
[0094] Optionally, when the acquisition module 51 acquires multiple structured query statements to be processed, it is specifically used to: acquire multiple structured query statements in row storage format; convert the multiple structured query statements in row storage format into column storage format to obtain multiple structured query statements to be processed.
[0095] Optionally, when the generation module 52 generates a target plan tree for each structured query statement, it is specifically used to: determine multiple execution plan trees for each structured query statement; traverse the multiple execution plan trees for each structured query statement based on the cost model to obtain the cost value of the multiple execution plan trees for each structured query statement; and determine the execution plan tree with the smallest cost value among the multiple execution plan trees as the target plan tree for each structured query statement.
[0096] Optionally, when the mapping module 53 maps the target plan tree corresponding to each structured query statement to obtain the vector plan tree of each structured query statement, it is specifically used to: determine each node in the target plan tree corresponding to each structured query statement; and modify each node in the target plan tree corresponding to each structured query statement to a vector node to obtain the vector plan tree of each structured query statement.
[0097] Optionally, when the mapping module 53 modifies each node in the target plan tree corresponding to each structured query statement to a vectorized node to obtain the vector plan tree of each structured query statement, it specifically performs the following steps: for any node in the target plan tree corresponding to each structured query statement, determine the data type and processing function of that node; modify the data type and processing function of that node to a vectorized data type and a vectorized processing function to obtain the vectorized node corresponding to that node; replace each node in the target plan tree corresponding to each structured query statement with the vectorized node corresponding to each node to obtain the vector plan tree of each structured query statement.
[0098] Optionally, each node in the target plan tree includes at least one of the following: a scan node, a connection node, an aggregation node, and a sorting node.
[0099] Optionally, when the processing module 54 calls a dedicated data processor to process each structured query statement based on the vector plan tree of each structured query statement to obtain the processing result of each structured query statement, it specifically performs the following: for any vectorized node in the vector plan tree of each structured query statement, it performs expression calculation on the vectorized data type and vectorized processing function of the vectorized node; and calls the dedicated data processor to process each structured query statement based on the vectorized data type and the vectorized processing function to obtain the processing result of each structured query statement.
[0100] Figure 5 The structured query statement processing device of the illustrated embodiment can be used to execute the technical solution of the above method embodiment. Its implementation principle and technical effect are similar, and will not be described again here.
[0101] Figure 6 This is a schematic diagram of the structure of an electronic device according to an embodiment of this disclosure. See below for details. Figure 6 It shows a schematic diagram of a structure suitable for implementing the electronic device 600 in the embodiments of this disclosure. Figure 6 The electronic device shown is merely an example and should not be construed as limiting the functionality and scope of the embodiments disclosed herein.
[0102] like Figure 6As shown, the electronic device 600 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 601, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage device 608 into a random access memory (RAM) 603 to implement the structured query statement processing method as described in the embodiments of this disclosure. The RAM 603 also stores various programs and data required for the operation of the electronic device 600. The processing device 601, ROM 602, and RAM 603 are interconnected via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.
[0103] Typically, the following devices can be connected to I / O interface 605: input devices 606 including, for example, touchscreens, touchpads, keyboards, mice, cameras, microphones, accelerometers, gyroscopes, etc.; output devices 607 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; storage devices 608 including, for example, magnetic tapes, hard disks, etc.; and communication devices 609. Communication device 609 allows electronic device 600 to communicate wirelessly or wiredly with other devices to exchange data. Although Figure 6 An electronic device 600 with various devices is shown; however, it should be understood that it is not required to implement or possess all of the devices shown. More or fewer devices may be implemented or possessed alternatively.
[0104] In particular, according to embodiments of this disclosure, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this disclosure include a computer program product comprising a computer program carried on a non-transitory computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts, thereby implementing the structured query statement processing method as described above. In such embodiments, the computer program can be downloaded and installed from a network via communication device 609, or installed from storage device 608, or installed from ROM 602. When the computer program is executed by processing device 601, it performs the functions defined in the methods of embodiments of this disclosure.
[0105] It should be noted that the computer-readable medium described in this disclosure can be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. A computer-readable storage medium can be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this disclosure, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in connection with an instruction execution system, apparatus, or device. In this disclosure, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium can be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wires, optical fibers, RF (radio frequency), etc., or any suitable combination thereof.
[0106] Additionally, this disclosure also provides a vehicle, including: a memory; a processor; and a computer program; wherein the computer program is stored in the memory and configured to be executed by the processor to implement the structured query statement processing method as described above.
[0107] In some implementations, clients and servers can communicate using any currently known or future-developed network protocol such as HTTP (Hypertext Transfer Protocol) and can interconnect with digital data communication (e.g., communication networks) of any form or medium. Examples of communication networks include local area networks (“LANs”), wide area networks (“WANs”), the Internet (e.g., the Internet of Things), and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any currently known or future-developed networks.
[0108] The aforementioned computer-readable medium may be included in the aforementioned electronic device; or it may exist independently and not assembled into the electronic device.
[0109] The aforementioned computer-readable medium carries one or more programs that, when executed by the electronic device, cause the electronic device to:
[0110] Retrieve multiple structured query statements to be processed;
[0111] For each of the multiple structured query statements to be processed, generate a corresponding target plan tree for each structured query statement;
[0112] Map the target plan tree corresponding to each structured query statement to obtain the vector plan tree for each structured query statement;
[0113] Based on the vector plan tree of each structured query statement, a dedicated data processor is invoked to process each structured query statement, and the processing result of each structured query statement is obtained.
[0114] Optionally, when one or more of the above-described procedures are executed by the electronic device, the electronic device may also perform other steps described in the above embodiments.
[0115] Computer program code for performing the operations of this disclosure can be written in one or more programming languages or a combination thereof, including but not limited to object-oriented programming languages such as Java, Smalltalk, and C++, as well as conventional procedural programming languages such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone 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 remote computers, the remote computer can be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0116] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0117] The units described in the embodiments of this disclosure can be implemented in software or hardware. The names of the units are not, in some cases, intended to limit the specific unit.
[0118] The functions described above in this document can be performed, at least in part, by one or more hardware logic components. For example, exemplary types of hardware logic components that can be used, without limitation, include: Field Programmable Gate Arrays (FPGAs), Application-Specific Integrated Circuits (ASICs), Application Standard Products (ASSPs), System-on-Chip (SoCs), Complex Programmable Logic Devices (CPLDs), and so on.
[0119] In the context of this disclosure, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0120] The above description is merely a preferred embodiment of this disclosure and an explanation of the technical principles employed. Those skilled in the art should understand that the scope of this disclosure is not limited to technical solutions formed by specific combinations of the above-described technical features, but should also cover other technical solutions formed by arbitrary combinations of the above-described technical features or their equivalents without departing from the above-described concept. For example, technical solutions formed by substituting the above features with (but not limited to) technical features disclosed in this disclosure that have similar functions.
[0121] Furthermore, while the operations are described in a specific order, this should not be construed as requiring these operations to be performed in the specific order shown or in a sequential order. In certain environments, multitasking and parallel processing may be advantageous. Similarly, while several specific implementation details are included in the above discussion, these should not be construed as limiting the scope of this disclosure. Certain features described in the context of individual embodiments may also be implemented in combination in a single embodiment. Conversely, various features described in the context of a single embodiment may also be implemented individually or in any suitable sub-combination in multiple embodiments.
[0122] Although the subject matter has been described using language specific to structural features and / or methodological logic, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. Rather, the specific features and actions described above are merely illustrative examples of implementing the claims.
Claims
1. A method for processing structured query statements, characterized in that, The method includes: Obtain multiple structured query statements to be processed, including: obtaining multiple structured query statements in row storage format; converting the multiple structured query statements in row storage format into column storage format to obtain multiple structured query statements to be processed; For each of the multiple structured query statements to be processed, generate a corresponding target plan tree for each structured query statement; Mapping the target plan tree corresponding to each structured query statement to obtain the vector plan tree for each structured query statement includes: determining each node in the target plan tree corresponding to each structured query statement; for any node in the target plan tree corresponding to each structured query statement, determining the data type and processing function of that node; modifying the data type and processing function of that node to vectorized data type and vectorized processing function respectively to obtain the vectorized node corresponding to that node; replacing each node in the target plan tree corresponding to each structured query statement with the vectorized node corresponding to each node to obtain the vector plan tree for each structured query statement. Based on the vector plan tree of each structured query statement, a dedicated data processor is invoked to process each structured query statement to obtain the processing result of each structured query statement. This includes: for any vectorized node in the vector plan tree of each structured query statement, performing expression calculation on the vectorized data type and vectorized processing function of that vectorized node; and invoking the dedicated data processor to process each structured query statement based on the vectorized data type and the vectorized processing function to obtain the processing result of each structured query statement.
2. The method according to claim 1, characterized in that, The step of generating a corresponding target plan tree for each structured query statement includes: Determine multiple execution plan trees for each structured query statement; Based on the cost model, the multiple execution plan trees of each structured query statement are traversed to obtain the cost value of the multiple execution plan trees of each structured query statement. The execution plan tree with the lowest cost among the various execution plan trees is determined as the target plan tree for each structured query statement.
3. The method according to claim 1, characterized in that, Each node in the target plan tree includes at least one of the following: Scan node, connect node, aggregate node, sort node.
4. A structured query statement processing device, characterized in that, The device includes: The acquisition module is used to acquire multiple structured query statements to be processed, including: acquiring multiple structured query statements in row storage format; converting the multiple structured query statements in row storage format into column storage format to obtain multiple structured query statements to be processed; The generation module is used to generate a corresponding target plan tree for each of the multiple structured query statements to be processed. The mapping module is used to map the target plan tree corresponding to each structured query statement to obtain a vector plan tree for each structured query statement. This includes: determining each node in the target plan tree corresponding to each structured query statement; for any node in the target plan tree corresponding to each structured query statement, determining the data type and processing function of that node; modifying the data type and processing function of that node to vectorized data type and vectorized processing function respectively, obtaining the vectorized node corresponding to that node; and replacing each node in the target plan tree corresponding to each structured query statement with the corresponding vectorized node, thus obtaining the vector plan tree for each structured query statement. The processing module is used to call a dedicated data processor to process each structured query statement based on the vector plan tree of each structured query statement, and obtain the processing result of each structured query statement. This includes: for any vectorized node in the vector plan tree of each structured query statement, performing expression calculation on the vectorized data type and vectorized processing function of that vectorized node; and calling the dedicated data processor to process each structured query statement based on the vectorized data type and the vectorized processing function, to obtain the processing result of each structured query statement.
5. An electronic device, characterized in that, include: Memory; processor; as well as Computer programs; The computer program is stored in the memory and configured to be executed by the processor to implement the method as described in any one of claims 1-3.
6. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the method as described in any one of claims 1-3.
Citation Information
Patent Citations
Method and device for vectorizing data
CN110858203A
Method for format conversion from row storage to column storage and query method and device
CN110990402A