Data query method, device and electronic device

By building only one hash table with a specified memory in the computing nodes of the distributed database, the problems of excessive memory and CPU consumption and excessive network bandwidth consumption caused by the hash join algorithm are solved, and more efficient data query is achieved.

CN113377774BActive Publication Date: 2025-03-07BEIJING KINGSOFT CLOUD NETWORK TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202110645512.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-06-09
Publication Date
2025-03-07
Estimated Expiration
2041-06-09

AI Technical Summary

Technical Problem

In distributed databases, hash join algorithms result in high memory and CPU usage on computing nodes, as well as significant network bandwidth consumption, which current technologies have not been able to effectively address.

Method used

Only one hash table with a specified memory is built in the compute node to communicate with multiple storage nodes, reducing memory and CPU usage, and data that meets the query conditions is obtained through this hash table.

Benefits of technology

It reduces memory and CPU usage, lowers network bandwidth consumption, and improves the efficiency of hash connections.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113377774B_ABST
    Figure CN113377774B_ABST
Patent Text Reader

Abstract

The present invention provides a data query method, device and electronic device, wherein a computing node receives a data query instruction sent by a user end and carries a first identifier of a first logic table, a second identifier of a second logic table and a query condition; a hash table of the first logic table is established in a designated memory according to the data of the first logic table pulled from multiple storage nodes; first data satisfying the query condition is obtained from the data of the second logic table stored in multiple storage nodes; second data satisfying the query condition is obtained from the hash table; and a query result determined based on the first data and the second data is returned to the user end. The computing node of this method constructs a hash table in a designated memory accessible to each storage node, and realizes data query through the hash table and the data stored in multiple storage nodes. Compared with the method in which the computing node stores multiple hash tables, this method reduces the occupation of memory and CPU, as well as the occupation of network bandwidth during data query.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of data processing technology, and in particular to a data query method, device and electronic equipment. Background Art

[0002] The hash join algorithm (hash join algorithm for short) is usually a table joining method that relies on hash operations to obtain the joining result set when two tables are joined.

[0003] In a distributed database, computing nodes connect to multiple storage nodes; computing nodes communicate with each storage node through a hash connection algorithm. Specifically, each storage node stores different internal table data, and computing nodes can pull the internal table data stored in all storage nodes to establish a full hash table. At the same time, a copy of the hash table must be made in the local memory corresponding to each storage node to facilitate parallel processing of data between computing nodes and storage nodes. However, multiple copies of the hash table are stored in the computing node, resulting in large memory and CPU usage. At the same time, each of the multiple copies of data needs to pull data from the storage node for hash table query, resulting in large network bandwidth usage. Summary of the invention

[0004] The object of the present invention is to provide a data query method, device and electronic device to reduce memory and CPU usage and reduce network bandwidth usage.

[0005] In a first aspect, the present invention provides a data query method, which is applied to a computing node of a distributed database; the computing node is communicatively connected to multiple storage nodes; the multiple storage nodes store data of a first logical table and data of a second logical table; the method comprises: receiving a data query instruction sent by a user terminal; wherein the data query instruction carries a first identifier of the first logical table, a second identifier of the second logical table and a query condition; pulling data of the first logical table from multiple storage nodes, and establishing a hash table corresponding to the first logical table in a designated memory according to the pulled data; wherein the hash table of the designated memory is used to: provide data to be queried for each storage node; obtain first data that meets the query condition from the data of the second logical table stored in multiple storage nodes; obtain second data that meets the query condition from the hash table; based on the first data and the second data, determine a query result corresponding to the data query instruction, and return the query result to the user terminal.

[0006] In an optional embodiment, the above-mentioned step of determining the query result corresponding to the data query instruction based on the first data and the second data includes: determining multiple target information that meet the query conditions from the first data and the second data; splicing the multiple target information to obtain a splicing result; and determining the splicing result as the query result corresponding to the data query instruction.

[0007] In an optional implementation, the step of splicing the multiple target data information to obtain a splicing result includes: splicing the multiple target information using multiple threads to obtain a splicing result.

[0008] In an optional embodiment, the above-mentioned step of obtaining the first data that meets the query condition from the data of the second logical table stored in multiple storage nodes includes: for each storage node in the multiple storage nodes, performing the following operations in parallel: pulling the data of the second logical table from the storage node; and querying the first data that meets the query condition from the data of the second logical table.

[0009] In an optional implementation, after the step of searching the data of the second logic table for the first data that meets the query condition, the method further includes: deleting the pulled data of the second logic table.

[0010] In an optional implementation, after the above step of returning the query result to the user end, the method further includes: releasing the hash table from the designated memory.

[0011] In a second aspect, the present invention provides a data query device, which is arranged at a computing node of a distributed database; the computing node is communicatively connected to multiple storage nodes; the multiple storage nodes store data of a first logical table and data of a second logical table; the device includes: an instruction receiving module, used to receive a data query instruction sent by a user terminal; wherein the data query instruction carries a first identifier of the first logical table, a second identifier of the second logical table and a query condition; a hash table establishment module, used to pull data of the first logical table from multiple storage nodes, and establish a hash table corresponding to the first logical table in a designated memory according to the pulled data; wherein the hash table of the designated memory is used to: provide data to be queried for each storage node; a data query module, used to obtain first data that meets the query condition from the data of the second logical table stored in multiple storage nodes; obtain second data that meets the query condition from the hash table; a result return module, used to determine the query result corresponding to the data query instruction based on the first data and the second data, and return the query result to the user terminal.

[0012] In an optional implementation, the above-mentioned result return module is also used to: determine multiple target information that meets the query conditions from the first data and the second data; splice the multiple target information to obtain a splicing result; and determine the splicing result as the query result corresponding to the data query instruction.

[0013] In a third aspect, the present invention provides an electronic device, comprising a processor and a memory, wherein the memory stores machine executable instructions that can be executed by the processor, and the processor executes the machine executable instructions to implement the data query method described in any one of the aforementioned implementations.

[0014] In a fourth aspect, the present invention provides a machine-readable storage medium storing machine-executable instructions. When the machine-executable instructions are called and executed by a processor, the machine-executable instructions prompt the processor to implement the data query method described in any one of the aforementioned implementations.

[0015] The embodiments of the present invention bring the following beneficial effects:

[0016] The present invention provides a data query method, device and electronic device. The computing node first receives a data query instruction sent by a user terminal, and the data query instruction carries a first identifier of a first logic table, a second identifier of a second logic table and a query condition; then pulls the data of the first logic table from multiple storage nodes connected to the computing node, and establishes a hash table corresponding to the first logic table in a designated memory according to the pulled data; then obtains the first data that meets the query condition from the data of the second logic table stored in multiple storage nodes, and obtains the second data that meets the query condition from the hash table; then determines the query result corresponding to the data query instruction based on the first data and the second data, and returns the query result to the user terminal. The computing node of this method constructs a hash table in a designated memory that each storage node can access, and implements data query through the hash table and the data stored in multiple storage nodes. Compared with the method in which the computing node stores multiple hash tables, this method reduces the memory and CPU usage, and also reduces the network bandwidth usage during data query.

[0017] Other features and advantages of the present invention will be set forth in the following description, or some features and advantages may be inferred or unambiguously determined from the description, or may be learned by implementing the above-mentioned technology of the present invention.

[0018] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, preferred embodiments are specifically listed below and described in detail with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0020] Figure 1 A schematic diagram of a hash connection algorithm provided in the related art provided in an embodiment of the present invention;

[0021] Figure 2 A flow chart of a data query method provided by an embodiment of the present invention;

[0022] Figure 3 A flowchart of another data query method provided by an embodiment of the present invention;

[0023] Figure 4 A schematic diagram of the structure of a data query device provided by an embodiment of the present invention;

[0024] Figure 5 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0025] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Generally, the components of the embodiments of the present invention described and shown in the drawings here can be arranged and designed in various different configurations.

[0026] Therefore, the following detailed description of the embodiments of the present invention provided in the accompanying drawings is not intended to limit the scope of the invention claimed for protection, but merely represents selected embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0027] In a distributed database, computing nodes connect to multiple storage nodes; computing nodes communicate with each storage node through a hash connection algorithm, such as Figure 1 FIG. 1 is a schematic diagram of a hash connection algorithm provided in the related art. Figure 1 The computing nodes in the system are responsible for the parsing and parallel computing of SQL (Structured Query Language). Figure 1 There are two storage nodes (or two storage node clusters) in Group 0 and Group 1. Each storage node stores different internal table data and external table data ( Figure 1 T1 is the inner table data, T2 is the outer table data, T1 and T2 are both logical tables, T1_0, T1_1, T1_2, T1_3 are the physical subtables corresponding to T1; T2_0, T2_1, T2_2 and T2_3 are the physical subtables corresponding to T2).

[0028] Specifically, the computing node can pull the internal table data stored in all storage nodes and establish a full hash table for each storage node, that is, the hash table corresponding to each storage node is the same, and the hash table corresponding to each storage node is stored in the memory of the computing node that can only be accessed by the storage node. Figure 1 If there are two storage nodes in the system, two hash tables are built in the computing node to facilitate parallel data processing between the computing node and the storage node. However, multiple copies of the hash table are stored in the computing node, resulting in large memory and CPU usage. At the same time, each of the multiple copies of data needs to be pulled from the storage node for hash table query, resulting in large network bandwidth usage.

[0029] Based on the above problems, the embodiments of the present invention provide a data query method, device and electronic device; the technology can be applied to data access, data query and other scenarios of distributed databases. To facilitate understanding of the present embodiment, a data query method disclosed in the embodiment of the present invention is first described in detail. The method is applied to a computing node of a distributed database; the computing node is connected to multiple storage nodes in communication; the multiple storage nodes store data of a first logical table and data of a second logical table; Figure 2 As shown, the method comprises the following specific steps:

[0030] Step S202, receiving a data query instruction sent by the user terminal; wherein the data query instruction carries a first identifier of the first logical table, a second identifier of the second logical table, and a query condition.

[0031] The above data query instruction may be sent by a user through a user terminal, and the user terminal may be a mobile terminal (e.g., a mobile phone, a tablet computer, etc.), or a computer, etc. The above data query instruction carries the identifiers of the first logic table and the second logic table to be queried, as well as the query conditions. The data in the first logic table may be the internal table data stored in the storage node, and the data in the second logic table may be the external table data stored in the storage node. Each storage node may store part of the data in the first logic table and part of the data in the second logic table, and the data stored in each storage node is different. It can also be understood that the data stored in multiple storage nodes are integrated to obtain the complete data of the first logic table and the complete data of the second logic table.

[0032] In the specific implementation, a unique identifier has been set for each logical table when constructing the logical table, so as to find the corresponding logical table. Usually, the logical table is constructed by SQL statements, and the inner table and outer table are defined according to the different positions of the logical table identifier in the SQL statement. For example, the SQL statement is: select * from T2 left join T1 on T2.id = T1.id; T2 is on the left and T1 is on the right, then T2 is the outer table and T1 is the inner table, where T1 and T2 can also be understood as the identifiers of the inner table and the outer table.

[0033] Step S204, pull data of the first logic table from multiple storage nodes, and create a hash table corresponding to the first logic table in a designated memory according to the pulled data; wherein the hash table in the designated memory is used to provide data to be queried for each storage node.

[0034] After receiving the data query instruction, the computing node needs to pull the data of the first logical table (equivalent to the internal table data mentioned above) from each storage node of the multiple storage nodes connected to it, and then establish a hash table corresponding to the full amount of the first logical table in the pre-applied designated memory according to the pulled data. The designated memory is a piece of global memory in the computing node. The hash table corresponding to the first logical table is stored in the global memory, which can ensure that each storage node connected to the computing node can access the designated memory and obtain the data to be queried from the designated memory.

[0035] In the present invention, only one copy of the internal table data is stored in the computing node, and only one full hash table needs to be established, and there is no need to establish a full hash table for each storage node, thereby reducing memory usage.

[0036] Step S206, obtaining first data satisfying the query condition from the data of the second logic table stored in the plurality of storage nodes; and obtaining second data satisfying the query condition from the hash table.

[0037] When the hash table is built, the computing node needs to obtain data that meets the query condition in the data query instruction (equivalent to the first data mentioned above) from the data of the second logical table stored in the multiple storage nodes. It can also be understood that the computing node obtains the first data that meets the query condition from the external table data stored in the storage node. Then, the computing node obtains the second data that meets the query condition from the hash table stored in the specified memory.

[0038] Step S208: determining a query result corresponding to the data query instruction based on the first data and the second data, and returning the query result to the user end.

[0039] In specific implementation, after the first data and the second data are queried, the first data and the second data need to be integrated and processed according to the query conditions to determine the final query result, and the query result is returned to the user end, thereby completing the data query.

[0040] A data query method provided by an embodiment of the present invention comprises the following steps: a computing node first receives a data query instruction sent by a user terminal, wherein the data query instruction carries a first identifier of a first logical table, a second identifier of a second logical table, and a query condition; then the computing node pulls data of the first logical table from multiple storage nodes connected to the computing node, and establishes a hash table corresponding to the first logical table in a designated memory according to the pulled data; then the computing node obtains first data satisfying the query condition from data of the second logical table stored in multiple storage nodes, and obtains second data satisfying the query condition from the hash table; then, based on the first data and the second data, the computing node determines a query result corresponding to the data query instruction, and returns the query result to the user terminal. The computing node of this method constructs a hash table in a designated memory accessible to each storage node, and implements data query through the hash table and the data stored in multiple storage nodes. Compared with the method in which the computing node stores multiple hash tables, this method reduces the memory and CPU usage, and also reduces the network bandwidth usage during data query.

[0041] The embodiment of the present invention also provides another data query method, which is implemented on the basis of the method of the above embodiment; the method focuses on describing the specific process of obtaining the first data that meets the query condition from the data of the second logical table stored in multiple storage nodes (implemented by the following step S306), including: based on the first data and the second data, determining the specific process of the query result corresponding to the data query instruction (implemented by the following steps S310-S312); Figure 3 As shown, the method comprises the following specific steps:

[0042] Step S302, receiving a data query instruction sent by a user terminal; the data query instruction carries a first identifier of a first logic table, a second identifier of a second logic table, and a query condition.

[0043] Step S304: pull data of the first logic table from multiple storage nodes, and create a hash table corresponding to the first logic table in a designated memory according to the pulled data.

[0044] Step S306 , for each storage node among the multiple storage nodes, performing the following operations in parallel: pulling data of the second logic table from the storage node; and searching the data of the second logic table for first data that meets the query condition.

[0045] The computing node may concurrently pull the data of the second logic table of each storage node (equivalent to the external table data) from the multiple storage nodes, and then query the first data satisfying the query condition from the pulled data of the second logic table.

[0046] In a specific implementation, after the first data satisfying the query condition is queried from the data of the second logic table, it is necessary to delete the pulled data of the second logic table to release memory and reduce memory usage.

[0047] Step S308: Obtain second data satisfying the query condition from the hash table.

[0048] Step S310: determining a plurality of target information satisfying a query condition from the first data and the second data.

[0049] Step S312, performing splicing processing on multiple target information to obtain a splicing result; and determining the splicing result as the query result corresponding to the data query instruction.

[0050] In a specific implementation, multiple target information meeting the query condition can be determined from the first data and the second data, and then the target information needs to be spliced, and the spliced ​​result obtained after the splicing process is used as the query result corresponding to the data query instruction.

[0051] In some embodiments, in order to return data that meets the query conditions as quickly as possible, multiple threads can be used to splice multiple target information to obtain a splicing result. It can also be understood that this method can use one thread to pull external data from multiple storage nodes, and then use multiple threads to splice data that meets the query conditions (equivalent to the above target information).

[0052] Step S314, returning the above query result to the user end.

[0053] In the specific implementation, after returning the query results to the user end, it is also necessary to release the hash table from the specified memory to release the space of the specified memory and provide sufficient memory space for the storage of internal table data and the construction of the hash table during the next data query.

[0054] In order to facilitate understanding of the embodiments of the present invention, the following is a detailed description of the query condition of the data query request for querying the data with the same place of origin in two logical tables. Assume that the computing node receives the data query request in SQL language sent by the client: select t2.birthplace, t2.name, t1.name from t2 left join t2 on t2.birthplace = t1.birthplace; wherein t1 represents the first identifier of the first logical table, t2 represents the second identifier of the second logical table, and birthplace represents the place of origin. After receiving the data query request, the computing node will pull the data of the first logical table stored in multiple storage nodes connected to the computing node according to the first identifier, and build a hash table corresponding to the first logical table (equivalent to the above hash table) based on the pulled data. The data related to the first logical table and the hash table are all stored in the global memory (equivalent to the above specified memory). For example, a hash table h1 is built. Assume that the hash table uses the third column of the data as the key to query the data with the same place of origin in the two tables. The hash table specifically includes the following contents:

[0055] beijing:0,xiaoming,beijing,20;

[0056] tianjin:1,xiaohong,tianjin,18;

[0057] xian:2,xiaojing,xian,21;

[0058] chengdu:3,xiaowei,chengdu,22;

[0059] The part before the colon is the key, and the part after the colon is the value.

[0060] Then the computing node concurrently pulls the data of the second logic table from each storage node according to the second identifier, and determines the first data that meets the query condition; then it searches the hash table h1 stored in the global memory to obtain the second data. Assuming that the first data determined from the second logic table is 1, xiaowang, tianjin, 25, the native place information tianjin is taken out; then the hash table is searched, and the second data is 1, xiaohong, tianjin, 18, and the native place is tianjin; that is, the data that meet the conditions in the two tables are: 1, xiaohong, tianjin, 18 in the hash table, and 1, xiaowang, tianjin, 25 in the first logic table. Assuming that the information to be obtained is only the native place, the name in the inner table (the name in the hash table), and the name in the outer table (the name in the second logic table), then the data that meets the conditions needs to be processed and spliced ​​(multi-threaded concurrent processing can be used), and the splicing result is: tianjian, xiaohong, xiaowang, and then the splicing result is returned to the caller.

[0061] In the above data query method, first, the computing node receives the data query instruction sent by the user end, which carries the first identifier of the first logical table, the second identifier of the second logical table, and the query condition; then, based on the data of the first logical table pulled from multiple storage nodes, a hash table corresponding to the first logical table is established in the designated memory; then, for each storage node in the multiple storage nodes, the following operations are performed in parallel: pull the data of the second logical table from the storage node; query the first data that meets the query condition from the data of the second logical table; then obtain the second data that meets the query condition from the hash table; then determine multiple target information that meets the query condition from the first data and the second data, perform splicing processing on the multiple target information to obtain the splicing result, and determine the splicing result as the query result corresponding to the data query instruction and return it to the user end. This method only needs to retain a copy of the internal table data in the computing node and build a hash table, which saves memory, CPU and network resources, and improves the efficiency of hash connection.

[0062] In view of the above-mentioned data query method embodiment, the present invention provides a data query device, which is arranged in a computing node of a distributed database; the computing node is communicatively connected with a plurality of storage nodes; the plurality of storage nodes store data of a first logic table and data of a second logic table; Figure 4 As shown, the device comprises:

[0063] The instruction receiving module 40 is used to receive a data query instruction sent by a user terminal; wherein the data query instruction carries a first identifier of the first logic table, a second identifier of the second logic table and a query condition.

[0064] The hash table establishment module 41 is used to pull data of the first logic table from multiple storage nodes, and establish a hash table corresponding to the first logic table in a designated memory according to the pulled data; wherein the hash table in the designated memory is used to provide data to be queried for each storage node.

[0065] The data query module 42 is used to obtain first data that meets the query condition from the data of the second logic table stored in multiple storage nodes; and obtain second data that meets the query condition from the hash table.

[0066] The result returning module 43 is used to determine the query result corresponding to the data query instruction based on the first data and the second data, and return the query result to the user end.

[0067] In the above data query device, the computing node first receives a data query instruction sent by the user end, and the data query instruction carries the first identifier of the first logic table, the second identifier of the second logic table and the query condition; then pulls the data of the first logic table from the multiple storage nodes connected to the computing node, and establishes a hash table corresponding to the first logic table in the designated memory according to the pulled data; then obtains the first data that meets the query condition from the data of the second logic table stored in the multiple storage nodes, and obtains the second data that meets the query condition from the hash table; then determines the query result corresponding to the data query instruction based on the first data and the second data, and returns the query result to the user end. The computing node of this method constructs a hash table in the designated memory that each storage node can access, and realizes data query through the hash table and the data stored in multiple storage nodes. Compared with the method in which the computing node stores multiple hash tables, this method reduces the memory and CPU usage, and also reduces the network bandwidth usage during data query.

[0068] Furthermore, the result returning module 43 is also used to: determine multiple target information satisfying the query condition from the first data and the second data; perform splicing processing on the multiple target information to obtain a splicing result; and determine the splicing result as the query result corresponding to the data query instruction.

[0069] In a specific implementation, the result returning module 43 is further used to: use multiple threads to splice multiple target information to obtain a splicing result.

[0070] Furthermore, the data query module 42 is also used to: for each storage node among the multiple storage nodes, perform the following operations in parallel: pull the data of the second logic table from the storage node; and query the first data that meets the query condition from the data of the second logic table.

[0071] Specifically, the above-mentioned device further includes a data deletion module, which is used to delete the pulled data of the second logical table after searching the data of the second logical table for the first data that meets the query condition.

[0072] In some embodiments, the above-mentioned device also includes a table deletion module, which is used to release the hash table from the designated memory after returning the query result to the user end.

[0073] The data query device provided in the embodiment of the present invention has the same implementation principle and technical effects as those of the aforementioned method embodiment. For the sake of brief description, for matters not mentioned in the device embodiment, reference may be made to the corresponding contents in the aforementioned method embodiment.

[0074] The embodiment of the present invention further provides an electronic device, such as Figure 5 As shown, the electronic device includes a processor 101 and a memory 100. The memory 100 stores machine executable instructions that can be executed by the processor 101. The processor 101 executes the machine executable instructions to implement the above data query method.

[0075] Further, Figure 5 The electronic device shown further includes a bus 102 and a communication interface 103 , and the processor 101 , the communication interface 103 and the memory 100 are connected via the bus 102 .

[0076] The memory 100 may include a high-speed random access memory (RAM), and may also include a non-volatile memory (non-volatile memory), such as at least one disk storage. The communication connection between the system network element and at least one other network element is realized through at least one communication interface 103 (which may be wired or wireless), and the Internet, wide area network, local area network, metropolitan area network, etc. may be used. The bus 102 may be an ISA bus, a PCI bus, or an EISA bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 5 Only one bidirectional arrow is used in the diagram, but this does not mean that there is only one bus or only one type of bus.

[0077] The processor 101 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit or software instructions in the processor 101. The above processor 101 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present invention can be implemented or executed. The general processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in the embodiment of the present invention can be directly embodied as a hardware decoding processor for execution, or a combination of hardware and software modules in the decoding processor for execution. The software module may be located in a storage medium mature in the art, such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory 100, and the processor 101 reads the information in the memory 100 and completes the steps of the method of the above embodiment in combination with its hardware.

[0078] An embodiment of the present invention also provides a machine-readable storage medium, which stores machine-executable instructions. When the machine-executable instructions are called and executed by a processor, the machine-executable instructions prompt the processor to implement the above-mentioned data query method. The specific implementation can be found in the method embodiment, which will not be repeated here.

[0079] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc., which can store program codes.

[0080] Finally, it should be noted that the above-described embodiments are only specific implementations of the present invention, which are used to illustrate the technical solutions of the present invention, rather than to limit them. The protection scope of the present invention is not limited thereto. Although the present invention is described in detail with reference to the above-described embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still modify the technical solutions recorded in the above-described embodiments within the technical scope disclosed by the present invention, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.

Claims

1. A data query method, characterized in that: The method is applied to a computing node of a distributed database; the computing node is communicatively connected with a plurality of storage nodes; the plurality of storage nodes store data of a first logic table and data of a second logic table; The data in the first logic table is the internal table data stored in the storage node, and the data in the second logic table is the external table data stored in the storage node. Each storage node can store part of the data in the first logic table and part of the data in the second logic table, and the data stored in each storage node is different. The data stored in multiple storage nodes are integrated to obtain complete data in the first logic table and complete data in the second logic table. The method comprises: Receiving a data query instruction sent by a user terminal; wherein the data query instruction carries a first identifier of the first logic table, a second identifier of the second logic table, and a query condition; Pull the data of the first logic table from the multiple storage nodes, and establish a hash table corresponding to the first logic table in the designated memory according to the pulled data; wherein the hash table of the designated memory is used to: provide data to be queried for each of the storage nodes; the designated memory is a global memory in the computing node, and the hash table corresponding to the first logic table is stored in the global memory to ensure that each of the storage nodes connected to the computing node can access the designated memory and obtain the data to be queried from the designated memory; Acquire first data satisfying the query condition from the data of the second logic table stored in the plurality of storage nodes; acquire second data satisfying the query condition from the hash table; Based on the first data and the second data, a query result corresponding to the data query instruction is determined, and the query result is returned to the user terminal.

2. The method according to claim 1, characterized in that The step of determining the query result corresponding to the data query instruction based on the first data and the second data includes: Determine a plurality of target information satisfying the query condition from the first data and the second data; The plurality of target information are spliced ​​to obtain a splicing result; and the splicing result is determined as a query result corresponding to the data query instruction.

3. The method according to claim 2, characterized in that The step of performing splicing processing on the plurality of target data information to obtain a splicing result comprises: The multiple target information are spliced ​​using multiple threads to obtain the splicing result.

4. The method according to any one of claims 1 to 3, characterized in that: The step of acquiring the first data satisfying the query condition from the data of the second logic table stored in the plurality of storage nodes comprises: For each storage node in the multiple storage nodes, perform the following operations in parallel: Pulling data of the second logical table from the storage node; The first data satisfying the query condition is searched from the data in the second logic table.

5. The method according to claim 4, characterized in that After the step of searching the data in the second logic table for the first data that meets the query condition, the method further includes: Delete the pulled data of the second logic table.

6. The method according to claim 1, characterized in that After the step of returning the query result to the user terminal, the method further includes: Release the hash table from the specified memory.

7. A data query device, characterized in that: The device is arranged at a computing node of a distributed database; the computing node is in communication connection with a plurality of storage nodes; the plurality of storage nodes store data of a first logic table and data of a second logic table; The data in the first logic table is the internal table data stored in the storage node, and the data in the second logic table is the external table data stored in the storage node. Each storage node can store part of the data in the first logic table and part of the data in the second logic table, and the data stored in each storage node is different. The data stored in multiple storage nodes are integrated to obtain complete data in the first logic table and complete data in the second logic table. The device comprises: An instruction receiving module, used for receiving a data query instruction sent by a user terminal; wherein the data query instruction carries a first identifier of the first logic table, a second identifier of the second logic table and a query condition; A hash table establishment module is used to pull the data of the first logical table from the multiple storage nodes, and establish a hash table corresponding to the first logical table in a designated memory according to the pulled data; wherein the hash table of the designated memory is used to: provide data to be queried for each of the storage nodes; the designated memory is a global memory in the computing node, and the hash table corresponding to the first logical table is stored in the global memory to ensure that each of the storage nodes connected to the computing node can access the designated memory and obtain the data to be queried from the designated memory; A data query module, configured to obtain first data satisfying the query condition from the data of the second logic table stored in the plurality of storage nodes; and obtain second data satisfying the query condition from the hash table; A result returning module is used to determine the query result corresponding to the data query instruction based on the first data and the second data, and return the query result to the user end.

8. The device according to claim 7, characterized in that The result returning module is further used for: Determine a plurality of target information satisfying the query condition from the first data and the second data; The plurality of target information are spliced ​​to obtain a splicing result; and the splicing result is determined as a query result corresponding to the data query instruction.

9. An electronic device, characterized in that: The electronic device includes a processor and a memory, the memory stores machine executable instructions that can be executed by the processor, and the processor executes the machine executable instructions to implement the data query method according to any one of claims 1 to 6.

10. A machine-readable storage medium, characterized in that: The machine-readable storage medium stores machine-executable instructions. When the machine-executable instructions are called and executed by a processor, the machine-executable instructions prompt the processor to implement the data query method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Dynamic hash method and device, equipment and storage medium

    CN112463795A

  • Apparatus and method for measuring per-flow informationof traffic

    KR1020060063544A