Data query method and related device
By storing the distribution key logical value of the base table data in the distributed database, the data node is directly determined, which solves the problem of low efficiency of table return query in the existing technology, and achieves more efficient query and resource saving effects.
Patent Information
- Application Number
- CN202310361217.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-29
- Publication Date
- 2024-10-01
AI Technical Summary
The table return query method in the prior art has low query efficiency in distributed databases, mainly because it is necessary to calculate the distribution key logical value of the base table data to determine the data node, which increases the table return time and cost.
By storing the logical value of the distribution key of the base table data in the data node instead of the actual distribution key value, the second data node is directly determined, eliminating the calculation process, improving query efficiency, and transmitting it between the coordination node and the data node. Save storage space and computing power.
It improves the efficiency of data query, reduces the cost of returning tables, saves storage space and transmission costs, and avoids the problem of insufficient storage space or computing power of the coordination node.
Smart Images

Figure CN118733606A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of distributed databases, and in particular to a data query method and related devices. Background Art
[0002] A data query method in a distributed database is a table-back query method based on a global secondary index (GSI).
[0003] At present, in the commonly used back-table query method, the GSI table contains the index of the base table data and the distribution key of the base table data. The base table is the basic table of the database system. After receiving the query request carrying the query condition, the coordination node first queries the GSI data whose index column value meets the query condition from each data node, and then calculates the data node where the base table data is located based on the distribution key value of the base table data recorded in the GSI data, and then queries the base table data that meets the query condition in the base table in the data node.
[0004] However, the query efficiency is low when using this table return query method to query data. Summary of the invention
[0005] The present application provides a data query method and related devices, which are used to solve the problem of low query efficiency when querying data using a table back query method in the prior art.
[0006] In a first aspect, the present application provides a data query method, which is applied to a first data node. The method includes: receiving a first instruction from a coordination node, the first instruction is used to request to query the base table data that meets the first query condition by a table back query method; querying based on the first instruction to obtain the first GSI data, the first index in the first GSI data meets the first query condition; sending a second instruction, the second instruction is used to indicate that the base table data that meets the first query condition is stored in a second data node, and the logical value of the distribution key of the base table data stored in the second data node is equal to the first logical value in the first GSI data.
[0007] The first data node may be deployed in a distributed system. In the distributed system, each data node stores GSI data, and the GSI data may include a first index and a first logical value, wherein the first index is an index of the base table data, and the first logical value is a logical value of a distribution key of the base table data. The first data node may be a data node in the distributed system for storing the first GSI data.
[0008] In this method, the first data node can directly determine the second data node based on the logical value of the distribution key of the base table data, which can omit the calculation process of the logical value of the distribution key of the base table data in the prior art, reduce the cost of returning to the table, and improve query efficiency.
[0009] In some possible implementations, the logical value of the distribution key of the base table data includes any one of the following: a hash value mapping value of the distribution key of the base table data, a range mapping value of the distribution key of the base table data, and a list mapping value of the distribution key of the base table data.
[0010] In this method, what is stored in the data node is the logical value of the distribution key of the base table data instead of the distribution key of the base table data, which saves the storage space of the data node.
[0011] In some possible implementations, the sending the second instruction includes: sending the second instruction to the coordination node.
[0012] In the method, after the first data node sends the second instruction to the coordination node, the coordination node can determine the second data node based on the second instruction, and then send a third instruction to the second data node, the third instruction is used to request the second data node to query the base table data that meets the first query condition. The second data node determines the first base table data based on the third instruction, and sends the first base table data to the coordination node. The first base table data includes the base table data that meets the first query condition.
[0013] The first data node sends a second instruction to the coordination node, so that the second data node does not need to receive the first GSI data, thereby saving storage space of the second data node.
[0014] Optionally, when the first data node sends the second instruction to the coordination node, it can also send the first GSI data to the coordination node. The first GSI data can contain the location information of the base table data or the partition key of the base table data, so that the coordination node can determine the storage location of the base table data corresponding to the first GSI data based on the location information, and the coordination node can determine the storage unit of the base table data based on the partition key of the base table data. When the coordination node sends the third instruction to the second data node, it can carry this information, thereby saving the query time of the base table data, which is conducive to improving the query efficiency.
[0015] Optionally, the first data node may send the location information of the base table data in the first GSI data or the partition key of the base table data to the coordination node. In other words, the first data node may not send the logical value of the distribution key of the base table data to the coordination node, which is conducive to saving the transmission cost between the first data node and the coordination node.
[0016] In some possible implementations, the sending the second instruction includes: sending the second instruction to the second data node.
[0017] In the method, after the first data node sends the second instruction to the second data node, the second data node can determine the first base table data based on the first query condition and send the first base table data to the coordination node, wherein the first base table data includes the data required by the user.
[0018] The first data node sends the second instruction to the second data node, which can save communication requirements between the first data node and the coordination node on the one hand, and avoid the problem of insufficient storage space or computing power of the coordination node when the coordination node receives too many second instructions on the other hand.
[0019] Optionally, when the first data node sends the second instruction to the second data node, it may also send the first GSI data to the second data node. The first GSI data may include the location information of the base table data or the partition key of the base table data, so that the second data node can determine the storage location of the base table data corresponding to the first GSI data based on the location information, and the second data node can determine the storage unit of the base table data based on the partition key of the base table data, which can save the query time of the base table data and help improve the query efficiency.
[0020] Optionally, the first data node may send the location information of the base table data in the first GSI data or the partition key of the base table data to the second data node. In this way, the first data node may not send the logical value of the distribution key of the base table data to the second data node, which is conducive to saving the transmission cost between the first data node and the second data node.
[0021] In some possible implementations, the first data node may send the first GSI data to the coordination node. Accordingly, the coordination node may determine the second data node based on the logical value of the distribution key of the base table data in the first GSI data, and then send the third instruction to the second data node.
[0022] In this method, the coordination node can omit the process of calculating the logical value of the base table data distribution key through the base table data distribution key, which is conducive to the coordination node to quickly determine the second data node, thereby improving query efficiency.
[0023] In addition, the first data node sends the first GSI data to the coordination node, so that the coordination node does not need to receive the second instruction, thereby saving storage space of the coordination node.
[0024] Optionally, if the first GSI data also includes a portion of data required by the user, the first data node may send this portion of data to the coordination node.
[0025] In some possible implementations, the GSI data further includes a second logical value, which is the logical value of the partition key of the base table data, and the logical value of the partition key of the base table data includes any one of the following: a hash value mapping value of the partition key of the base table data, a range mapping value of the partition key of the base table data, and a list mapping value of the partition key of the base table data; wherein the logical value of the partition key of the base table data stored in the second data node is equal to the second logical value in the first GSI data.
[0026] In this method, the first data node can determine in which storage unit of the second data node the base table data is stored based on the second logical value, which is helpful to save and improve the efficiency of the second data node in determining the first base table data, thereby improving the efficiency of back-table query.
[0027] In a second aspect, the present application provides a data query method, which is applied in a coordination node. The method includes: sending a first instruction to at least one data node, each of the at least one data node stores global secondary index GSI data, the GSI data contains a first index and a first logical value, the first index is an index of base table data, the first logical value is the logical value of the distribution key of the base table data, and the first instruction is used to request to query the base table data that meets the first query condition by a back table query method; receiving a second instruction from the first data node of the at least one data node, the second instruction is used to indicate that the base table data that meets the first query condition is stored in the second data node, and the logical value of the distribution key of the base table data stored in the second data node is equal to the first logical value in the first GSI data.
[0028] In some possible implementations, the logical value of the distribution key of the base table data includes any one of the following: a hash value mapping value of the distribution key of the base table data, a range mapping value of the distribution key of the base table data, and a list mapping value of the distribution key of the base table data.
[0029] In some possible implementations, the GSI data further includes a second logical value, which is the logical value of the partition key of the base table data, and the logical value of the partition key of the base table data includes any one of the following: a hash value mapping value of the partition key of the base table data, a range mapping value of the partition key of the base table data, and a list mapping value of the partition key of the base table data; wherein the logical value of the partition key of the base table data stored in the second data node is equal to the second logical value in the first GSI data.
[0030] In a third aspect, the present application provides a data query device, including modules or units for implementing the method in the first aspect and any possible implementation of the first aspect. It should be understood that each module or unit can implement the corresponding function by executing a computer program.
[0031] For example, the data query device may include a receiving module, a query module and a sending module.
[0032] The receiving module may be configured to receive a first instruction, wherein the first instruction is configured to request to query the base table data satisfying the first query condition by means of a table back query.
[0033] The query module may be configured to query based on the first instruction to obtain first GSI data, wherein a first index in the first GSI data satisfies the first query condition.
[0034] The sending module can be used to send a second instruction, where the second instruction is used to indicate that the base table data that meets the first query condition is stored in the second data node, and the logical value of the distribution key of the base table data stored in the second data node is equal to the first logical value in the first GSI data.
[0035] In some possible implementations, the logical value of the distribution key of the base table data includes any one of the following: a hash value mapping value of the distribution key of the base table data, a range mapping value of the distribution key of the base table data, and a list mapping value of the distribution key of the base table data.
[0036] In some possible implementations, when the receiving module receives the first instruction, the receiving module may be specifically configured to: receive the first instruction from the coordination node.
[0037] When the sending module sends the second instruction, the sending module may be specifically configured to: send the second instruction to the second data node or the coordination node.
[0038] In some possible implementations, the GSI data further includes a second logical value, which is the logical value of the partition key of the base table data, and the logical value of the partition key of the base table data includes any one of the following: a hash value mapping value of the partition key of the base table data, a range mapping value of the partition key of the base table data, and a list mapping value of the partition key of the base table data; wherein the logical value of the partition key of the base table data stored in the second data node is equal to the second logical value in the first GSI data.
[0039] In a fourth aspect, the present application provides a data query device, including modules or units for implementing the method in the second aspect and any possible implementation of the second aspect. It should be understood that each module or unit can implement the corresponding function by executing a computer program.
[0040] For example, the data query device may include a sending module and a receiving module.
[0041] Among them, the sending module can be used to send a first instruction to at least one data node, each first data node in the at least one data node stores global secondary index GSI data, the GSI data contains a first index and a first logical value, the first index is an index of the base table data, the first logical value is the logical value of the distribution key of the base table data, and the first instruction is used to request to query the base table data that meets the first query condition through a back-table query.
[0042] The receiving module can be used to receive a second instruction from a first data node among the at least one data node, wherein the second instruction is used to indicate that the base table data satisfying the first query condition is stored in the second data node, and the logical value of the distribution key of the base table data stored in the second data node is equal to the first logical value in the first GSI data.
[0043] In some possible implementations, the logical value of the distribution key of the base table data includes any one of the following: a hash value mapping value of the distribution key of the base table data, a range mapping value of the distribution key of the base table data, and a list mapping value of the distribution key of the base table data.
[0044] In some possible implementations, the GSI data further includes a second logical value, which is the logical value of the partition key of the base table data, and the logical value of the partition key of the base table data includes any one of the following: a hash value mapping value of the partition key of the base table data, a range mapping value of the partition key of the base table data, and a list mapping value of the partition key of the base table data; wherein the logical value of the partition key of the base table data stored in the second data node is equal to the second logical value in the first GSI data.
[0045] In a fifth aspect, the present application provides a data query device, comprising a processor, wherein the processor is used to execute the method described in any possible implementation manner of the first aspect or the second aspect.
[0046] The device may further include a memory for storing instructions and data. The memory is coupled to the processor, and when the processor executes the instructions stored in the memory, the methods described in the above aspects may be implemented. The device may further include a communication interface, and the communication interface is used for the device to communicate with other devices. Exemplarily, the communication interface may be a transceiver, circuit, bus, module or other type of communication interface.
[0047] In a sixth aspect, the present application provides a communication system, the communication system comprising a data node and a coordination node. The data node can be used to implement the method described in any possible implementation of the first aspect, and the coordination node can be used to implement the method described in any possible implementation of the second aspect.
[0048] In a seventh aspect, the present application provides a computer-readable storage medium storing a program code for execution by a data query device, wherein the program code includes instructions for implementing the method in the first aspect or the second aspect.
[0049] In an eighth aspect, the present application provides a computer program product comprising instructions, and when the computer program product is run on a data query device, the data query device implements the method in the first aspect or the second aspect.
[0050] It can be understood that the effects that can be obtained from the second to eighth aspects can be referred to the description in the first aspect and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0051] Figure 1 A schematic diagram of a distributed system architecture applicable to an embodiment of the present application;
[0052] Figure 2 An exemplary storage method of base table data and GSI data provided in the embodiment of the present application;
[0053] Figure 3 A schematic diagram of a data query method provided by an embodiment of the present application;
[0054] Figure 4 A schematic diagram of a data query method provided by another embodiment of the present application;
[0055] Figure 5 A schematic diagram of a data query method provided by an embodiment of the present application;
[0056] Figure 6 A schematic diagram of a data query method provided by another embodiment of the present application;
[0057] Figure 7 A schematic diagram of a data query method provided by yet another embodiment of the present application;
[0058] Figure 8 A schematic diagram of a data query method provided by yet another embodiment of the present application;
[0059] Fig. 9 A schematic diagram of a data query method provided by yet another embodiment of the present application;
[0060] Fig.10 This is a schematic diagram of the structure of a data query device according to an embodiment of the present application;
[0061] Fig.11 This is a structural diagram of a data query device according to another embodiment of the present application;
[0062] Fig.12 This is a structural diagram of a data query device according to another embodiment of the present application. DETAILED DESCRIPTION
[0063] The technical solutions in the embodiments of the present application will be described below in conjunction with the drawings in the embodiments of the present application.
[0064] In order to facilitate the clear description of the technical solutions of the embodiments of the present application, in the embodiments of the present application, the words "first" and "second" are used to distinguish the same items or similar items with substantially the same functions and effects. For example, the first information and the second information are only used to distinguish different information, and their order is not limited. Those skilled in the art can understand that the words "first" and "second" do not limit the quantity and execution order, and the words "first" and "second" do not necessarily limit them to be different.
[0065] In the embodiments of the present application, "at least one" refers to one or more, and "more than one" refers to two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone, where A and B can be singular or plural. The character " / " generally indicates that the previous and next associated objects are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b, or c can represent: a, b, c; a and b; a and c; b and c; or a and b and c. Among them, a, b, c can be single or multiple.
[0066] To facilitate understanding of the data query method provided in the embodiment of the present application, the system architecture and application scenarios of the data query method provided in the embodiment of the present application are described below. It is understandable that the system architecture and application scenarios described in the embodiment of the present application are to more clearly illustrate the technical solution of the embodiment of the present application, and do not constitute a limitation on the technical solution provided in the embodiment of the present application.
[0067] Figure 1 Schematic diagram of a distributed system architecture applicable to the embodiment of the present application. Figure 1 As shown, the distributed system may include a client, a coordinator node (CN) and M data nodes (DN), where M is a positive integer. The client and the coordinator node may communicate with each other, and the coordinator node and each data node may communicate with each other.
[0068] The client may be used to receive instructions input by the user and send the instructions to the coordination node. For example, the instructions input by the user in the client may include storage instructions, modification instructions, addition and deletion instructions, or query instructions, etc. In this embodiment, the distributed system may include at least one client.
[0069] The coordination node can be used to receive user requests from the client, parse the user requests and perform corresponding operations, or send the indication information to the data node so that the data node can perform corresponding operations based on the indication information. Optionally, the coordination node can also receive data obtained by the data node based on the indication information and return the data to the client.
[0070] In one example, when a user requests to store data, the coordination node may store the data in the data node based on the request.
[0071] The data may include multiple sets of base table data, which are basic tables in a database. For any set of base table data, the base table data may include a distribution key, and the coordination node may store the base table data on the data node corresponding to the distribution key based on the distribution key corresponding to the base table data.
[0072] In addition, a column in the base table data can also be indexed, that is, each set of base table data can also correspond to a set of index data. For any set of index data, the index data can also correspond to a distribution key of the index data, and the coordination node can store the index data on the data node corresponding to the distribution key based on the distribution key corresponding to the index data.
[0073] In this embodiment, the index distributed on a different data node from the base table may be referred to as a GSI. Accordingly, the aforementioned index data may also be referred to as GSI data.
[0074] As an example, the base table data and GSI data can be stored as follows: Figure 2 In this example, the distributed system may include three data nodes: data node 1, data node 2, and data node 3, wherein data node 1 may store base table data 1 and GSI data 1, data node 2 may store base table data 2 and GSI data 2, and data node 3 may store base table data 3 and GSI data 3.
[0075] Each set of base table data and the GSI data corresponding to the base table data may be distributed in the same data node or in different data nodes.
[0076] Understandably, Figure 2 This is only a simple example and does not limit the number of data nodes and the storage method of data in this application. In actual applications, the base table data stored in any data node can be one group, multiple groups or zero groups, and the GSI data stored in any data node can also be one group, multiple groups or zero groups.
[0077] There is no requirement for the distribution of base table data and GSI data on data nodes. The available distribution methods include hash distribution, range distribution, list distribution, etc.
[0078] As an example, for hash-distributed data, the data node corresponding to the data can be determined by calculating the hash value mapping value of the data's distribution key. For range-distributed data, the data node corresponding to the data can be directly determined based on the range mapping value of the data's distribution key. For list-distributed data, the data node corresponding to the data can be directly determined based on the list mapping value of the data's distribution key.
[0079] Optionally, for any set of base table data, the base table data can also be stored in partitions on the data nodes. There is no requirement for partitioning of the base table data on the data nodes, and the partitioning methods that can be selected include hash partitioning, range partitioning, list partitioning, etc. Correspondingly, each set of base table data can correspond to a partition key, and the GSI data can contain the logical value of the partition key of the base table data. After the coordination node determines the data node corresponding to the base table data, it can also store the base table data in the storage unit corresponding to the partition key based on the partition key corresponding to the base table data.
[0080] As an example, for hash partitioned data, the storage unit corresponding to the data can be determined by calculating the hash value of the partition key of the base table data. For range-distributed base table data, the storage unit corresponding to the data can be directly determined based on the range of the data. For list-distributed base table data, the storage unit corresponding to the data can be directly determined based on the list mapping value of the data.
[0081] The coordination node may also send a first mapping relationship of the base table data to each data node, wherein the first mapping relationship is used to indicate a distribution logic between the base table data and the data nodes.
[0082] As an example, for hash-distributed base table data, the first mapping relationship of the base table data may include a mapping relationship between each hash value mapping value and a data node corresponding to each hash value mapping value. For range-distributed base table data, the first mapping relationship of the base table data may include a mapping relationship between each range mapping value and a data node corresponding to each range mapping value. For list-distributed base table data, the first mapping relationship of the base table data may include a mapping relationship between each list mapping value and a data node corresponding to each list mapping value.
[0083] Optionally, the coordination node may also send a second mapping relationship of the base table data to each data node, wherein the second mapping relationship is used to indicate a partitioning logic between the base table data and a storage unit of the data node.
[0084] As an example, for hash partitioned base table data, the second mapping relationship of the base table data may include a mapping relationship between each hash value mapping value and a storage unit of a data node corresponding to each hash value mapping value. For range partitioned base table data, the second mapping relationship of the base table data may include a mapping relationship between each range mapping value and a storage unit of a data node corresponding to each range mapping value. For list partitioned base table data, the mapping relationship of the base table data may include a mapping relationship between each list mapping value and a storage unit of a data node corresponding to each list mapping value.
[0085] In some embodiments, the GSI data may include the partition key of the base table data.
[0086] In this embodiment, the distribution mode and partition mode of the base table data are independent, and the distribution mode and partition mode can be used in combination.
[0087] It should be understood that the data included in the base table data and the GSI data is only an example and does not limit the scope of the base table data and the GSI data.
[0088] In another example, when the user request is to query data, the coordination node may send indication information to the data node based on the instruction, and the indication information may include the query condition and the query method.
[0089] In this embodiment, the coordination node may be a server with a control function. Optionally, the coordination node may also be a controller, or a chip used in a controller.
[0090] In this embodiment, the distributed system may include one or more coordination nodes. When the distributed system includes one coordination node, the client may connect to any one of the multiple coordination nodes. Any two of the multiple coordination nodes may communicate with each other.
[0091] The data node can be used to store data, receive indication information from the coordination node, and perform corresponding operations based on the query conditions in the indication information. In this embodiment, any two data nodes can also communicate with each other.
[0092] In this embodiment, a database parser, an optimizer and an executor may be deployed in the coordination node and the data node. The database parser may be used to convert user requests into executable instructions, the optimizer is used to determine the query mode based on the query conditions, and the executor is used to execute commands based on the instructions.
[0093] In this embodiment, the data node can query from the stored base table data based on the query condition, and can also query from the stored GSI data based on the query condition. In some scenarios, when the data node queries from the stored GSI data, if all the data required by the user cannot be found, it is necessary to perform a back table query to query the data other than the index data from the base table.
[0094] For example, suppose the base table contains five columns of data, c1 to c5, the distribution key is c1, and an index (i.e., GSI) is created on column c2. If the query wants to obtain the values of columns c2 and c3, and there is a conditional filtering operation on column c2, you can first query on the index to filter out the values that meet the c2 filtering condition, and then further perform a back table query to obtain the values of c2 and c3.
[0095] At present, in the commonly used back-table query method, the GSI table contains the index of the base table data and the distribution key of the base table data, and the base table contains the distribution key of the base table data. After receiving the query request carrying the query condition, the coordination node first queries the GSI data whose index column value meets the query condition from each data node, and then calculates the data node where the base table data is located based on the distribution key value of the base table data recorded in the GSI data, and then queries the base table in the data node for the base table data that meets the query condition.
[0096] However, when using this table return query method to query data, the problem of low query efficiency often occurs.
[0097] The inventors have discovered that the reasons why the existing table return query method has low query efficiency are as follows: after the data node determines the GSI data, it is necessary to first calculate the value of the distribution key of the base table data recorded in the GSI data to obtain the logical value of the distribution value, and then determine the data node where the base table data is located based on the logical value of the distribution key, which increases the table return time, affects the table return efficiency, and thus reduces the query efficiency.
[0098] To this end, the present application provides a data query method and related devices to solve the problem of low query efficiency in the prior art.
[0099] In the technical solution of the present application, the GSI data contains the logical value of the distribution key of the base table data, but does not contain the value of the distribution key of the base table data. The first data node can directly determine the second data node based on the logical value of the distribution key of the base table data, which can omit the calculation process of the logical value of the distribution key of the base table data in the prior art, reduce the cost of returning to the table, and improve the query efficiency.
[0100] The logical value of the distribution key of the base table data can be obtained based on the distribution mode of the base table data. As an example, for base table data with hash distribution, the logical value of the distribution key of the base table data is the hash value mapping value of the distribution key of the base table data. For base table data with range distribution, the logical value of the distribution key of the base table data is the range of the distribution key of the base table data. For base table data with list distribution, the logical value of the distribution key of the base table data is the list mapping value of the distribution key of the base table data.
[0101] Optionally, the GSI data may also include the logical value of the partition key of the base table data. The first data node may directly determine the storage unit in the second data node based on the logical value of the partition key of the base table data, which is beneficial to improving the efficiency of the back table query.
[0102] Next, this application will combine Figures 3 to 11 , the solution of this application is introduced in detail.
[0103] Figure 3 A schematic diagram of a data query method provided by an embodiment of the present application. Figure 3 As shown, the data query method may include S301 to S303.
[0104] S301, the coordinating node sends a first instruction to at least one data node, the first instruction being used to request to query the base table data satisfying the first query condition by means of table return query. Accordingly, the at least one data node receives the first instruction.
[0105] In this embodiment, the coordination node may be: Figure 1A coordination node in the distributed system shown. In the distributed system, each of at least one data node stores GSI data, and the GSI data may include a first index and a first logical value, the first index being an index of the base table data, and the first logical value being a logical value of a distribution key of the base table data.
[0106] In this embodiment, the at least one data node may include a first data node and a second data node.
[0107] Among the at least one data node, a data node whose GSI data satisfies the first query condition may be referred to as a first data node, and there may be one or more first data nodes.
[0108] Among the at least one data node, a data node whose base table data satisfies the first query condition may be referred to as a second data node, and there may be one or more second data nodes.
[0109] Optionally, before the coordination node sends the first instruction to at least one data node, the coordination node may receive a user query request from a client, where the user query request may be a request input by a user at the client. As an example, the user query request may include a query instruction.
[0110] After receiving the query instruction, the coordination node may first determine whether to use the table return query method based on the query instruction, and send the first instruction to the first data node if it is determined to use the table return query method.
[0111] In some possible implementations, the method for the coordination node to determine whether to use a back-table query may include: first determining whether a GSI is built on the base table, and if a GSI is built on the base table, performing a query based on the GSI; then determining whether the GSI data contains all the data required by the user, and if the GSI data does not contain all the data required by the user, using a back-table query.
[0112] Optionally, the coordination node may also calculate the cost of the table query. If the table query cost is low, the coordination node determines to use the table query method to query. If the table query cost is high, the coordination node determines to use other query methods to query, such as directly querying through the base table.
[0113] The step of determining whether to use table return query may be performed by an optimizer in the coordination node.
[0114] Optionally, after receiving the query instruction, the coordination node may also parse the query instruction to obtain the first query condition and the data required by the user. The step of parsing the query instruction may be performed by a database parser in the coordination node.
[0115] S302: A first data node among at least one data node performs a query based on a first instruction to obtain first GSI data, wherein a first index in the first GSI data satisfies the first query condition.
[0116] In this embodiment, the first GSI data may include the logical value of the distribution key of the base table data.
[0117] Optionally, the first data node may determine the second data node based on the logical value of the distribution key of the base table data in the first GSI data, and the second data node stores the base table data corresponding to the first GSI data.
[0118] As an example, the base table data may be distributed and stored in the second data node in a hash value manner, and the logical value of the distribution key of the base table data is a hash value mapping value of the distribution key of the base table data.
[0119] As another example, the base table data may be distributed and stored in the second data node in a range manner, and the logical value of the distribution key of the base table data is the range mapping value of the distribution key of the base table data.
[0120] As another example, the base table data may be distributed and stored in the second data node in a list mapping manner, and the logical value of the distribution key of the base table data is the list mapping value of the distribution key of the base table data.
[0121] Optionally, the first GSI data may further include location information of the base table data, where the location information is used to indicate a storage location of the base table data corresponding to the first GSI data in the second data node.
[0122] As an example, the storage method of the base table data in the second data node may be represented in the form of a tuple. For example, assuming that the base table data is stored at the second offset in the first data page in the second data node, the location information of the base table data may be (1, 2).
[0123] Optionally, the first GSI data may also include a logical value of a partition key of the base table data. The first data node may determine a target storage unit of the second data node based on the logical value of the partition key. The target storage unit is a storage unit in the second data node for storing the base table data corresponding to the first GSI data.
[0124] As an example, the base table data may be partitioned and stored in the storage unit of the second data node in a hash value manner, and the logical value of the partition key of the base table data is a hash value mapping value of the partition key of the base table data.
[0125] As another example, the base table data may be stored in a storage unit of the second data node in a range partitioned manner, and the logical value of the partition key of the base table data is a range mapping value of the partition key of the base table data.
[0126] As another example, the base table data may be partitioned and stored in the second data node in a list mapping manner, and the logical value of the partition key of the base table data is the list mapping value of the partition key of the base table data.
[0127] S303, the first data node sends a second instruction to the second data node, the second instruction is used to indicate that the base table data that meets the first query condition is stored in the second data node, and the logical value of the distribution key of the base table data stored in the second data node is equal to the first logical value in the first GSI data. Correspondingly, the second data node receives the second instruction.
[0128] In this embodiment, after receiving the second instruction, the second data node may determine the first base table data based on the first query condition and send the first base table data to the coordination node, wherein the first base table data includes the data required by the user.
[0129] In this method, the first data node can omit the process of calculating the logical value of the base table data distribution key through the base table data distribution key, which is conducive to the first data node to quickly determine the second data node, thereby improving query efficiency.
[0130] In addition, the first data node sends the second instruction to the second data node, which can save communication requirements between the first data node and the coordination node on the one hand, and avoid the problem of insufficient storage space or computing power of the coordination node when the coordination node receives too many second instructions on the other hand.
[0131] Optionally, when the first data node sends the second instruction to the second data node, it may also send the first GSI data to the second data node. The first GSI data may include the location information of the base table data or the logical value of the partition key of the base table data, so that the second data node can determine the storage location of the base table data corresponding to the first GSI data based on the location information, and the second data node can determine the storage unit of the base table data based on the logical value of the partition key of the base table data, which can save the query time of the base table data and help improve the query efficiency.
[0132] Optionally, the first data node may send the location information of the base table data in the first GSI data or the logical value of the partition key of the base table data to the second data node. In other words, the first data node may not send the logical value of the distribution key of the base table data to the second data node, which is conducive to saving the transmission cost between the first data node and the second data node.
[0133] Optionally, after obtaining the first GSI data, the first data node may also directly send the first GSI data to the second data node.
[0134] In this embodiment, the coordinating node may send a first instruction to at least one data node, but the first data node that sends a second instruction to the second data node may be all of the at least one data node or may be part of the at least one data node.
[0135] Figure 4 A schematic diagram of a data query method provided by another embodiment of the present application. Figure 4 As shown, the data query method may include S401 to S404.
[0136] S401, the coordinating node sends a first instruction to at least one data node, the first instruction being used to request to query the base table data satisfying the first query condition by means of table return query. Accordingly, the at least one data node receives the first instruction.
[0137] In this embodiment, S401 can refer to Figure 3 The relevant steps in the illustrated embodiment will not be described in detail here.
[0138] S402: A first data node among at least one data node performs a query based on a first instruction to obtain first GSI data, wherein a first index in the first GSI data satisfies the first query condition.
[0139] In this embodiment, S402 can refer to Figure 3 The relevant steps in the illustrated embodiment will not be described in detail here.
[0140] S403, the first data node sends a second instruction to the coordination node, the second instruction is used to indicate that the base table data that meets the first query condition is stored in the second data node, and the logical value of the distribution key of the base table data stored in the second data node is equal to the first logical value in the first GSI data. Correspondingly, the coordination node receives the second instruction.
[0141] S404, the coordination node sends a third instruction to the second data node, where the third instruction is used to request the second data node to query the base table data that meets the first query condition. Correspondingly, the second data node receives the third instruction.
[0142] In this embodiment, the second data node determines the first base table data based on the third instruction, and sends the first base table data to the coordination node, wherein the first base table data includes base table data that meets the first query condition.
[0143] In this method, the first data node can omit the process of calculating the logical value of the base table data distribution key through the base table data distribution key, which is conducive to the first data node to quickly determine the second data node, thereby improving query efficiency.
[0144] Optionally, when the first data node sends the second instruction to the coordination node, it can also send the first GSI data to the coordination node. The first GSI data can include the location information of the base table data or the logical value of the partition key of the base table data, so that the coordination node can determine the storage location of the base table data corresponding to the first GSI data based on the location information, and the coordination node can determine the storage unit of the base table data based on the logical value of the partition key of the base table data. When the coordination node sends the third instruction to the second data node, it can carry this information, thereby saving the query time of the base table data and helping to improve the query efficiency.
[0145] Optionally, the first data node may send the location information of the base table data in the first GSI data or the logical value of the partition key of the base table data to the coordination node. In other words, the first data node may not send the logical value of the distribution key of the base table data to the coordination node, which is conducive to saving the transmission cost between the first data node and the coordination node.
[0146] Optionally, after obtaining the first GSI data, the first data node may also directly send the first GSI data to the coordination node. Accordingly, the coordination node may determine the second data node based on the logical value of the distribution key of the base table data in the first GSI data, and then send the third instruction to the second data node.
[0147] In this method, the coordination node can omit the process of calculating the logical value of the base table data distribution key through the base table data distribution key, which is conducive to the coordination node to quickly determine the second data node, thereby improving query efficiency.
[0148] Optionally, if the first GSI data also includes a portion of data required by the user, the first data node may send this portion of data to the coordination node.
[0149] In this embodiment, the coordinating node may send a first instruction to at least one data node, but the first data node that sends a second instruction to the coordinating node may be all of the at least one data node or may be some of the at least one data node.
[0150] In the present application, the distribution mode of the base table data may include multiple modes. Optionally, the base table data may also be stored in partitions, and the partitioning mode of the base table data may also include multiple modes. Next, the present application will further introduce the scheme of the present application in combination with the distribution mode and partitioning mode of the base table data.
[0151] In the following embodiments, the present application will take the case where the first data node sends the second instruction to the second data node as an example for explanation, and the case where the first data node sends the second instruction to the coordination node may be similar.
[0152] In the first example, the base table data is distributed in a hash distribution mode and is not partitioned.
[0153] Assume that Table 1 is a base table t1. The base table t1 may contain data in columns a, b, and c, where column a represents the distribution key of the base table data.
[0154] Table 1: Data and basic structure of base table t1
[0155] a b c 1 2 3 2 3 4
[0156] A GSI (which may be referred to as GSI-t1) is established on column b of base table t1. The data and structure of GSI-t1 may be as shown in Table 2.
[0157] Table 2: Data and basic structure of GSI-t1
[0158] b Hash value Location Information Transaction information 1 Transaction information 2 3 hash(2) (1,1) 100 0 2 hash(1) (1,2) 100 0
[0159] In Table 2, column b may be the index key of GSI-t1 and the distribution key of GSI-t1, and the hash value may be the logical value of the distribution key of the base table data corresponding to the GSI-t1 data. The location information is used to indicate the location of the base table data in the corresponding data node.
[0160] In this embodiment, the data of the base table t1 can be distributed to each data node according to the hash value of the distribution key of the base table data. For example, the base table data (1,2,3) can be distributed to data node 1, and the base table data (2,3,4) can be distributed to data node 2.
[0161] GSI-t1 data can be distributed to each data node according to the hash value of the distribution key of the GSI data. For example, GSI-t1 data (3, hash (2), (1, 1), 100, 0) can be distributed to data node 1, and GSI-t1 data (2, hash (1), (1, 2), 100, 0) can be distributed to data node 2.
[0162] It can be understood that Table 1 and Table 2 are only two simple examples. In actual application, the distribution key of the base table data in the base table t1 can be a string or any other data type that can be hashed.
[0163] Assume that the query instruction entered by the user on the client is: SELECT c FROM t1 WHERE b=2, the coordination node can determine to use table back query based on the query instruction. The coordination node can also determine that the data node that meets the first query condition is data node 2 based on the query instruction. Among them, the first query condition is b=2, and the data required by the user is the c column data with b=2 in the base table data.
[0164] In this example, data node 2 can be equivalent to Figure 3 or Figure 4 The first data node in the embodiment, data node 1, may be equivalent to Figure 3 or Figure 4 The second data node in an embodiment.
[0165] In this example, the first GSI data may include hash(1) and (1,2). Data node 2 may determine that the base table data satisfying b=2 is stored in data node 1 based on hash(1), and data node 2 may determine the storage location of the base table data satisfying b=2 in data node 1 based on (1,2).
[0166] In this example, data node 2 may send a second instruction to data node 1. After receiving the second instruction, data node 1 may determine first base table data based on the second instruction and send the first base table data to the coordination node, where the first base table data includes data required by the user.
[0167] In this example, the first base table data is 3.
[0168] In summary, an example of a data query method can be as follows Figure 5 shown.
[0169] Optionally, data node 2 may also send the first GSI data to data node 1. It is understood that the table query method for base table data based on range distribution, list distribution, etc. is consistent with the table query method for base table data based on hash distribution, and will not be repeated here. The difference is that the logical value of the distribution key of the base table data stored in GSI-t1 is different.
[0170] In the second example, the distribution mode of the base table data is hash distribution, and the partition mode of the base table data is hash partition.
[0171] Assume that Table 3 is the base table t2. The base table t2 may contain data in columns a, b, c, and d, where column a represents the distribution key of the base table data, column d is used to store the partition key of the base table data, and the partition key of the base table data is used to indicate the storage unit corresponding to the base table data.
[0172] Table 3: Data and basic structure of base table t2
[0173] a b c d 1 2 3 10000 2 3 4 10001
[0174] A GSI (which may be referred to as GSI-t2) is established on column b of base table t2. The data and structure of GSI-t2 may be as shown in Table 4.
[0175] Table 4: Data and basic structure of GSI-t2
[0176] b Hash value 1 Location Information Hash value 2 Transaction information 1 Transaction information 2 3 hash(2) (1,1) hash(10001) 100 0 2 hash(1) (1,2) hash(10000) 100 0
[0177] In Table 4, column b may be the index key of GSI-t2 and the distribution key of GSI-t2, hash value 1 may be the logical value of the distribution key of the base table data corresponding to the GSI-t2 data, and hash value 2 may be the logical value of the partition key of the base table data corresponding to the GSI-t2 data. The location information is used to indicate the location of the base table data in the corresponding data node.
[0178] In this embodiment, the data of the base table t2 can be distributed to each data node according to the hash value of the distribution key of the base table data. For example, the base table data (1,2,3,10000) can be distributed to data node 1, and the base table data (2,3,4,10001) can be distributed to data node 2.
[0179] GSI-t2 data can be distributed to each data node according to the hash value of the distribution key of the GSI data. For example, GSI-t2 data (3, hash (2), (1, 1), hash (10001), 100, 0) can be distributed to data node 1, and GSI-t2 data (2, hash (1), (1, 2), hash (10000), 100, 0) can be distributed to data node 2.
[0180] It can be understood that Table 3 and Table 4 are only two simple examples. In practical applications, the distribution key of the base table data in the base table t2 can be a string or any other data type that can be hashed.
[0181] Assume that the query instruction entered by the user on the client is: SELECT c FROM t2 WHERE b=2, the coordination node can determine to use table back query based on the query instruction. The coordination node can also determine that the data node that meets the first query condition is data node 2 based on the query instruction. Among them, the first query condition is b=2, and the data required by the user is the c column data with b=2 in the base table data.
[0182] In this example, data node 2 can be equivalent to Figure 3 or Figure 4 The first data node in the embodiment, data node 1, may be equivalent to Figure 3 or Figure 4 The second data node in an embodiment.
[0183] In this example, the first GSI data may include hash(1), (1,2), and hash(10000). Data node 2 may determine that the base table data satisfying b=2 is stored in data node 1 based on hash(1), and data node 2 may determine the storage location of the base table data satisfying b=2 in data node 1 based on (1,2). Data node 2 may determine the storage unit of the base table data satisfying b=2 in data node 1 based on hash(10000).
[0184] In this example, data node 2 may send a second instruction to data node 1. After receiving the second instruction, data node 1 may determine first base table data based on the second instruction and send the first base table data to the coordination node, where the first base table data includes data required by the user.
[0185] In this example, the first base table data is 3.
[0186] An example of a data query method can be as follows Figure 6 Optionally, data node 2 may also send first GSI data to data node 1.
[0187] In the third example, the distribution mode of the base table data is range distribution, and the partition mode of the base table data is range partitioning.
[0188] Assume that Table 5 is the base table t3. The base table t3 may contain data in columns a, b, c, and d, where column a represents the distribution key of the base table data, column d is used to store the partition key of the base table data, and the partition key of the base table data is used to indicate the storage unit corresponding to the base table data.
[0189] Table 5: Data and basic structure of base table t3
[0190] a b c d 1 2 3 10000 2 3 4 10001
[0191] A GSI (which may be referred to as GSI-t3) is created on column b of base table t3. The data and structure of GSI-t3 may be as shown in Table 6.
[0192] Table 6: Data and basic structure of GSI-t3
[0193] b Range 1 Location Information Range 2 Transaction information 1 Transaction information 2 3 range(2) (1,1) range(10001) 100 0 2 range(1) (1,2) range(10000) 100 0
[0194] In Table 6, column b may be the index key of GSI-t3 and the distribution key of GSI-t3, range 1 may be the logical value of the distribution key of the base table data corresponding to the GSI-t3 data, and range 2 may be the logical value of the partition key of the base table data corresponding to the GSI-t3 data. The location information is used to indicate the location of the base table data in the corresponding data node.
[0195] In this embodiment, the data of the base table t3 can be distributed to each data node according to the range of the distribution key of the base table data. For example, the base table data (1,2,3,10000) can be distributed to data node 1, and the base table data (2,3,4,10001) can be distributed to data node 2.
[0196] GSI-t3 data can be distributed to various data nodes according to the range of the distribution key of the GSI data. For example, GSI-t3 data (3, range (2), (1, 1), range (10001), 100, 0) can be distributed to data node 1, and GSI-t3 data (2, range (1), (1, 2), range (10000), 100, 0) can be distributed to data node 2.
[0197] It can be understood that Table 5 and Table 6 are only two simple examples. In actual application, the distribution key of the base table data in the base table t3 can be other types of data such as character strings.
[0198] Assume that the query instruction entered by the user on the client is: SELECT c FROM t3 WHERE b=2, the coordination node can determine to use table back query based on the query instruction. The coordination node can also determine that the data node that meets the first query condition is data node 2 based on the query instruction. Among them, the first query condition is b=2, and the data required by the user is the c column data with b=2 in the base table data.
[0199] In this example, data node 2 can be equivalent to Figure 3 or Figure 4 The first data node in the embodiment, data node 1, may be equivalent to Figure 3 or Figure 4 The second data node in an embodiment.
[0200] In this example, the first GSI data may include range(1), (1,2) and range(10000). Data node 2 may determine that the base table data satisfying b=2 is stored in data node 1 based on range(1), and data node 2 may determine the storage location of the base table data satisfying b=2 in data node 1 based on (1,2). Data node 2 may determine the storage unit of the base table data satisfying b=2 in data node 1 based on range(10000).
[0201] In this example, data node 2 may send a second instruction to data node 1. After receiving the second instruction, data node 1 may determine first base table data based on the second instruction and send the first base table data to the coordination node, where the first base table data includes data required by the user.
[0202] In this example, the first base table data is 3.
[0203] In summary, an example of a data query method can be as follows Figure 7 shown.
[0204] Optionally, data node 2 may also send first GSI data to data node 1 .
[0205] In the fourth example, the distribution mode of the base table data is list distribution, and the partition mode of the base table data is list partitioning.
[0206] Assume that Table 7 is the base table t4. The base table t4 may contain data in columns a, b, c, and d, wherein column a represents the distribution key of the base table data, column d is used to store the partition key of the base table data, and the partition key of the base table data is used to indicate the storage unit corresponding to the base table data.
[0207] Table 7: Data and basic structure of base table t4
[0208] a b c d 1 2 3 10000 2 3 4 10001
[0209] A GSI (which may be referred to as GSI-t4) is created on column b of base table t4. The data and structure of GSI-t4 may be as shown in Table 8.
[0210] Table 8: Data and basic structure of GSI-t4
[0211] b List map value 1 Location Information List map value 2 Transaction information 1 Transaction information 2 3 list(2) (1,1) list(10001) 100 0 2 list(1) (1,2) list(10000) 100 0
[0212] In Table 8, column b may be the index key of GSI-t4 and the distribution key of GSI-t4, list mapping value 1 may be the logical value of the distribution key of the base table data corresponding to the GSI-t4 data, and list mapping value 2 may be the logical value of the partition key of the base table data corresponding to the GSI-t4 data. The location information is used to indicate the location of the base table data in the corresponding data node.
[0213] In this embodiment, the data of the base table t4 can be distributed to each data node according to the list mapping value of the distribution key of the base table data. For example, the base table data (1,2,3,10000) can be distributed to data node 1, and the base table data (2,3,4,10001) can be distributed to data node 2.
[0214] GSI-t4 data can be distributed to each data node according to the list mapping value of the distribution key of the GSI data. For example, GSI-t4 data (3, list (2), (1, 1), list (10001), 100, 0) can be distributed to data node 1, and GSI-t4 data (2, list (1), (1, 2), list (10000), 100, 0) can be distributed to data node 2.
[0215] It can be understood that Table 7 and Table 8 are only two simple examples. In actual application, the distribution key of the base table data in the base table t4 can be other types of data such as character strings.
[0216] Assume that the query instruction entered by the user on the client is: SELECT c FROM t4 WHERE b=2, the coordination node can determine to use the back table query based on the query instruction. The coordination node can also determine that the data node that meets the first query condition is data node 2 based on the query instruction. Among them, the first query condition is b=2, and the data required by the user is the c column data with b=2 in the base table data.
[0217] In this example, data node 2 can be equivalent to Figure 3 or Figure 4 The first data node in the embodiment, data node 1, may be equivalent to Figure 3 or Figure 4 The second data node in an embodiment.
[0218] In this example, the first GSI data may include list(1), (1,2) and list(10000). Data node 2 may determine that the base table data satisfying b=2 is stored in data node 1 based on list(1), and data node 2 may determine the storage location of the base table data satisfying b=2 in data node 1 based on (1,2). Data node 2 may determine the storage unit of the base table data satisfying b=2 in data node 1 based on list(10000).
[0219] In this example, data node 2 may send a second instruction to data node 1. After receiving the second instruction, data node 1 may determine first base table data based on the second instruction and send the first base table data to the coordination node, where the first base table data includes data required by the user.
[0220] In this example, the first base table data is 3.
[0221] In summary, an example of a data query method can be as follows Figure 8 shown.
[0222] Optionally, data node 2 may also send first GSI data to data node 1 .
[0223] In the fifth example, the distribution mode of the base table data is hash distribution, and the partition mode of the base table data is range partitioning.
[0224] Assume that Table 9 is the base table t5. The base table t5 may contain data in columns a, b, c, and d, wherein column a represents the distribution key of the base table data, column d is used to store the partition key of the base table data, and the partition key of the base table data is used to indicate the storage unit corresponding to the base table data.
[0225] Table 9: Data and basic structure of base table t5
[0226] a b c d 1 2 3 10000 2 3 4 10001
[0227] A GSI (which may be referred to as GSI-t5) is established on column b of base table t5. The data and structure of GSI-t5 may be as shown in Table 10.
[0228] Table 10: Data and basic structure of GSI-t5
[0229] b Hash value Location Information Range Value Transaction information 1 Transaction information 2 3 hash(2) (1,1) range(10001) 100 0 2 hash(1) (1,2) range(10000) 100 0
[0230] In Table 10, column b may be the index key of GSI-t5 and the distribution key of GSI-t5, and the hash value may be the logical value of the distribution key of the base table data corresponding to the GSI-t5 data. The location information is used to indicate the location of the base table data in the corresponding data node. The partition key is used to indicate the storage unit of the base table data in the data node.
[0231] In this embodiment, the data of the base table t5 can be distributed to each data node according to the list mapping value of the distribution key of the base table data. For example, the base table data (1,2,3,10000) can be distributed to data node 1, and the base table data (2,3,4,10001) can be distributed to data node 2.
[0232] GSI-t5 data can be distributed to each data node according to the list mapping value of the distribution key of the GSI data. For example, GSI-t5 data (3, hash (2), (1, 1), range (10001), 100, 0) can be distributed to data node 1, and GSI-t4 data (2, hash (1), (1, 2), range (10000), 100, 0) can be distributed to data node 2.
[0233] It can be understood that Table 9 and Table 10 are only two simple examples. In actual application, the distribution key of the base table data in the base table t5 can be a string or any other data type that can be hashed.
[0234] Assume that the query instruction entered by the user on the client is: SELECT c FROM t5 WHERE b=2, the coordination node can determine to use table back query based on the query instruction. The coordination node can also determine that the data node that meets the first query condition is data node 2 based on the query instruction. Among them, the first query condition is b=2, and the data required by the user is the c column data with b=2 in the base table data.
[0235] In this example, data node 2 can be equivalent to Figure 3 or Figure 4 The first data node in the embodiment, data node 1, may be equivalent to Figure 3 or Figure 4 The second data node in an embodiment.
[0236] In this example, the first GSI data may include hash(1), (1,2) and range(10000). Data node 2 may determine that the base table data satisfying b=2 is stored in data node 1 based on hash(1), and data node 2 may determine the storage location of the base table data satisfying b=2 in data node 1 based on (1,2). Data node 2 may determine the storage unit of the base table data satisfying b=2 in data node 1 based on range(10000).
[0237] In this example, data node 2 may send a second instruction to data node 1. After receiving the second instruction, data node 1 may determine first base table data based on the second instruction and send the first base table data to the coordination node, where the first base table data includes data required by the user.
[0238] In this example, the first base table data is 3.
[0239] In summary, an example of a data query method can be as follows Fig. 9 shown.
[0240] Optionally, data node 2 may also send first GSI data to data node 1 .
[0241] It is understandable that this application only provides five examples of table query based on distribution mode and partition mode. The distribution mode and partition mode of base table data can be combined at will, and this application will not repeat them.
[0242] Fig.10 FIG. 1 is a schematic diagram of the structure of a data query device according to an embodiment of the present application. Fig.10 As shown, the data query device 1000 may include a receiving module 1001, a query module 1002 and a sending module 1003. The data query device 1000 may be applied in a first data node.
[0243] As a first example, the data query device 1000 can be used to implement Figure 3 The data query method of the illustrated embodiment: wherein the receiving module 1001 can be used to execute the receiving step in S301, the query module 1002 can be used to execute S302, and the sending module 1003 can be used to execute the sending step in S303.
[0244] As a second example, the data query device 1000 can also be used to implement Figure 4 The data query method of the illustrated embodiment: wherein the receiving module 1001 can be used to execute the receiving step in S401, the query module 1002 can be used to execute S402, and the sending module 1003 can be used to execute the sending step in S403.
[0245] Fig.11 FIG. 1 is a schematic diagram of the structure of a data query device according to another embodiment of the present application. Fig.11 As shown, the data query device 1100 may include a sending module 1101 and a receiving module 1102. The data query device 1100 may be applied in a coordination node.
[0246] As a first example, the data query device 1100 can be used to implement Figure 3 The data query method of the illustrated embodiment: wherein the sending module 1101 can be used to execute the sending step in S301, and the receiving module 1102 can be used to execute the receiving step in S303.
[0247] As a second example, the data query device 1100 can also be used to implement Figure 4 The data query method of the illustrated embodiment: wherein the sending module 1101 can be used to execute the sending steps in S401 and S404, and the receiving module 1102 can be used to execute the receiving step in S403.
[0248] Fig.12 This is a schematic diagram of the structure of a data query device provided by another embodiment of the present application. Fig.12 As shown, the data query device 1200 includes a processor 1201 and an interface circuit 1202. The processor 1201 and the interface circuit 1202 are coupled to each other. It is understood that the interface circuit 1202 can be a transceiver or an input-output interface. Optionally, the data query device 1200 can also include a memory 1203 for storing instructions executed by the processor 1201 or storing input data required by the processor 1201 to run the instructions or storing data generated after the processor 1201 runs the instructions.
[0249] As a first example, the processor 1201 is used to implement the functions of the query module 1002 , and the interface circuit 1202 is used to implement the functions of the receiving module 1001 and the sending module 1003 .
[0250] As a second example, the interface circuit 1202 is used to implement the functions of the above-mentioned sending module 1101 and receiving module 1102.
[0251] The data query apparatus 1200 may be a data query device, or may be a chip used in a data query device.
[0252] The method steps in the embodiments of the present application can be implemented by hardware, or by a processor executing software instructions. The software instructions can be composed of corresponding software modules, and the software modules can be stored in a random access memory, a flash memory, a read-only memory, a programmable read-only memory, an erasable programmable read-only memory, an electrically erasable programmable read-only memory, a register, a hard disk, a mobile hard disk, a CD-ROM, or any other form of storage medium well known in the art. An exemplary storage medium is coupled to the processor so that the processor can read information from the storage medium and can write information to the storage medium. Of course, the storage medium can also be a component of the processor. The processor and the storage medium can be located in an ASIC. In addition, the ASIC can be located in a network device or a terminal device. Of course, the processor and the storage medium can also be present in a network device or a terminal device as discrete components.
[0253] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented by software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer programs or instructions. When the computer program or instruction is loaded and executed on a computer, the process or function described in the embodiment of the present application is executed in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, a network device, a user device or other programmable device. The computer program or instruction may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer program or instruction may be transmitted from one website site, computer, server or data center to another website site, computer, server or data center by wired or wireless means. The computer-readable storage medium may be any available medium that a computer can access or a data storage device such as a server, data center, etc. that integrates one or more available media. The available medium may be a magnetic medium, for example, a floppy disk, a hard disk, a tape; it may also be an optical medium, for example, a digital video disc; it may also be a semiconductor medium, for example, a solid-state hard disk.
[0254] In the various embodiments of the present application, unless otherwise specified or provided for in any logical conflict, the terms and / or descriptions between the different embodiments are consistent and may be referenced to each other, and the technical features in the different embodiments may be combined to form new embodiments according to their inherent logical relationships.
[0255] It is understood that the various numbers involved in the embodiments of the present application are only for the convenience of description and are not used to limit the scope of the embodiments of the present application. The size of the sequence number of the above-mentioned processes does not mean the order of execution, and the execution order of each process should be determined by its function and internal logic.
Claims
1. A data query method, the method is applied to a first data node, characterized in that: The first data node stores global secondary index GSI data, the GSI data includes a first index and a first logical value, the first index is an index of base table data, and the first logical value is a logical value of a distribution key of the base table data, and the method includes: Receiving a first instruction from a coordination node, wherein the first instruction is used to request to query base table data that meets a first query condition by a table return query method; Performing a query based on the first instruction to obtain first GSI data, where a first index in the first GSI data satisfies the first query condition; A second instruction is sent, where the second instruction is used to indicate that the base table data satisfying the first query condition is stored in a second data node, and the logical value of the distribution key of the base table data stored in the second data node is equal to the first logical value in the first GSI data.
2. The method according to claim 1, characterized in that: The logical value of the distribution key of the base table data includes any one of the following: a hash value mapping value of the distribution key of the base table data, a range mapping value of the distribution key of the base table data, and a list mapping value of the distribution key of the base table data.
3. The method according to claim 1 or 2, characterized in that: The sending of the second instruction comprises: Send the second instruction to the second data node.
4. The method according to claim 1 or 2, characterized in that: The sending of the second instruction comprises: The second instruction is sent to the coordinating node.
5. The method according to any one of claims 1 to 4, characterized in that The GSI data further includes a second logical value, which is a logical value of a partition key of the base table data, and the logical value of the partition key of the base table data includes any one of the following: a hash value mapping value of the partition key of the base table data, a range mapping value of the partition key of the base table data, and a list mapping value of the partition key of the base table data; The logical value of the partition key of the base table data stored in the second data node is equal to the second logical value in the first GSI data.
6. A data query method, the method being applied in a coordination node, characterized in that: The method comprises: Sending a first instruction to at least one data node, each of the at least one data node stores global secondary index GSI data, the GSI data includes a first index and a first logical value, the first index is an index of base table data, the first logical value is a logical value of a distribution key of the base table data, and the first instruction is used to request to query the base table data that meets the first query condition by a table back query method; Receive a second instruction from a first data node among the at least one data node, where the second instruction is used to indicate that base table data that meets the first query condition is stored in the second data node, the logical value of the distribution key of the base table data stored in the second data node is equal to the first logical value in the first GSI data, and the first index in the first GSI data meets the first query condition.
7. The method according to claim 6, characterized in that The logical value of the distribution key of the base table data includes any one of the following: a hash value mapping value of the distribution key of the base table data, a range mapping value of the distribution key of the base table data, and a list mapping value of the distribution key of the base table data.
8. The method according to claim 6 or 7, characterized in that: The GSI data further includes a second logical value, which is a logical value of a partition key of the base table data, and the logical value of the partition key of the base table data includes any one of the following: a hash value mapping value of the partition key of the base table data, a range mapping value of the partition key of the base table data, and a list mapping value of the partition key of the base table data; The logical value of the partition key of the base table data stored in the second data node is equal to the second logical value in the first GSI data.
9. A data query device, characterized in that: The method comprises a functional module for implementing the method according to any one of claims 1 to 5, or comprises a functional module for implementing the method according to any one of claims 6 to 8.
10. A data query device, characterized in that: include: Memory and processor; The memory is used to store program instructions; The processor is used to execute the program instructions in the memory to implement the method according to any one of claims 1 to 5, or is used to execute the program instructions in the memory to implement the method according to any one of claims 6 to 8.
11. A communication system, characterized in that: The communication system comprises a data node and a coordination node, the data node is used to implement the method according to any one of claims 1 to 5, and the coordination node is used to implement the method according to any one of claims 6 to 8.
12. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a program code for computer execution, wherein the program code includes instructions for implementing the method as claimed in any one of claims 1 to 5 or any one of claims 6 to 8.
13. A computer program product, characterized in that The computer program product comprises instructions for implementing the method as claimed in any one of claims 1 to 5 or any one of claims 6 to 8.
Citation Information
Patent Citations
Distributed key-value query method and query engine system
CN102591970A
Data query method and device, storage medium and electronic equipment
CN110704453A
Case data query method, system and device and computer readable storage medium
CN112579608A
Data storage method and device, and server
CN114064706A
Distributed database system for establishing global index and capability improving method
CN114328717A
Cited By
Optimized query method and device, equipment, medium and product
CN120994701A
Data query method and related device
EP4672021A1
Data query method and related device
WO2024198882A1
