Multi-table connection query method, system and equipment
By splitting multi-table connection queries into multi-sliced connection queries and dispersing them to storage nodes for processing, the problem of multi-table connection queries occupying computing node resources in cloud-native databases is solved, and more efficient resource utilization and performance improvement is achieved.
Patent Information
- Application Number
- CN202311433696.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Priority Date
- 2023-07-28
- Filing Date
- 2023-10-31
- Publication Date
- 2025-02-14
AI Technical Summary
In a cloud-native database, multi-table connection query occupies too much transmission resources and processing resources of the computing node, resulting in performance bottlenecks.
By splitting the multi-table connection query into multi-shard connection query and scattering it to the storage node for processing, the computing node only needs to receive and combine the query results of the storage node to complete the final multi-table connection query.
It effectively reduces the use of transmission resources and processing resources of computing nodes, and improves the overall performance and efficiency of the database.
Smart Images

Figure CN119441285A_ABST
Abstract
Description
[0001] This disclosure claims priority to Chinese patent application No. 202310943415.1 filed on July 28, 2023, with invention name “A multi-table connection query method, device and computing device cluster”, the entire contents of which are incorporated by reference in this disclosure. Technical Field
[0002] The present disclosure relates to the field of database technology, and in particular to a method, system and device for multi-table connection query. Background Art
[0003] With the development of the Internet, the amount of data has exploded, but the storage space of traditional databases is limited, so databases under cloud-native architecture came into being. In databases under cloud-native architecture, data tables are divided into many shards and stored in different storage nodes.
[0004] In a cloud-native database, to perform a multi-table join query, it is generally necessary to aggregate all shards of the multiple data tables involved to the computing node, which then combines the shards to obtain the multiple data tables and then performs a join query on the multiple data tables.
[0005] The above processing method will occupy a large amount of transmission resources and processing resources of the computing node. Summary of the invention
[0006] The present disclosure provides a method, system and device for multi-table connection query, which can effectively reduce the occupation of transmission resources and processing resources of computing nodes.
[0007] In a first aspect, a method for multi-table connection query is provided, which is applied to a cloud native database system, the cloud native database system including a computing node and a plurality of storage nodes, the method including: the computing node receives a multi-table connection query instruction, and then determines at least one first shard connection information that needs to be processed by the storage node based on the table shards respectively included in the plurality of data tables corresponding to the multi-table connection query instruction, wherein each first shard connection information indicates a plurality of table shards for connection query. Then, the computing node sends shard connection query information corresponding to the first shard connection information to a target storage node corresponding to each first shard connection information, the shard connection query information including the first shard connection information and the query condition in the multi-table connection query instruction, and the target storage node stores a plurality of table shards indicated by the corresponding first shard connection information. Each target storage node performs a connection query in the plurality of table shards indicated by the received first shard connection information based on the query condition, and obtains a first shard query result. The computing node receives the first shard query result sent by each target storage node, and then determines the query result of the multi-table connection query instruction based on the received at least one first shard query result, and feeds back the multi-table connection query instruction based on the query result.
[0008] Table shards can be formally considered as part of the row data in a data table. The computing node splits a multi-table join query into several multi-shard join queries, and sends some or all of the multi-shard join queries to the storage node for processing. Multi-shard join queries are join queries on multiple table shards, and the processing logic of multi-shard join queries is exactly the same as that of multi-table join queries. The storage node feeds back the shard query results to the computing node, and the computing node obtains the final query results based on the shard query results.
[0009] In this way, part or all of the processing of multi-table join queries is distributed to the storage nodes, and there is no need to send all table shards to the computing nodes for join queries, which can greatly reduce the occupancy of the transmission resources and processing resources of the computing nodes.
[0010] In one possible implementation, the computing node determines at least one shard connection information based on table shards respectively included in multiple data tables corresponding to the multi-table join query instruction, wherein each shard connection information indicates multiple table shards used for the join query, and then the computing node determines at least one first shard connection information from the at least one shard connection information, wherein the multiple table shards indicated by the first shard connection information are stored in the same storage node.
[0011] The at least one shard connection information may also be referred to as theoretical shard connection information. The method for generating the theoretical shard connection information is to combine all table shards respectively included in the multiple data tables based on the specified combination logic to obtain all possible shard combinations (each shard in the shard combination belongs to a different data table). Each shard combination corresponds to one theoretical shard connection information, that is, multiple theoretical shard connection information is obtained. The multiple table shards in each theoretical shard connection information belong to different data tables.
[0012] In this way, after determining the first shard connection information, shard connection query information can be sent to the target storage node corresponding to the first shard connection information, and the target storage node will complete the multi-shard connection query operation. The multi-shard connection query can be handled by the storage node as much as possible, thereby reducing the occupancy of the computing node's transmission resources and processing resources.
[0013] In a possible implementation, the computing node determines at least one second shard connection information, wherein the multiple table shards indicated by the second shard connection information are stored in different storage nodes, and then the computing node obtains the multiple table shards indicated by the at least one second shard connection information from the multiple storage nodes corresponding to the at least one second shard connection information, and then the computing node performs a connection query on the multiple table shards indicated by the at least one second shard connection information based on the query conditions in the multi-table connection query instruction to obtain a second shard query result. Finally, the computing node combines the received at least one first shard query result and the second shard query result into the query result of the multi-table connection query instruction.
[0014] For the second shard connection information, no storage node stores data of all table shards indicated by the second shard connection information. The set composed of the first shard connection information and the second shard connection information is the theoretical shard connection information.
[0015] In this way, part of the query processing of multi-table connection queries is executed by the computing nodes, and part of the query processing is dispersed to the storage nodes. There is no need to send all table shards to the computing nodes for connection queries, which can greatly reduce the occupancy of the transmission resources and processing resources of the computing nodes.
[0016] In a possible implementation, the computing node combines the received multiple first shard query results into a query result of a multi-table join query instruction.
[0017] Each theoretical shard connection information corresponds to a storage node (the storage node stores the data of all table shards indicated by the theoretical shard connection information). Then, the computing node can combine the shard query results received from each storage node to obtain the final query result.
[0018] In this way, all query processing of multi-table join queries is dispersed to the storage nodes, and there is no need to send table shards to the computing nodes for join queries, which can greatly reduce the occupancy of transmission resources and processing resources of the computing nodes.
[0019] In one possible implementation, the computing node determines at least one storage node corresponding to each first shard connection information, and the storage node stores multiple table shards indicated by the corresponding first shard connection information. Then the computing node determines the target storage node from at least one storage node based on the resource occupancy information of the at least one storage node.
[0020] The computing node may obtain resource occupancy information of each storage node, and select a storage node with the least occupied resources as a target storage node based on the resource occupancy information. The resource occupancy information may be at least one of the following information: processor occupancy rate, total data volume corresponding to the currently processed read and write operations, and the number of currently processed read and write operations.
[0021] In this way, load balancing can be achieved to avoid some storage nodes having a heavy workload while some storage nodes are relatively idle.
[0022] In a possible implementation, after determining that the data volume of multiple data tables corresponding to the multi-table connection query instruction exceeds a preset threshold, the computing node determines the first shard connection information.
[0023] Based on the data type of the target column (the target column is the column involved in the multi-table connection query instruction in the corresponding data table), the data volume of each field corresponding to the target column can be determined. The product of the data volume and the number of rows is the data volume corresponding to the target column. The total data volume corresponding to all target columns in multiple data tables (that is, the data volume of multiple data tables corresponding to the multi-table connection query instruction) can be further determined. If the total data volume is greater than the data volume threshold, the computing node determines the first shard connection information and further performs the above-mentioned subsequent processing. If the data volume is less than the data volume threshold, the computing node obtains each table shard from the storage node, merges each table shard to obtain the corresponding data table, and then performs a multi-table connection query on the data table, and feedbacks the multi-table connection query instruction based on the query result.
[0024] In this way, when the amount of data to be processed is large, the query processing of multi-table join queries is dispersed to the storage nodes, which can effectively reduce the occupation of the transmission resources and processing resources of the computing nodes. When the amount of data to be processed is small, the computing nodes perform all the query processing of multi-table join queries. Because the computing nodes have strong processing capabilities, this can improve processing efficiency.
[0025] In a second aspect, a cloud native database system is provided, which includes a computing node and multiple storage nodes, and the computing node and the multiple storage nodes are used to execute the method provided by the above-mentioned first aspect and its possible implementation methods.
[0026] In a third aspect, a method for multi-table connection query is provided, which is applied to a cloud native database system, the cloud native database system includes a computing node and a plurality of storage nodes, the method is executed by the computing node, and the method includes: receiving a multi-table connection query instruction, and then determining at least one first shard connection information that needs to be processed by the storage node based on the table shards respectively included in the plurality of data tables corresponding to the multi-table connection query instruction, wherein each first shard connection information indicates a plurality of table shards for connection query. Then, shard connection query information corresponding to the first shard connection information is sent to the target storage node corresponding to each first shard connection information, the shard connection query information includes the first shard connection information and the query condition in the multi-table connection query instruction, and the target storage node stores the plurality of table shards indicated by the corresponding first shard connection information. Then, the first shard query result sent by each target storage node is received, and the query result of the multi-table connection query instruction is determined based on the received at least one first shard query result, and the multi-table connection query instruction is fed back based on the query result.
[0027] In this way, the computing node distributes part or all of the processing of multi-table connection queries to the storage node, and there is no need to send all table shards to the computing node for connection queries, which can greatly reduce the occupancy of the computing node's transmission resources and processing resources.
[0028] In one possible implementation, based on the table shards respectively included in the multiple data tables corresponding to the multi-table join query instruction, at least one shard connection information is determined, wherein each shard connection information indicates multiple table shards used for the join query, and then at least one first shard connection information is determined from the at least one shard connection information, wherein the multiple table shards indicated by the first shard connection information are stored in the same storage node.
[0029] In this way, after determining the first shard connection information, shard connection query information can be sent to the target storage node corresponding to the first shard connection information, and the target storage node will complete the multi-shard connection query operation. The multi-shard connection query can be handled by the storage node as much as possible, thereby reducing the occupancy of the computing node's transmission resources and processing resources.
[0030] In a possible implementation, at least one second shard connection information is determined, wherein the multiple table shards indicated by the second shard connection information are stored in different storage nodes, and then the multiple table shards indicated by the at least one second shard connection information are obtained from the multiple storage nodes corresponding to the at least one second shard connection information, and then based on the query conditions in the multi-table connection query instruction, a connection query is performed on the multiple table shards indicated by the at least one second shard connection information to obtain a second shard query result. Finally, the received at least one first shard query result and the second shard query result are combined into the query result of the multi-table connection query instruction.
[0031] In this way, part of the query processing of multi-table connection queries is executed by the computing nodes, and part of the query processing is dispersed to the storage nodes. There is no need to send all table shards to the computing nodes for connection queries, which can greatly reduce the occupation of the transmission resources and processing resources of the computing nodes.
[0032] In a possible implementation, the received multiple first shard query results are combined into a query result of a multi-table join query instruction.
[0033] In this way, all query processing of multi-table join queries is dispersed to the storage nodes, and there is no need to send table shards to the computing nodes for join queries, which can greatly reduce the occupancy of transmission resources and processing resources of the computing nodes.
[0034] In one possible implementation, at least one storage node corresponding to each first shard connection information is determined, the storage node stores multiple table shards indicated by the corresponding first shard connection information, and then a target storage node is determined from at least one storage node based on resource occupancy information of the at least one storage node.
[0035] In this way, load balancing can be achieved to avoid some storage nodes having a heavy workload while some storage nodes are relatively idle.
[0036] In a possible implementation, after determining that the data volume of multiple data tables corresponding to the multi-table connection query instruction exceeds a preset threshold, the first shard connection information is determined.
[0037] In this way, when the amount of data to be processed is large, the query processing of multi-table join queries is dispersed to the storage nodes, which can effectively reduce the occupation of the transmission resources and processing resources of the computing nodes. When the amount of data to be processed is small, the computing nodes perform all the query processing of multi-table join queries. Because the computing nodes have strong processing capabilities, this can improve processing efficiency.
[0038] In a fourth aspect, a method for multi-table join query is provided, which is applied to a cloud native database system, the cloud native database system includes a computing node and multiple storage nodes, the method is executed by the storage node, and the method includes: receiving shard connection query information sent by the computing node, the shard connection query information includes first shard connection information and query conditions, multiple table shards indicated by the first shard connection information are stored in the storage node, and then based on the query conditions, a join query is performed in the multiple table shards indicated by the first shard connection information to obtain a first shard query result, and finally the first shard query result is sent to the computing node corresponding to the storage node.
[0039] In this way, part or all of the processing of multi-table join queries is distributed to the storage nodes, and there is no need to send all table shards to the computing nodes for join queries, which can greatly reduce the occupancy of the transmission resources and processing resources of the computing nodes.
[0040] In a fifth aspect, a device for multi-table join query is provided, the device comprising at least one module, and the at least one module is used to implement the method provided by the third aspect and its possible implementation methods.
[0041] In a sixth aspect, a device for multi-table join query is provided, the device comprising at least one module, and the at least one module is used to implement the method provided by the fourth aspect and its possible implementation methods.
[0042] In the seventh aspect, a computing device cluster is provided, comprising at least one computing device, each computing device comprising a processor and a memory; the processor of at least one computing device is used to execute instructions stored in the memory of at least one computing device, so that the computing device cluster executes the method provided by the above-mentioned first aspect and its possible implementation method.
[0043] In an eighth aspect, a computer device is provided, the computer device comprising a memory and a processor, the memory being used to store computer instructions. The processor executes the computer instructions stored in the memory, so that the computer device executes the method provided in the third aspect and possible implementations thereof.
[0044] In a ninth aspect, a computer device is provided, the computer device comprising a memory and a processor, the memory being used to store computer instructions. The processor executes the computer instructions stored in the memory, so that the computer device executes the method provided in the fourth aspect and possible implementations thereof.
[0045] In a tenth aspect, a computer-readable storage medium is provided, which includes computer program instructions. When the computer program instructions are executed by a computing device cluster, the computing device cluster executes the method provided by the above-mentioned first aspect and its possible implementation methods.
[0046] In the eleventh aspect, a computer-readable storage medium is provided, which stores a computer program code. When the computer program code is executed by a computer device, the computer device executes the method provided by the third aspect and its possible implementation methods.
[0047] In a twelfth aspect, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a computer program code. When the computer program code is executed by a computer device, the computer device executes the method provided in the fourth aspect and its possible implementation methods.
[0048] In a thirteenth aspect, a computer program product comprising instructions is provided. When the instructions are executed by a computing device cluster, the computing device cluster executes the method provided by the first aspect and its possible implementation manner.
[0049] In a fourteenth aspect, a computer program product is provided, which includes a computer program code. When the computer program code is executed by a computer device, the computer device executes the method provided by the third aspect and its possible implementation method.
[0050] In a fifteenth aspect, a computer program product is provided, which includes a computer program code. When the computer program code is executed by a computer device, the computer device executes the method provided in the fourth aspect and its possible implementation methods. BRIEF DESCRIPTION OF THE DRAWINGS
[0051] Figure 1 It is a schematic diagram of data table sharding provided by an embodiment of the present disclosure;
[0052] Figure 2 is a structural diagram of a cloud native database system provided by an embodiment of the present disclosure;
[0053] Figure 3 is a structural diagram of a cloud native database system provided by an embodiment of the present disclosure;
[0054] Figure 4 It is a flow chart of a method for multi-table connection query provided by an embodiment of the present disclosure;
[0055] Figure 5 is a flow chart of a method for determining slice connection information to be sent provided by an embodiment of the present disclosure;
[0056] Figure 6 It is a structural schematic diagram of a device for multi-table connection query provided by an embodiment of the present disclosure;
[0057] Figure 7It is a structural schematic diagram of a device for multi-table connection query provided by an embodiment of the present disclosure;
[0058] Figure 8 is a schematic diagram of a computing device provided by an embodiment of the present disclosure;
[0059] Fig. 9 is a schematic diagram of a computing device cluster provided by an embodiment of the present disclosure;
[0060] Fig.10 It is a schematic diagram of a computing device cluster provided by an embodiment of the present disclosure. DETAILED DESCRIPTION
[0061] In order to make the objectives, technical solutions and advantages of the present disclosure more clear, the embodiments of the present disclosure will be further described in detail below with reference to the accompanying drawings.
[0062] The concepts involved in this disclosure are explained below:
[0063] database
[0064] A database is a collection of data with a specified data structure. The data in a database is generally stored in a two-dimensional table, also called a data table.
[0065] Multi-table join query
[0066] Multi-table join query or join query is an operation to integrate and feedback the contents of multiple data tables in a database. The corresponding instruction can be called a multi-table join query instruction, which is a Structured Query Language (SQL) statement. SQL is a database operation and programming language used to access data and query, update and manage databases.
[0067] The form of multi-table connection query instructions can be as follows:
[0068] SELECT target_column FROM table_A JOIN table_B ON A_column=B_column
[0069] In this instruction, "SELECT" is the instruction name, indicating that this instruction is used for query. "target_column" is the name of the target column (or target attribute). The target column can be considered as the column involved in the instruction. There can be multiple target columns. This instruction can query multiple target columns in the table. The value of this field can also be "*", indicating that the data in all columns of the query data table are queried. "FROM" and "JOIN" are fixed fields in the instruction, which are used to lead to multiple data tables targeted by the query. "table_A" and "table_B" are the names of these multiple data tables. "ON" is a fixed field in the instruction, which is used to lead to the connection conditions of multiple data tables. "A_column=B_column" is the connection condition, which means that when the A_column attribute of a row of data in table_A is equal to the B_column attribute of a row of data in table_B, the two rows of data are "connected", that is, the two rows of data are combined into a row of data as a row of data in the query result. A_column and B_column can be called reference attributes.
[0070] Table slice
[0071] Table shards can be formally considered as a portion of the row data in a data table. For example, a data table has a total of 1,000 rows. The data table is divided into 20 table shards, and each table shard contains 50 rows. Figure 1 As shown, the data table is divided into two table slices, namely sliceX (the data included in the upper dotted box) and sliceY (the data included in the lower dotted box), and each table slice has 5 rows of data.
[0072] The embodiment of the present disclosure provides a method for multi-table join query. The method can be applied to a cloud native database system, which may include a computing server (or computing node) and a storage server (or storage node). The structure of the cloud native database system is as follows: Figure 2 The following is an introduction to each component of the cloud native database system:
[0073] The computing node 210 may be an independent computer device, a virtual machine, or a computer cluster, etc. The computing node is user-oriented, and can parse the user's operation instructions, execute the operation instructions, and finally feed back the results to the user. The process of executing the operation instructions may be writing data to or reading data from the storage node, etc. In the cloud native database system, a computing node can be allocated to each user.
[0074] The storage node 220 may be a computer device with powerful storage capacity and some basic processing capabilities. The storage node is used to store data and read and write data under the control of the computing node.
[0075] In a cloud-native database system, when storing a data table, the data table is divided into multiple table shards, and then the table shards are dispersed and stored in multiple storage nodes. In addition, a certain redundancy mechanism can be set to copy each table shard several times and store them in different storage nodes, such as Figure 3 As shown. The execution method of multi-table connection query instructions under this database architecture is very different from that under the traditional database architecture. The embodiment of the present disclosure provides a method for multi-table connection query, which can make good use of the processing resources of storage nodes in the cloud native database system and reduce the resource occupation of computing nodes. Figure 4 As shown, the processing flow of the method includes the following steps:
[0076] Step 401: A computing node receives a multi-table connection query instruction.
[0077] When a user wants to perform a multi-table connection query, he can enter a multi-table connection query instruction through the user device, and the user device sends the multi-table connection query instruction to the cloud native database system. The content of the instruction has been introduced above and can be:
[0078] SELECT target_column FROM table_A JOIN table_B ON A_column=B_column
[0079] In the cloud native database system, the computing node is responsible for receiving and parsing the multi-table connection query instructions sent by the user device. The syntax parser in the computing node parses the instruction and obtains the various fields in the instruction. Based on the fixed fields such as "SELECT" and "JOIN" in the instruction, it can be determined that the instruction is a query instruction, and it is a multi-table connection query instruction. Then, the query conditions in the multi-table connection query instruction can be determined. The query conditions may include the names of the multiple data tables to be connected (i.e., table_A and table_B), the names of the reference attributes in each data table (i.e., attribute A_column in data table table_A and attribute B_column in data table table_B), and the name of the target attribute (i.e., target_column).
[0080] Step 402: The computing node determines at least one shard connection information to be sent to the storage node for processing based on the table shards respectively included in the multiple data tables corresponding to the multi-table connection query instruction.
[0081] In the computing node, the relevant information of each data table in the database system can be recorded, including all table shards included in the data table, the storage nodes where the table shards are located, etc. A corresponding relationship table between data tables, table shards, and storage nodes can be established in the computing node, as shown in Table 1:
[0082] Table 1
[0083]
[0084]
[0085] After parsing the multi-table connection query instruction, the computing node can obtain the name of the data table carried in it. Then, in the above correspondence table, the corresponding table shards are searched to determine all the table shards of the data table involved in the multi-table connection query instruction (the storage nodes recorded in the correspondence table will be used in the subsequent processing). Furthermore, the computing node can determine the shard connection information to be sent based on these table shards. The idea of this processing is as follows:
[0086] Split a multi-table connection query into several multi-shard connection queries, and hand over some or all of them to the storage node for processing. A multi-shard connection query is a connection query for multiple table shards. Because a table shard is actually a relatively small data table, the processing logic of a multi-shard connection query is exactly the same as that of a multi-table connection query. The only difference is that the amount of data in a table shard is much smaller than that in a data table. Each multi-shard connection query handed over to the storage node for processing corresponds to a shard connection information to be sent (which may be referred to as the first shard connection information). The shard connection information may include identifiers of multiple table shards, which are used to indicate that the storage node performs a connection query on these multiple table shards. The multiple table shards for connection query should belong to different data tables, so the multiple table shards indicated by the shard connection information belong to different data tables.
[0087] For example, a multi-table join query is performed on the above data tables table_A and table_B (see Table 1). Table_A includes table slices slice11 and slice12, and table_B includes table slices slice21, slice22, and slice23. The corresponding slice connection information may include slice11 join slice21, slice11 join slice22, slice11join slice23, slice12 join slice21, slice12 join slice22, and slice12 join slice23, these 6 shard connection information correspond to 6 multi-shard connection queries, which are all the multi-shard connection queries that can be obtained by splitting the above multi-table connection query. That is to say, by completing these 6 multi-shard connection queries and getting 6 shard query results, you can get the query result of the above multi-table connection query by combining them. Furthermore, the computing node can use part or all of the 6 shard connection information as the shard connection information to be sent based on the storage status of the table shards of the storage node or some preset business logic.
[0088] In practical applications, the computing node can first determine various possible combinations based on the determined table shards, obtain various possible shard connection information (also called theoretical shard connection information), and then determine the shard connection information to be sent based on these possible shard connection information and the storage nodes corresponding to the shards, and determine that all shards indicated by any shard connection information to be sent correspond to the same storage node. There are many possibilities for the specific processing logic here, which will be explained in detail in the following content.
[0089] Step 403: The computing node sends shard connection query information to the target storage node corresponding to each shard connection information to be sent.
[0090] The shard connection query information includes the query conditions and shard connection information in the multi-table connection query instruction. The query conditions include the connection conditions of the data table (i.e., "A_column=B_column") and the target column (i.e., target_column). In addition, if the identifier of the table shard in the shard connection information cannot uniquely locate the data table to which the table shard belongs, the identifier of the data table may also be included in the query conditions to locate the table shard through the identifier of the data table and the identifier of the table shard.
[0091] Each shard connection information to be sent corresponds to at least one storage node, and any storage node corresponding to the shard connection information stores all shards indicated by the shard connection information. For shard connection information corresponding to only one storage node, the corresponding shard connection query information is directly sent to the storage node (the above-mentioned target storage node). For shard connection information corresponding to multiple storage nodes, the computing node can select a storage node (i.e., the above-mentioned target storage node) from multiple storage nodes based on a certain selection rule, and send the shard connection query information to the storage node. The selection rule can be load balancing, random, polling, etc. Taking load balancing as an example, the computing node can obtain the resource occupancy information of each storage node, and select the storage node with the least occupied resources as the target storage node based on the resource occupancy information. The resource occupancy information can be at least one of the processor occupancy rate, the total amount of data corresponding to the read and write operations currently being processed, and the number of read and write operations currently being processed.
[0092] For example, for Figure 3 In the example shown, the slice connection information slice11 join slice21 to be sent, and the storage nodes storing slice11 and slice21 are storage node 1 and storage node 2. The computing node checks that the processor occupancy rates of the two storage nodes are 40% and 66% respectively, and then selects storage node 1 with a lower processor occupancy rate as the target storage node, and sends the slice connection information slice11 join slice21 and the query conditions to storage node 1.
[0093] Step 404: The target storage node performs a connection query in the multiple table shards indicated by the shard connection information based on the query condition to obtain a shard query result.
[0094] The storage node reads the corresponding table shard locally based on the identifier of the table shard in the shard connection information, that is, the table shard to be queried for connection. Alternatively, the storage node may read the corresponding table shard locally based on the identifier of the table shard in the shard connection information and the identifier of the data table in the query condition.
[0095] Based on the connection conditions and target columns in the query conditions, the storage node performs a connection query on the multiple table shards read to obtain the shard query results. Table shards are actually relatively small data tables. The processing logic of connecting multiple table shards is the same as that of connecting multiple data tables. The following describes the specific operation steps of connecting table shards:
[0096] The data table named stu records various information about students. The data table has four columns, namely student ID (stu_id), student name (stu_name), date of birth (stu_age) and gender (stu_sex). A table slice (referred to as sliceA) of the data table is shown in Table 2:
[0097] Table 2
[0098] stu_id stu_name stu_age stu_sex 01 Zhao Lei 2000-10-03 male 02 Sun Dian 2001-03-05 female 03 Li Feng 2000-11-08 male 04 Zhou Yun 2000-12-11 female 05 Wu Mei 2001-03-25 female
[0099] The data table named sc records the students' grades. The data table has three columns, namely the student ID (sc_stuid), the course ID (sc_id) and the grade (sc_score). A table slice (referred to as sliceB) of the data table is shown in Table 3:
[0100] Table 3
[0101] sc_stuid sc_id sc_score 01 01 80 01 02 89 01 03 79 02 01 91 02 02 85 02 03 66
[0102] The target storage node performs a join query operation on the sliceA and sliceB. When the user needs to feedback the data in all columns, the multi-table join query instruction sent to the computing node may be: SELECT * FROM stu JOIN sc ON stu_id = sc_stuid. The query condition sent by the computing node to the target storage node may include information such as "*" and "stu_id = sc_stuid".
[0103] The join query operation process is as follows: the stu_id attribute in the first row of data "01, Zhao Lei, 2000-10-03, Male" in sliceA is "01", and "01" is found in all the values corresponding to the sc_stuid attribute in sliceB to determine the row where "01" is located (the first row in Table 2), and then these two rows of data are joined to obtain a row of query results "01, Zhao Lei, 2000-10-03, Male, 01, 01, 80". The above operation is performed for each row of data in sliceA, and the complete shard query result can be shown in Table 4:
[0104] Table 4
[0105] stu_id stu_name stu_age stu_sex sc_stuid sc_id sc_score 01 Zhao Lei 2000-10-03 male 01 01 80 01 Zhao Lei 2000-10-03 male 01 02 89 01 Zhao Lei 2000-10-03 male 01 03 79 02 Sun Dian 2001-03-05 female 02 01 91 02 Sun Dian 2001-03-05 female 02 02 85 02 Sun Dian 2001-03-05 female 02 03 66
[0106] When the user needs to feedback the data in the target column (for example, stu_id and stu_name in the data table stu and sc_id and sc_score in the data table sc are the target columns), the multi-table join query instruction sent to the computing node may be: SELECT stu_id, stu_name, sc_id, sc_score FROM stu JOIN sc ON stu_id=sc_stuid. The query conditions sent by the computing node to the target storage node may include information such as "stu_id, stu_name, sc_id, sc_score" and "stu_id=sc_stuid".
[0107] The join query operation process is similar to the above process. The difference is that the final query result only includes the data of the target column. The final shard query result can be shown in Table 5:
[0108] Table 5
[0109] stu_id stu_name sc_id sc_score 01 Zhao Lei 01 80 01 Zhao Lei 02 89 01 Zhao Lei 03 79 02 Sun Dian 01 91 02 Sun Dian 02 85 02 Sun Dian 03 66
[0110] Step 405: The target storage node sends the shard query result to the computing node.
[0111] Each target storage node that performs a multi-shard connection query operation sends the shard query results to the corresponding computing node.
[0112] Step 406: The computing node determines the query result of the multi-table join query instruction based on the received shard query result.
[0113] After receiving the shard query results fed back by each target storage node, the computing node determines the final query result based on these shard query results. For example, in some cases, the computing node can combine the received shard query results as the final query result; in some cases, the computing node gives a part of the shard connection information (which can be called the first shard connection information) to the storage node for multi-shard connection query, and performs multi-shard connection query based on another part of the shard connection information (which can be called the second shard connection information), combines the received shard query result (which can be called the first shard query result) and the shard query result (which can be called the second shard query result) of its own query to obtain the final query result, and so on. Based on the different specific processing methods of step 402, the processing methods for determining the final query result here are also different. In the following content, the specific processing of step 406 will be described in detail in combination with the specific processing of step 402.
[0114] Step 407: The computing node provides feedback to the multi-table connection query instruction based on the query result.
[0115] Optionally, in a cloud-native database system, when the amount of data queried by a multi-table join query instruction is large, the above-mentioned process can be used, and the storage node performs a shard join query, and then the computing node summarizes it. When the amount of data queried by a multi-table join query instruction is small, the computing node can merge the shards of each table to obtain the corresponding data table, and then perform a multi-table join query on the data table. The corresponding processing method can be as follows:
[0116] In the computing node, relevant information of each data table can be recorded, including all table shards included in the data table, the data type of each column of the data table, the number of rows in the data table, etc.
[0117] After parsing the multi-table connection query instruction, the computing node can obtain the name of the data table and the name of the target column (the target column is the column involved in the multi-table connection query instruction in the corresponding data table) carried therein. Then, the data type of the target column in each data table can be determined, and the number of rows in each data table can be determined. Based on the data type of the target column, the data volume of each field corresponding to the target column can be determined, and the product of the data volume and the number of rows is the data volume corresponding to the target column. Further, the total data volume corresponding to all target columns in multiple data tables (that is, the data volume of multiple data tables corresponding to the multi-table connection query instruction) can be determined. Then, the total data volume can be compared with the preset data volume threshold. If the total data volume is greater than the data volume threshold, the processing of steps 402-407 is further performed. If the data volume is less than the data volume threshold, the computing node obtains each table fragment from the storage node, merges each table fragment to obtain the corresponding data table, and then performs a multi-table connection query on the data table, and feedbacks the multi-table connection query instruction based on the query result.
[0118] In the disclosed embodiment, the computing node splits the multi-table connection query into several multi-shard connection queries, which are processed by the storage node. The storage node feeds back the shard query results to the computing node, and the computing node obtains the final query result based on the shard query results. In this way, part or all of the processing of the multi-table connection query is dispersed to the storage node, and there is no need to send all table shards to the computing node for connection query, which can well reduce the occupation of the computing node transmission resources and processing resources.
[0119] In the embodiment of the present disclosure, when performing the above step 402 to determine the shard connection information to be sent to the storage node for processing, the following method can be used: Figure 5 The processing method shown includes the following steps:
[0120] Step 501: The computing node determines multiple theoretical shard connection information based on all table shards respectively included in multiple data tables corresponding to the multi-table connection query instruction.
[0121] Based on the specified combination logic, all table shards respectively included in the multiple data tables are combined to obtain all possible shard combinations (each shard in the shard combination belongs to a different data table), each shard combination corresponds to a theoretical shard connection information, that is, multiple theoretical shard connection information is obtained. The multiple table shards in each theoretical shard connection information belong to different data tables.
[0122] There are many possible situations for the above combinational logic, and several of them are described below:
[0123] In case 1, the number of multiple table shards indicated by the theoretical shard connection information is equal to the number of multiple data tables corresponding to the multi-table connection query instruction. That is, the multiple table shards indicated by the theoretical shard connection information are obtained by selecting one table shard from each of all the data tables corresponding to the multi-table connection query instruction.
[0124] In this case, the computing node can hand over the connection query to the storage node as much as possible.
[0125] For example, the number of data tables included in the multi-table join query instruction is 2, table_A contains table slices 11 and 12, and table_B contains table slices 21, 22, and 23. The generated theoretical slice join information includes:
[0126] slice11 join slice21;
[0127] slice11 join slice22;
[0128] slice11 join slice23;
[0129] slice12 join slice21;
[0130] slice12 join slice22;
[0131] slice12 join slice23.
[0132] For another example, the number of data tables included in the multi-table join query instruction is 3, table_A includes table slices 11 and 12, table_B includes table slices 21, 22 and 23, and table_C includes table slices 31 and 32. The generated theoretical slice join information includes:
[0133] slice11 join slice21 join slice31;
[0134] slice11 join slice21 join slice32;
[0135] slice11 join slice22 join slice31;
[0136] slice11 join slice22 join slice32;
[0137] slice11 join slice23 join slice31;
[0138] slice11 join slice23 join slice32;
[0139] slice12 join slice21 join slice31;
[0140] slice12 join slice21 join slice32;
[0141] slice12 join slice22 join slice31;
[0142] slice12 join slice22 join slice32;
[0143] slice12 join slice23 join slice31;
[0144] slice12 join slice23 join slice32.
[0145] For situation 1, the processing of step 406 may include:
[0146] If each theoretical shard connection information corresponds to a storage node (the storage node stores the data of all table shards indicated by the theoretical shard connection information), then the computing node can combine the shard query results received from each storage node to obtain the final query result. If some theoretical shard connection information has no corresponding storage node (that is, no storage node stores the data of all table shards indicated by the theoretical shard connection information), then for each theoretical shard connection information that has no corresponding storage node, the computing node obtains all table shards contained in the theoretical shard connection information from the storage node, and then completes the multi-shard connection query operation to obtain the corresponding shard query result. For the theoretical shard connection information that corresponds to a storage node, the storage node can perform the corresponding multi-shard connection query and send the shard query result to the computing node. In this way, for all theoretical shard connection information, the computing node obtains the corresponding shard query results, and the computing node can combine these shard query results to obtain a combined query result as the final query result.
[0147] Case 2: The number of multiple table shards indicated by the theoretical shard connection information is less than the number of multiple data tables corresponding to the multi-table connection query instruction. That is, the multiple table shards indicated by the theoretical shard connection information are obtained by selecting one table shard each from some of the data tables corresponding to the multi-table connection query instruction.
[0148] In this case, the computing nodes themselves also have to share more connection query processing.
[0149] For example, the number of data tables included in the multi-table join query instruction is 3, table_A contains table slices 11 and 12, table_B contains table slices 21, 22 and 23, and table_C contains table slices 31 and 32. Only the table slices corresponding to table_A and table_B are generated into theoretical slice join information, and the generated theoretical slice join information includes:
[0150] slice11 join slice21;
[0151] slice11 join slice22;
[0152] slice11 join slice23;
[0153] slice12 join slice21;
[0154] slice12 join slice22;
[0155] slice12 join slice23.
[0156] For the situation described in this example, the processing of step 406 may include:
[0157] The computing node can obtain the shard query results corresponding to all theoretical shard connection information by using the processing method of step 406 in case 1, and combine these shard query results to obtain the combined query result. In addition, the computing node obtains each table shard of table_C from the storage node, and combines the table shards to obtain table_C. Then, the computing node can perform a connection query process on the combined query result and table_C to obtain the final query result.
[0158] For another example, the number of data tables included in the multi-table connection query instruction is 4, table_A includes table slices 11 and 12, table_B includes table slices 21, 22 and 23, table_C includes table slices 31 and 32, and table_D includes table slices 41, 42 and 43. The table slices corresponding to table_A and table_B are used to generate theoretical slice connection information, and the generated theoretical slice connection information includes:
[0159] slice11 join slice21;
[0160] slice11 join slice22;
[0161] slice11 join slice23;
[0162] slice12 join slice21;
[0163] slice12 join slice22;
[0164] slice12 join slice23.
[0165] Generate theoretical shard connection information for the table shards corresponding to table_C and table_D. The generated theoretical shard connection information includes:
[0166] slice31 join slice41;
[0167] slice31 join slice42;
[0168] slice31 join slice43;
[0169] slice32 join slice41;
[0170] slice32 join slice42;
[0171] slice32 join slice43.
[0172] For the situation described in this example, the processing of step 406 may include:
[0173] The theoretical shard connection information corresponding to table_A and table_B constitutes a shard connection information set M, and the theoretical shard connection information corresponding to table_C and table_D constitutes a shard connection information set N. The computing node can adopt the processing method of step 406 in situation 1 to obtain the shard query results corresponding to the shard connection information set M and the shard connection information set N. All shard query results corresponding to the shard connection information set M are combined to obtain a first combined query result. All shard query results corresponding to the shard connection information set N are combined to obtain a second combined query result. Then the computing node performs connection query processing on the first combined query result and the second combined query result to obtain the final query result.
[0174] Similar processing methods can be used for any number of data tables, and will not be described in detail here.
[0175] Step 502: The computing node determines at least one shard connection information to be sent to the storage node for processing based on multiple theoretical shard connection information.
[0176] For each theoretical shard connection information, the computing node can find out the storage nodes corresponding to all table shards in the theoretical shard connection information by looking up the correspondence table of data tables, table shards, and storage nodes. Then the computing node can determine whether there is an intersection between the storage nodes corresponding to each table shard, that is, whether there is a storage node that stores all the table shards indicated by the theoretical shard connection information. If such a storage node exists, the storage node is used as the storage node corresponding to the theoretical shard connection information, and the theoretical shard connection information is determined as the shard connection information to be sent.
[0177] For example, for Figure 3 In the example shown, a corresponding relationship table of data tables, table shards, and storage nodes can be established in the computing node, as shown in Table 1:
[0178] The method for judging whether the theoretical shard connection information slice11 join slice21 is the shard connection information to be sent is as follows: by searching the above correspondence table, it can be concluded that both storage node 1 and storage node 2 store table shard slice11 and table shard slice21, so the theoretical shard connection information slice11 join slice21 is determined as the shard connection information to be sent, and the storage nodes corresponding to the theoretical shard connection information slice11 join slice21 are recorded as storage node 1 and storage node 2. Similarly, it can be judged whether each theoretical shard connection information is the shard connection information to be sent, and the storage node corresponding to the theoretical shard connection information is recorded. The shard connection information to be sent and the corresponding storage node are recorded in the correspondence table of the shard connection information to be sent and the storage node.
[0179] The corresponding relationship table of the shard connection information to be sent and the storage node can be shown in Table 6:
[0180] Table 6
[0181] Slice connection information to be sent Storage Node slice11 join slice21 1、2 slice11join slice22 1、2 slice11join slice23 3 slice12join slice21 4 slice12join slice22 5 slice12join slice23 6
[0182] Based on the same technical concept, the embodiment of the present disclosure provides a device for multi-table connection query, which can be applied to the above computing nodes, such as Figure 6 As shown, the device comprises:
[0183] A receiving module 610 is used to receive a multi-table connection query instruction;
[0184] A determination module 620 is used to determine at least one first shard connection information based on the table shards respectively included in the multiple data tables corresponding to the multi-table connection query instruction, wherein each first shard connection information indicates multiple table shards for connection query;
[0185] A sending module 630 is used to send shard connection query information corresponding to the first shard connection information to a target storage node corresponding to each first shard connection information, where the shard connection query information includes the first shard connection information and a query condition in a multi-table connection query instruction, and the target storage node stores multiple table shards indicated by the corresponding first shard connection information;
[0186] A result module 640 is used to receive the first shard query result sent by each target storage node, and determine the query result of the multi-table connection query instruction based on at least one first shard query result received;
[0187] The feedback module 650 is used to provide feedback on the multi-table connection query instruction based on the query result.
[0188] In one possible implementation, the determination module 620 is used to: determine at least one shard connection information based on the table shards respectively included in the multiple data tables corresponding to the multi-table connection query instruction, wherein each shard connection information indicates multiple table shards used for the connection query; determine at least one first shard connection information from the at least one shard connection information, wherein the multiple table shards indicated by the first shard connection information are stored in the same storage node.
[0189] In one possible implementation, the determination module 620 is further used to determine at least one second shard connection information, wherein the multiple table shards indicated by the second shard connection information are stored in different storage nodes; the receiving module 610 is further used to obtain the multiple table shards indicated by the at least one second shard connection information from the multiple storage nodes corresponding to the at least one second shard connection information; the device also includes a query module 660, which is used to perform a connection query on the multiple table shards indicated by the at least one second shard connection information based on the query conditions in the multi-table connection query instruction to obtain a second shard query result; the result module 640 is used to combine the received at least one first shard query result and the second shard query result into a query result of the multi-table connection query instruction.
[0190] In a possible implementation, the result module 640 is used to combine the received multiple first shard query results into a query result of the multi-table connection query instruction.
[0191] In a possible implementation, the determination module 620 is also used to: determine at least one storage node corresponding to each first shard connection information, the storage node storing multiple table shards indicated by the corresponding first shard connection information; and determine a target storage node from at least one storage node based on resource occupancy information of at least one storage node.
[0192] In a possible implementation, the determination module 620 is further configured to determine whether the data volumes of the multiple data tables corresponding to the multi-table connection query instruction exceed a preset threshold.
[0193] In the disclosed embodiment, the computing node splits the multi-table connection query into several multi-shard connection queries, which are processed by the storage node. The storage node feeds back the shard query results to the computing node, and the computing node obtains the final query result based on the shard query results. In this way, part or all of the processing of the multi-table connection query is dispersed to the storage node, and there is no need to send all table shards to the computing node for connection query, which can well reduce the occupation of the computing node transmission resources and processing resources.
[0194] Among them, the receiving module 610, the determining module 620, the sending module 630, the result module 640, the feedback module 650 and the query module 660 can all be implemented by software, or can be implemented by hardware. Exemplarily, the implementation of the receiving module 610 is introduced below by taking the receiving module 610 as an example. Similarly, the implementation of the determining module 620, the sending module 630, the result module 640, the feedback module 650 and the query module 660 can refer to the implementation of the receiving module 610.
[0195] As an example of a software functional unit, the receiving module 610 may include code running on a computing instance. Among them, the computing instance may include at least one of a physical host (computing device), a virtual machine, and a container. Further, the above-mentioned computing instance may be one or more. For example, the receiving module 610 may include code running on multiple hosts / virtual machines / containers. It should be noted that the multiple hosts / virtual machines / containers used to run the code may be distributed in the same region (region) or in different regions. Furthermore, the multiple hosts / virtual machines / containers used to run the code may be distributed in the same availability zone (AZ) or in different AZs, each AZ including a data center or multiple data centers with similar geographical locations. Among them, usually a region may include multiple AZs.
[0196] Similarly, multiple hosts / virtual machines / containers used to run the code can be distributed in the same virtual private cloud (VPC) or in multiple VPCs. Usually, a VPC is set up in a region. For cross-region communication between two VPCs in the same region and between VPCs in different regions, a communication gateway needs to be set up in each VPC to achieve interconnection between VPCs through the communication gateway.
[0197] As an example of a hardware functional unit, the receiving module 610 may include at least one computing device, such as a server, etc. Alternatively, the receiving module 610 may also be a device implemented using an application-specific integrated circuit (ASIC) or a programmable logic device (PLD). The PLD may be a complex programmable logical device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL) or any combination thereof.
[0198] The multiple computing devices included in the receiving module 610 can be distributed in the same region or in different regions. The multiple computing devices included in the receiving module 610 can be distributed in the same AZ or in different AZs. Similarly, the multiple computing devices included in the receiving module 610 can be distributed in the same VPC or in multiple VPCs. The multiple computing devices can be any combination of computing devices such as servers, ASICs, PLDs, CPLDs, FPGAs, and GALs.
[0199] It should be noted that, in other embodiments, the receiving module 610, the determining module 620, the sending module 630, the result module 640, the feedback module 650 and the query module 660 can be used for any step in the multi-table connection query method in the computing node, and the steps that the receiving module 610, the determining module 620, the sending module 630, the result module 640, the feedback module 650 and the query module 660 are responsible for implementing can be specified as needed. The receiving module 610, the determining module 620, the sending module 630, the result module 640, the feedback module 650 and the query module 660 respectively implement different steps in the multi-table connection query method to realize the full functions of the device for executing multi-table connection query on the computing node.
[0200] Based on the same technical concept, the embodiment of the present disclosure provides a device for multi-table connection query, which can be applied to the above storage node, such as Figure 7 As shown, the device comprises:
[0201] A receiving module 710 is used to receive shard connection query information sent by a computing node, where the shard connection query information includes first shard connection information and a query condition, and a plurality of table shards indicated by the first shard connection information are stored in a storage node;
[0202] A query module 720, configured to perform a connection query in the plurality of table shards indicated by the first shard connection information based on the query condition, and obtain a first shard query result;
[0203] The sending module 730 is used to send the first shard query result to the computing node.
[0204] In the disclosed embodiment, the computing node splits the multi-table connection query into several multi-shard connection queries, which are processed by the storage node. The storage node feeds back the shard query results to the computing node, and the computing node obtains the final query result based on the shard query results. In this way, part or all of the processing of the multi-table connection query is dispersed to the storage node, and there is no need to send all table shards to the computing node for connection query, which can well reduce the occupation of the computing node transmission resources and processing resources.
[0205] Among them, the receiving module 710, the query module 720 and the sending module 730 can all be implemented by software, or can be implemented by hardware. Exemplarily, the implementation of the receiving module 710 is introduced below by taking the receiving module 710 as an example. Similarly, the implementation of the query module 720 and the sending module 730 can refer to the implementation of the receiving module 710.
[0206] As an example of a software functional unit, the receiving module 710 may include code running on a computing instance. Among them, the computing instance may include at least one of a physical host (computing device), a virtual machine, and a container. Further, the above-mentioned computing instance may be one or more. For example, the receiving module 710 may include code running on multiple hosts / virtual machines / containers. It should be noted that the multiple hosts / virtual machines / containers used to run the code may be distributed in the same region (region) or in different regions. Furthermore, the multiple hosts / virtual machines / containers used to run the code may be distributed in the same availability zone (AZ) or in different AZs, each AZ including one data center or multiple data centers with similar geographical locations. Among them, usually a region may include multiple AZs.
[0207] Similarly, multiple hosts / virtual machines / containers used to run the code can be distributed in the same virtual private cloud (VPC) or in multiple VPCs. Usually, a VPC is set up in a region. For cross-region communication between two VPCs in the same region and between VPCs in different regions, a communication gateway needs to be set up in each VPC to achieve interconnection between VPCs through the communication gateway.
[0208] As an example of a hardware functional unit, the receiving module 710 may include at least one computing device, such as a server, etc. Alternatively, the receiving module 710 may also be a device implemented using an application-specific integrated circuit (ASIC) or a programmable logic device (PLD). The PLD may be a complex programmable logical device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL) or any combination thereof.
[0209] The multiple computing devices included in the receiving module 610 can be distributed in the same region or in different regions. The multiple computing devices included in the receiving module 610 can be distributed in the same AZ or in different AZs. Similarly, the multiple computing devices included in the receiving module 610 can be distributed in the same VPC or in multiple VPCs. The multiple computing devices can be any combination of computing devices such as servers, ASICs, PLDs, CPLDs, FPGAs, and GALs.
[0210] It should be noted that, in other embodiments, the receiving module 710, the query module 720 and the sending module 730 can be used for any step in the multi-table connection query method in the storage node, and the steps that the receiving module 710, the query module 720 and the sending module 730 are responsible for implementing can be specified as needed. The receiving module 710, the query module 720 and the sending module 730 respectively implement different steps in the multi-table connection query method to realize the full functions of the device for performing multi-table connection query in the storage node.
[0211] The present disclosure also provides a cloud native database system, such as Figure 2 As shown, it includes computing nodes and storage nodes. The functions of the computing nodes and storage nodes have been introduced and will not be repeated here.
[0212] Both the computing node and the storage node can be implemented by software or hardware. As an example, the implementation of the computing node is described below. Similarly, the implementation of the storage node can refer to the implementation of the computing node.
[0213] As an example of a software functional unit, a computing node may include code running on a computing instance. The computing instance may be at least one of a physical host (computing device), a virtual machine, a container, and other computing devices. Furthermore, the computing device may be one or more. For example, the YY device may include code running on multiple hosts / virtual machines / containers. It should be noted that the multiple hosts / virtual machines / containers used to run the application may be distributed in the same region or in different regions. The multiple hosts / virtual machines / containers used to run the code may be distributed in the same AZ or in different AZs, each AZ including a data center or multiple data centers with close geographical locations. Typically, a region may include multiple AZs.
[0214] Similarly, multiple hosts / virtual machines / containers used to run the code can be distributed in the same VPC or in multiple VPCs. Usually, a VPC is set up in a region. For cross-region communication between two VPCs in the same region and between VPCs in different regions, a communication gateway must be set up in each VPC to achieve interconnection between VPCs through the communication gateway.
[0215] The module is an example of a hardware functional unit, and the computing node may include at least one computing device, such as a server, etc. Alternatively, the YY device may also be a device implemented using ASIC or PLD, etc. The PLD may be implemented using CPLD, FPGA, GAL or any combination thereof.
[0216] The multiple computing devices included in the computing node can be distributed in the same region or in different regions. The multiple computing devices included in the computing node can be distributed in the same AZ or in different AZs. Similarly, the multiple computing devices included in the computing node can be distributed in the same VPC or in multiple VPCs. The multiple computing devices can be any combination of computing devices such as servers, ASICs, PLDs, CPLDs, FPGAs, and GALs.
[0217] The present disclosure also provides a computing device 100. The computing device 100 can be applied to the above computing node or storage node. Figure 8 As shown, the computing device 100 includes: a bus 102, a processor 104, a memory 106, and a communication interface 108. The processor 104, the memory 106, and the communication interface 108 communicate with each other through the bus 102. The computing device 100 can be a server or a terminal device. It should be understood that the present disclosure does not limit the number of processors and memories in the computing device 100.
[0218] The bus 102 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 8 The bus 102 is represented by only one line, but it does not mean that there is only one bus or one type of bus. The bus 102 may include a path for transmitting information between various components of the computing device 100 (eg, the memory 106, the processor 104, and the communication interface 108).
[0219] The processor 104 may include any one or more of a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor (MP), or a digital signal processor (DSP).
[0220] The memory 106 may include a volatile memory, such as a random access memory (RAM). The memory 106 may also include a non-volatile memory, such as a read-only memory (ROM), a flash memory, a hard disk drive (HDD), or a solid state drive (SSD).
[0221] The memory 106 stores executable program codes, and the processor 104 executes the executable program codes to respectively implement the functions of the aforementioned receiving module 610, determining module 620, sending module 630, result module 640, feedback module 650, query module 660, receiving module 710, query module 720, and sending module 730, thereby implementing the method for multi-table join query. That is, the memory 106 stores instructions for the method for multi-table join query.
[0222] Alternatively, the memory 106 stores executable codes, and the processor 104 executes the executable codes to respectively implement the functions of the aforementioned receiving module 610, determining module 620, sending module 630, result module 640, feedback module 650, query module 660, receiving module 710, query module 720, and sending module 730, thereby implementing the multi-table join query method. That is, the memory 106 stores instructions for the multi-table join query method.
[0223] The communication interface 108 uses a transceiver module such as, but not limited to, a network interface card or a transceiver to implement communication between the computing device 100 and other devices or a communication network.
[0224] The present disclosure also provides a computing device cluster. The computing device cluster includes at least one computing device. The computing device may be a server, such as a central server, an edge server, or a local server in a local data center. In some embodiments, the computing device may also be a terminal device such as a desktop computer, a laptop computer, or a smart phone.
[0225] like Fig. 9 As shown, the computing device cluster includes at least one computing device 100. The memory 106 in one or more computing devices 100 in the computing device cluster may store the same instructions for the method for multi-table join query.
[0226] In some possible implementations, the memory 106 of one or more computing devices 100 in the computing device cluster may also store partial instructions of the method for multi-table join query. In other words, the combination of one or more computing devices 100 may jointly execute the instructions of the method for multi-table join query.
[0227] It should be noted that the memory 106 in different computing devices 100 in the computing device cluster can store different instructions, which are respectively used for part of the functions of the multi-table connection query device. That is, the instructions stored in the memory 106 in different computing devices 100 can implement the functions of one or more of the aforementioned receiving module 610, determining module 620, sending module 630, result module 640, feedback module 650, query module 660, receiving module 710, query module 720 and sending module 730.
[0228] In some possible implementations, one or more computing devices in the computing device cluster may be connected via a network, which may be a wide area network or a local area network, etc. The network may be a Transmission Control Protocol (TCP) network or a Remote Direct Memory Access (RDMA) network, etc. Fig.10 A possible implementation is shown. Fig.10 As shown, two computing devices 100A and 100B are connected via a network. Specifically, the network is connected via a communication interface in each computing device. In this type of possible implementation, the memory 106 in the computing device 100A stores instructions for executing the functions of the receiving module 610, the determining module 620, the sending module 630, the result module 640, the feedback module 650, and the query module 660. At the same time, the memory 106 in the computing device 100B stores instructions for executing the functions of the receiving module 710, the query module 720, and the sending module 730.
[0229] Fig.10 The connection method between the computing device clusters shown may be that considering that the method for multi-table connection query provided by the present disclosure requires a large amount of data storage, it is considered to hand over the functions implemented by the receiving module 710, the query module 720 and the sending module 730 to the computing device 100B for execution.
[0230] It should be understood that Fig.10 The functions of the computing device 100A shown in FIG. 1 may also be completed by multiple computing devices 100. Similarly, the functions of the computing device 100B may also be completed by multiple computing devices 100.
[0231] The present disclosure also provides another computing device cluster. The connection relationship between the computing devices in the computing device cluster can be similar to that of Fig. 9 and Fig.10 The connection mode of the computing device cluster is different in that the memory 106 in one or more computing devices 100 in the computing device cluster may store the same instructions for the multi-table connection query method.
[0232] In some possible implementations, the memory 106 of one or more computing devices 100 in the computing device cluster may also store partial instructions of the method for multi-table join query. In other words, the combination of one or more computing devices 100 may jointly execute the instructions of the method for multi-table join query.
[0233] The present disclosure also provides a computer program product including instructions. The computer program product may be software or a program product including instructions that can be run on a computing device or stored in any available medium. When the computer program product is run on at least one computing device, a method is provided for enabling at least one computing device to perform multi-table join query.
[0234] The embodiment of the present disclosure also provides a computer-readable storage medium. The computer-readable storage medium can be any available medium that can be stored by a computing device or a data storage device such as a data center containing one or more available media. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a magnetic tape), an optical medium (e.g., a digital video disk (DVD)), or a semiconductor medium (e.g., a solid-state hard disk). The computer-readable storage medium includes instructions, and the instructions instruct the computing device to perform a multi-table join query method, or instruct the computing device to perform a multi-table join query method.
[0235] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present disclosure, rather than to limit them. Although the present disclosure has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the protection scope of the technical solutions of the embodiments of the present disclosure.
Claims
1. A method for multi-table connection query, characterized in that: The method is applied to a cloud native database system, the cloud native database system includes a computing node and a plurality of storage nodes, and the method includes: The computing node receives a multi-table connection query instruction; The computing node determines at least one first shard connection information based on the table shards respectively included in the multiple data tables corresponding to the multi-table connection query instruction, wherein each first shard connection information indicates multiple table shards for connection query; The computing node sends shard connection query information corresponding to the first shard connection information to each target storage node corresponding to the first shard connection information, wherein the shard connection query information includes the first shard connection information and the query condition in the multi-table connection query instruction, and the target storage node stores multiple table shards indicated by the corresponding first shard connection information; Based on the query condition, each of the target storage nodes performs a connection query in a plurality of table shards indicated by the first shard connection information corresponding to the target storage node to obtain a first shard query result; The computing node receives the first shard query result sent by each of the target storage nodes; The computing node determines a query result of the multi-table join query instruction based on the received at least one first shard query result, and provides feedback to the multi-table join query instruction based on the query result.
2. The method according to claim 1, characterized in that: The computing node determines at least one first shard connection information based on the table shards respectively included in the multiple data tables corresponding to the multi-table connection query instruction, including: The computing node determines at least one shard connection information based on the table shards respectively included in the multiple data tables corresponding to the multi-table connection query instruction, wherein each shard connection information indicates multiple table shards for connection query; The computing node determines at least one first shard connection information from the at least one shard connection information, wherein the multiple table shards indicated by the first shard connection information are stored in the same storage node.
3. The method according to claim 2, characterized in that The method further comprises: The computing node determines at least one second shard connection information, wherein the plurality of table shards indicated by the second shard connection information are stored in different storage nodes; The computing node obtains, from the plurality of storage nodes corresponding to the at least one second shard connection information, the plurality of table shards indicated by the at least one second shard connection information; The computing node performs a connection query on the multiple table shards indicated by the at least one second shard connection information based on the query condition in the multi-table connection query instruction to obtain a second shard query result; The computing node determines the query result of the multi-table join query instruction based on the received at least one first shard query result, including: The computing node combines the received at least one first shard query result and the second shard query result into a query result of the multi-table join query instruction.
4. The method according to claim 1, characterized in that: The computing node determines the query result of the multi-table join query instruction based on the received multiple first shard query results, including: The computing node combines the received multiple first shard query results into a query result of the multi-table connection query instruction.
5. The method according to any one of claims 1 to 4, characterized in that The method further comprises: The computing node determines at least one storage node corresponding to each first shard connection information, and the storage node stores a plurality of table shards indicated by the corresponding first shard connection information; The computing node determines a target storage node from the at least one storage node according to the resource occupation information of the at least one storage node.
6. The method according to any one of claims 1 to 5, characterized in that Before the computing node determines at least one first shard connection information based on the table shards respectively included in the multiple data tables corresponding to the multi-table connection query instruction, the method further includes: The computing node determines that the data volume of the multiple data tables corresponding to the multi-table connection query instruction exceeds a preset threshold.
7. A cloud native database system, characterized in that: The cloud native database system includes a computing node and multiple storage nodes; The computing node is used to receive a multi-table connection query instruction; determine at least one first shard connection information based on table shards respectively included in a plurality of data tables corresponding to the multi-table connection query instruction, wherein each first shard connection information indicates a plurality of table shards used for connection query; send shard connection query information corresponding to the first shard connection information to a target storage node corresponding to each first shard connection information, the shard connection query information including the first shard connection information and a query condition in the multi-table connection query instruction, and the target storage node stores a plurality of table shards indicated by the corresponding first shard connection information; Each of the target storage nodes is configured to perform a connection query in a plurality of table shards indicated by the first shard connection information corresponding to the target storage node based on the query condition to obtain a first shard query result; The computing node is used to receive the first shard query result sent by each of the target storage nodes; determine the query result of the multi-table connection query instruction based on at least one first shard query result received, and provide feedback to the multi-table connection query instruction based on the query result.
8. The cloud native database system according to claim 7, characterized in that: The computing node is used for: Based on the table shards respectively included in the multiple data tables corresponding to the multi-table connection query instruction, determine at least one shard connection information, wherein each shard connection information indicates multiple table shards for connection query; At least one first shard connection information is determined from the at least one shard connection information, wherein the multiple table shards indicated by the first shard connection information are stored in the same storage node.
9. The cloud native database system according to claim 8, characterized in that: The computing node is further used for: Determine at least one second shard connection information, wherein the plurality of table shards indicated by the second shard connection information are stored in different storage nodes; Acquire, from the plurality of storage nodes corresponding to the at least one second shard connection information, the plurality of table shards indicated by the at least one second shard connection information; Based on the query condition in the multi-table connection query instruction, a connection query is performed on the multiple table shards indicated by the at least one second shard connection information to obtain a second shard query result; The computing node is used for: The at least one first shard query result and the second shard query result received are combined into a query result of the multi-table join query instruction.
10. The cloud native database system according to claim 7, characterized in that: The computing node is used for: The received multiple first shard query results are combined into a query result of the multi-table connection query instruction.
11. The cloud native database system according to any one of claims 7 to 10, characterized in that: The computing node is further used for: Determine at least one storage node corresponding to each first shard connection information, wherein the storage node stores a plurality of table shards indicated by the corresponding first shard connection information; According to the resource occupation information of the at least one storage node, a target storage node is determined from the at least one storage node.
12. The cloud native database system according to any one of claims 7 to 11, characterized in that: The computing node is further used for: It is determined that the data amounts of the multiple data tables corresponding to the multi-table connection query instruction exceed a preset threshold.
13. A computing device cluster, characterized in that: comprising at least one computing device, each computing device comprising a processor and a memory; The processor of the at least one computing device is configured to execute instructions stored in the memory of the at least one computing device, so that the computing device cluster executes the method according to any one of claims 1 to 6.
14. A computer-readable storage medium, characterized in that: The method comprises computer program instructions, and when the computer program instructions are executed by a computing device cluster, the computing device cluster performs the method according to any one of claims 1 to 6.
15. A computer program product comprising instructions, characterized in that When the instructions are executed by a computing device cluster, the computing device cluster executes the method according to any one of claims 1 to 6.