Data query optimization method and device, equipment and storage medium
By optimizing data query statements and making their association conditions a distribution key for the query table, the problem of low query performance in the existing technology is solved, and more efficient data query and lower resource consumption are achieved.
Patent Information
- Application Number
- CN202411968840.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-30
- Publication Date
- 2025-04-25
AI Technical Summary
In existing data query technology, when the association conditions of the query statement are not the distribution key of the query table, it is easy to lead to low query performance.
By obtaining the association query statement, the first and second association fields are determined, and the target query table is determined based on these fields. Send the target query statement to the target data node to enable it to perform data query tasks, thereby improving query efficiency.
By optimizing query statements, their association conditions become the distribution key of the query table, the efficiency of data query is improved, query resource consumption is reduced, and system performance is improved.
Smart Images

Figure CN119884172A_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present invention relate to the field of data query technology, and in particular to a data query optimization method, device, equipment and storage medium. Background Art
[0002] Query is one of the most common and frequent operations in database systems. The query optimization of distributed query performance needs to be refined. When the associated condition of the query statement is not the distribution key of the query table, the query statement cannot be pushed down to the dn (Data Node) node as a whole, so it is necessary to split the tables of the overall query and query each sub-data separately to the cn (Computer Node) layer for calculation, which easily leads to poor performance. Summary of the invention
[0003] The embodiments of the present invention provide a data query optimization method, device, equipment and storage medium. The technical solution of the embodiments of the present invention solves the problem in the existing data query technology that when the association condition of the query statement is not the distribution key of the query table, it is easy to cause poor query performance. The query statement can be optimized so that the association condition of the query statement is the distribution key of the query table, thereby improving data query efficiency, reducing query resource consumption and improving system performance.
[0004] In a first aspect, an embodiment of the present invention provides a data query optimization method, the method comprising:
[0005] Obtain an associated query statement, and determine a first associated field and a second associated field according to the associated query statement; determine a first target query table corresponding to the first associated field, determine a second target query table corresponding to the second associated field, and determine a target query statement according to the first target query table and the second target query table; wherein the first associated field is a distribution key of the first target query table, and the second associated field is a distribution key of the second target query table; send the target query statement to a target data node, so that the target data node executes a data query task corresponding to the target query statement, and obtains a data query result.
[0006] In a second aspect, an embodiment of the present invention provides a data query optimization device, the device comprising:
[0007] An associated field determination module is used to obtain an associated query statement and determine a first associated field and a second associated field according to the associated query statement; a query table determination module is used to determine a first target query table corresponding to the first associated field, determine a second target query table corresponding to the second associated field, and determine a target query statement according to the first target query table and the second target query table; wherein the first associated field is a distribution key of the first target query table, and the second associated field is a distribution key of the second target query table; a data query module is used to send the target query statement to a target data node so that the target data node executes a data query task corresponding to the target query statement to obtain a data query result.
[0008] In a third aspect, an embodiment of the present invention provides a computer device, the computer device comprising:
[0009] one or more processors;
[0010] A memory for storing one or more programs;
[0011] When the one or more programs are executed by the one or more processors, the one or more processors implement the data query optimization method described in any embodiment.
[0012] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the data query optimization method described in any embodiment.
[0013] The technical solution provided by the embodiment of the present invention obtains an associated query statement, determines the first associated field and the second associated field according to the associated query statement; determines the first target query table corresponding to the first associated field, determines the second target query table corresponding to the second associated field, and determines the target query statement according to the first target query table and the second target query table; wherein the first associated field is the distribution key of the first target query table, and the second associated field is the distribution key of the second target query table; sends the target query statement to the target data node so that the target data node executes the data query task corresponding to the target query statement to obtain a data query result. The technical solution of the embodiment of the present invention solves the problem in the existing data query technology that when the associated condition of the query statement is not the distribution key of the query table, it is easy to cause poor query performance. The query statement can be optimized so that the associated condition of the query statement is the distribution key of the query table, thereby improving data query efficiency, reducing query resource consumption, and improving system performance. BRIEF DESCRIPTION OF THE DRAWINGS
[0014] Figure 1It is a flow chart of a data query optimization method provided by an embodiment of the present invention;
[0015] Figure 2 It is a flow chart of another data query optimization method provided by an embodiment of the present invention;
[0016] Figure 3 It is a structural schematic diagram of a data query optimization device provided by an embodiment of the present invention;
[0017] Figure 4 It is a structural schematic diagram of a computer device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0018] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution 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. 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.
[0019] Figure 1 It is a flow chart of a data query optimization method provided by an embodiment of the present invention. The embodiment of the present invention can execute a data query task according to a query statement. The method can be executed by a data query optimization device, and the device can be implemented by software and / or hardware.
[0020] like Figure 1 As shown, the data query optimization method includes the following steps:
[0021] S110: Obtain an associated query statement, and determine a first associated field and a second associated field according to the associated query statement.
[0022] The associated query statement may be a query statement that needs to be optimized. The associated query statement may include information that needs to be queried for an associated relationship. For example, the associated query statement may include an associated condition of two fields and a query table corresponding to the two fields. Further, the first associated field and the second associated field may be two fields that need to be queried for an associated relationship. Specifically, one field in the associated query statement may be used as the first associated field, and the other field may be used as the second associated field.
[0023] S120: Determine a first target query table corresponding to the first associated field, determine a second target query table corresponding to the second associated field, and determine a target query statement according to the first target query table and the second target query table.
[0024] The first target query table may be a query table corresponding to the first associated field after optimization. The first associated field is a distribution key of the first target query table. Specifically, the original query table corresponding to the first associated field may be first determined from the associated query statement. If the first associated field is the distribution key of the original query table, the original query table may be directly used as the first target query table. If the first associated field is not the distribution key of the original query table, the first target query table may be determined from the global index table corresponding to the original query table.
[0025] Similarly, the second target query table can be a query table corresponding to the second associated field after optimization. The second associated field is the distribution key of the second target query table. Specifically, the original query table corresponding to the second associated field can be first determined from the associated query statement. When the second associated field is the distribution key of the original query table, the original query table can be directly used as the second target query table; when the second associated field is not the distribution key of the original query table, the second target query table can be determined from the global index table corresponding to the original query table.
[0026] S130: Send the target query statement to a target data node, so that the target data node executes a data query task corresponding to the target query statement to obtain a data query result.
[0027] The target data node may be a data node for executing a target query statement. The data query result may be a query result obtained by executing the target query statement. Specifically, the target query statement may be sent to the target data node so that the target data node executes the data query task corresponding to the target query statement to obtain the data query result.
[0028] The technical solution provided by the embodiment of the present invention obtains an associated query statement, determines the first associated field and the second associated field according to the associated query statement; determines the first target query table corresponding to the first associated field, determines the second target query table corresponding to the second associated field, and determines the target query statement according to the first target query table and the second target query table; wherein the first associated field is the distribution key of the first target query table, and the second associated field is the distribution key of the second target query table; sends the target query statement to the target data node so that the target data node executes the data query task corresponding to the target query statement to obtain the data query result. The technical solution of the embodiment of the present invention solves the problem in the existing data query technology that when the associated condition of the query statement is not the distribution key of the query table, it is easy to cause poor query performance. The query statement can be optimized so that the associated condition of the query statement is the distribution key of the query table, thereby improving data query efficiency, reducing query resource consumption, and improving system performance.
[0029] Figure 2It is another flow chart of a data query optimization method provided by an embodiment of the present invention. The embodiment of the present invention can execute a data query task according to a query statement. Based on the above embodiment, this embodiment further explains how to determine a first target query table corresponding to a first associated field and a second target query table corresponding to a second associated field; and how to send the target query statement to a target data node so that the target data node executes the data query task corresponding to the target query statement and obtains a data query result. The device can be implemented by software and / or hardware and integrated in a computer device with application development function.
[0030] like Figure 2 As shown, the data query optimization method includes the following steps:
[0031] S210: Obtain an associated query statement, and determine a first associated field and a second associated field according to the associated query statement.
[0032] The associated query statement may be a query statement that needs to be optimized. The associated query statement may include information that needs to be queried for an associated relationship. For example, the associated query statement may include an associated condition of two fields and a query table corresponding to the two fields. Further, the first associated field and the second associated field may be two fields that need to be queried for an associated relationship. Specifically, one field in the associated query statement may be used as the first associated field, and the other field may be used as the second associated field.
[0033] Optionally, obtaining an associated query statement, and determining a first associated field and a second associated field according to the associated query statement, including: determining an associated equivalence condition according to the associated query statement; wherein the associated equivalence condition is used to represent an associated condition between two preset fields; using one of the two preset fields as the first associated field, and using the other field as the second associated field.
[0034] S220. Determine a first reference query table corresponding to the first associated field according to the associated query statement. When the first associated field is not a distribution key of the first reference query table and the first associated field is a global index of the first reference query table, use the global index table corresponding to the first reference query table as the first target query table.
[0035] The first query table may be the original query table corresponding to the first associated field. Specifically, the query table corresponding to the first associated field in the associated query statement may be used as the first reference query table. The first target query table may be the query table corresponding to the first associated field after optimization. Specifically, when the first associated field is not the distribution key of the first reference query table and the first associated field is the global index of the first reference query table, the global index table corresponding to the first reference query table may be used as the first target query table.
[0036] S230. Determine a second reference query table corresponding to the second associated field according to the associated query statement. When the second associated field is not a distribution key of the second reference query table and the second associated field is a global index of the second reference query table, use the global index table corresponding to the second reference query table as the second target query table, and determine a target query statement according to the first target query table and the second target query table.
[0037] The second query table may be the original query table corresponding to the second associated field. Specifically, the query table corresponding to the second associated field in the associated query statement may be used as the second reference query table. The second target query table may be the query table corresponding to the optimized second associated field. Specifically, when the second associated field is not the distribution key of the second reference query table and the second associated field is the global index of the second reference query table, the global index table corresponding to the second reference query table may be used as the second target query table.
[0038] Furthermore, the target query may be a query statement obtained by optimizing the associated query statement. Specifically, the query table corresponding to the first associated field in the associated query statement may be replaced with the first target query table, and the query table corresponding to the second associated field may be replaced with the second target query table, and the statement obtained after adjustment may be used as the target query statement.
[0039] S240: Send the target query statement to multiple target data sub-nodes, so that the target data sub-nodes execute data query tasks corresponding to the target query statement to obtain sub-node query results.
[0040] The target data node may be a data node for executing the target query statement. The target data subnode may be a branch node corresponding to the target data node. The subnode query result may be a query result obtained by querying the data of the target data subnode. Specifically, the target query statement may be split into multiple subquery tasks, and each subquery task may be distributed to the corresponding target data subnode, so that the target data subnode executes the corresponding subquery task, thereby obtaining the subnode query result.
[0041] Optionally, the target query statement is sent to multiple target data sub-nodes so that the target data sub-nodes execute the data query task corresponding to the target query statement to obtain the sub-node query result, including: splitting the target query statement into multiple target sub-query statements according to the number of target data sub-nodes, and distributing each target sub-query statement to the corresponding target data sub-node; for each target data sub-node, controlling the target data sub-node to execute the data query task of the corresponding target sub-query statement to obtain the sub-node query result corresponding to the target data sub-node.
[0042] Among them, the target sub-query statement can be a branch statement corresponding to the target query statement. Specifically, the target query statement can be split into an equal number of target sub-query statements according to the number of target data sub-nodes, and each target sub-query statement can be distributed to the corresponding target data sub-node. Specifically, for example, if the number of target data sub-nodes is three, the target query statement can be split into three target sub-query statements, and further, each target sub-query statement can be distributed to the corresponding target data sub-node respectively; for each target data sub-node, the target data sub-node is controlled to execute the data query task of the corresponding target sub-query statement, and the sub-node query result corresponding to the target data sub-node is obtained.
[0043] S250. Control the target computing node to obtain sub-node query results of the multiple target data sub-nodes, and determine the data query result according to the sub-node query results.
[0044] The target computing node may be a node for performing query result calculation. The data query result may be a query result obtained by executing the target query statement. Specifically, the target computing node may aggregate the sub-node query results of multiple target data sub-nodes to obtain the data query result.
[0045] Optionally, after obtaining the data query result, the data query result may also be sent to a target client application.
[0046] For example, in order to better understand the technical solution provided by the present invention, a specific embodiment is introduced below:
[0047] The structure of the shard table t1 / t2 is as follows:
[0048] t1(a int not null,
[0049] b int,
[0050] global index idx1(b),
[0051] primary key(a))
[0052] distributed by hash(a)(g1,g2,g3);
[0053] When creating a table, if there is a global index idx1(b), the index table will be created simultaneously.
[0054] t1_indextb_b(a int not null,
[0055] b int,
[0056] primary key(a))
[0057] distributed by hash(b)(g1,g2,g3);
[0058] t2(a int not null,
[0059] b int,
[0060] global index idx1(b),
[0061] primary key(a)
[0062] distributed by hash(a)(g1,g2,g3);
[0063] When creating a table, if there is a global index idx1(b), the index table will be created simultaneously.
[0064] t2_indextb_b(a int not null,
[0065] b int,
[0066] primary key(a)
[0067] distributed by hash(b)(g1,g2,g3);
[0068] Example of a related query statement: select count(*)from t1 join t2 on t1.b=t2.a;
[0069] Step 1: Get the associated equivalent condition t1.b=t2.a of the query statement.
[0070] Step 2: Check whether the field t1.b of the t1 table in the equivalent chain t1.b=t2.a is the distribution key t1.a of t1. If it is not, go to step 3; if it is, go to step 4.
[0071] Step 3: Check whether field t1.b is a global index of table t1. If so, replace t1 in the original query statement with t1_indextb_b.
[0072] Step 4: Based on whether the field t2.a in the equivalence chain t1.b=t2.a of the t2 table is the distribution key t2.a of t2, if it is, no replacement optimization is required.
[0073] Step 5: The query statement sent to the DN (g1, g2, g3) node is select count(*) from t1_indextb_b join t2 on t1_indextb_b.b=t2.a;
[0074] Step 6: The CN layer aggregates the data of DN(g1,g2,g3) for secondary calculation.
[0075] Step 7: Report the CN result to the client application.
[0076] The technical solution of the embodiment of the present invention first performs lexical and grammatical analysis on the query statement through the CN computing node, and then judges whether the associated equivalent field is a sharding key. If it is a distribution key, the query can be directly pressed down without optimization. If not, the index table corresponding to the associated field of the non-distribution key is found, and the table name of the query statement is replaced with the index table, and then directly pressed down to each DN node for query. The CN layer can summarize the results of the associated query, thereby avoiding the secondary associated calculation of the full data at the CN layer. The resources of each component of the distributed system are fully utilized to achieve more efficient query performance and resource utilization.
[0077] The technical solution provided by the embodiment of the present invention obtains an associated query statement, determines a first associated field and a second associated field according to the associated query statement; determines a first reference query table corresponding to the first associated field according to the associated query statement, and when the first associated field is not a distribution key of the first reference query table and the first associated field is a global index of the first reference query table, uses the global index table corresponding to the first reference query table as the first target query table; determines a second reference query table corresponding to the second associated field according to the associated query statement, and when the second associated field is not a distribution key of the second reference query table and the second associated field is a global index of the second reference query table, uses the global index table corresponding to the second reference query table as the second target query table; sends the target query statement to multiple target data sub-nodes, so that the target data sub-nodes execute the data query task corresponding to the target query statement and obtain the sub-node query result; controls the target computing node to obtain the sub-node query results of the multiple target data sub-nodes, and determines the data query result according to the sub-node query results.
[0078] The technical solution of the embodiment of the present invention solves the problem in the existing data query technology that when the association condition of the query statement is not the distribution key of the query table, it is easy to cause poor query performance. The query statement can be optimized so that the association condition of the query statement is the distribution key of the query table, thereby improving data query efficiency, reducing query resource consumption, and improving system performance.
[0079] Figure 3 It is a structural diagram of a data query optimization device provided by an embodiment of the present invention. The embodiment of the present invention can execute data query tasks according to query statements. The device can be implemented by software and / or hardware and integrated into a computer device with application development function.
[0080] like Figure 3 As shown, the data query optimization device includes: an associated field determination module 310 , a query table determination module 320 and a data query module 330 .
[0081] Among them, the associated field determination module 310 is used to obtain the associated query statement, and determine the first associated field and the second associated field according to the associated query statement; the query table determination module 320 is used to determine the first target query table corresponding to the first associated field, determine the second target query table corresponding to the second associated field, and determine the target query statement according to the first target query table and the second target query table; wherein the first associated field is the distribution key of the first target query table, and the second associated field is the distribution key of the second target query table; the data query module 330 is used to send the target query statement to the target data node, so that the target data node executes the data query task corresponding to the target query statement to obtain the data query result.
[0082] The technical solution provided by the embodiment of the present invention obtains an associated query statement, determines the first associated field and the second associated field according to the associated query statement; determines the first target query table corresponding to the first associated field, determines the second target query table corresponding to the second associated field, and determines the target query statement according to the first target query table and the second target query table; wherein the first associated field is the distribution key of the first target query table, and the second associated field is the distribution key of the second target query table; sends the target query statement to the target data node so that the target data node executes the data query task corresponding to the target query statement to obtain a data query result. The technical solution of the embodiment of the present invention solves the problem in the existing data query technology that when the associated condition of the query statement is not the distribution key of the query table, it is easy to cause poor query performance. The query statement can be optimized so that the associated condition of the query statement is the distribution key of the query table, thereby improving data query efficiency, reducing query resource consumption, and improving system performance.
[0083] In an optional embodiment, the query table determination module 320 includes: a first query table determination unit, used to: determine the first reference query table corresponding to the first associated field according to the associated query statement; when the first associated field is not the distribution key of the first reference query table, and the first associated field is the global index of the first reference query table, use the global index table corresponding to the first reference query table as the first target query table.
[0084] In an optional embodiment, the query table determination module 320 includes: a second query table determination unit, used to: determine the second reference query table corresponding to the second associated field according to the associated query statement; when the second associated field is not the distribution key of the second reference query table, and the second associated field is the global index of the second reference query table, use the global index table corresponding to the second reference query table as the second target query table.
[0085] In an optional implementation, the associated field determination module 310 is specifically used to: determine an associated equivalent condition based on the associated query statement; wherein the associated equivalent condition is used to represent an associated condition between two preset fields; and use one of the two preset fields as a first associated field, and use the other field as a second associated field.
[0086] In an optional embodiment, the data query module 330 is specifically used to: send the target query statement to multiple target data sub-nodes so that the target data sub-nodes execute the data query tasks corresponding to the target query statement to obtain sub-node query results; control the target computing node to obtain the sub-node query results of the multiple target data sub-nodes, and determine the data query results based on the sub-node query results.
[0087] In an optional embodiment, the data query module 330 includes: a sub-node query unit, which is used to: split the target query statement into multiple target sub-query statements according to the number of the target data sub-nodes, and distribute each target sub-query statement to the corresponding target data sub-node; for each target data sub-node, control the target data sub-node to execute the data query task of the corresponding target sub-query statement to obtain the sub-node query result corresponding to the target data sub-node.
[0088] In an optional implementation, the data query optimization device further includes: a query result sending module, configured to: after obtaining the data query result, send the data query result to a target client application.
[0089] The data query optimization device provided in the embodiment of the present invention can execute the data query optimization method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.
[0090] Figure 4 A schematic diagram of the structure of a computer device provided in an embodiment of the present invention. Figure 4 A block diagram of an exemplary computer device 12 suitable for use in implementing embodiments of the present invention is shown. Figure 4 The computer device 12 shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention. The computer device 12 can be any terminal device with computing capability and can be configured in the data query optimization device.
[0091] like Figure 4 As shown, the computer device 12 is in the form of a general-purpose computing device. The components of the computer device 12 may include, but are not limited to: one or more processors or processing units 16, a system memory 28, and a bus 18 that connects various system components (including the system memory 28 and the processing unit 16).
[0092] The bus 18 may be one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processor or a local bus using any of a variety of bus architectures. For example, these architectures include, but are not limited to, an Industry Standard Architecture (ISA) bus, a Micro Channel Architecture (MAC) bus, an Enhanced ISA bus, a Video Electronics Standards Association (VESA) local bus, and a Peripheral Component Interconnect (PCI) bus.
[0093] The computer device 12 typically includes a variety of computer system readable media. These media can be any available media that can be accessed by the computer device 12, including volatile and non-volatile media, removable and non-removable media.
[0094] The system memory 28 may include computer system readable media in the form of volatile memory, such as random access memory (RAM) 30 and / or cache 32. The computer device 12 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, the storage system 34 may be used to read and write non-removable, non-volatile magnetic media ( Figure 4 not shown, usually called a "hard drive"). Although Figure 4Not shown in the figure, a disk drive for reading and writing to a removable non-volatile disk (e.g., a "floppy disk"), and an optical disk drive for reading and writing to a removable non-volatile optical disk (e.g., a CD-ROM, a DVD-ROM, or other optical media) may be provided. In these cases, each drive may be connected to the bus 18 via one or more data medium interfaces. The system memory 28 may include at least one program product having a set (e.g., at least one) of program modules that are configured to perform the functions of the various embodiments of the present invention.
[0095] A program / utility 40 having a set (at least one) of program modules 42 may be stored, for example, in system memory 28, such program modules 42 including, but not limited to, an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment. Program modules 42 generally perform the functions and / or methods of the embodiments described herein.
[0096] The computer device 12 may also communicate with one or more external devices 14 (e.g., keyboards, pointing devices, displays 24, etc.), one or more devices that enable a user to interact with the computer device 12, and / or any device that enables the computer device 12 to communicate with one or more other computing devices (e.g., network cards, modems, etc.). Such communication may be performed through an input / output (I / O) interface 22. Furthermore, the computer device 12 may also communicate with one or more networks (e.g., local area networks (LANs), wide area networks (WANs), and / or public networks, such as the Internet) through a network adapter 20. Figure 4 As shown, the network adapter 20 communicates with other modules of the computer device 12 via the bus 18. It should be understood that although Figure 4 Not shown, other hardware and / or software modules may be used in conjunction with computer device 12, including but not limited to microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0097] The processing unit 16 executes various functional applications and data processing by running the program stored in the system memory 28, for example, implementing the data query optimization method provided by the embodiment of the present invention, which includes:
[0098] Obtain an associated query statement, and determine a first associated field and a second associated field according to the associated query statement; determine a first target query table corresponding to the first associated field, determine a second target query table corresponding to the second associated field, and determine a target query statement according to the first target query table and the second target query table; wherein the first associated field is a distribution key of the first target query table, and the second associated field is a distribution key of the second target query table; send the target query statement to a target data node, so that the target data node executes a data query task corresponding to the target query statement, and obtains a data query result.
[0099] This embodiment provides a computer-readable storage medium, on which a computer program is stored. When the program is executed by a processor, the data query optimization method provided by any embodiment of the present invention is implemented, including:
[0100] Obtain an associated query statement, and determine a first associated field and a second associated field according to the associated query statement; determine a first target query table corresponding to the first associated field, determine a second target query table corresponding to the second associated field, and determine a target query statement according to the first target query table and the second target query table; wherein the first associated field is a distribution key of the first target query table, and the second associated field is a distribution key of the second target query table; send the target query statement to a target data node, so that the target data node executes a data query task corresponding to the target query statement, and obtains a data query result.
[0101] The computer storage medium of the embodiment of the present invention can adopt any combination of one or more computer-readable media. The computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. The computer-readable storage medium can be, for example, but not limited to: an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples (non-exhaustive list) of computer-readable storage media include: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this document, a computer-readable storage medium can be any tangible medium containing or storing a program, which can be used by an instruction execution system, device or device or used in combination with it.
[0102] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, which carry computer-readable program code. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.
[0103] The program code embodied on the computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
[0104] Computer program code for performing the operations of the present invention may be written in one or more programming languages or combinations thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0105] It should be understood by those skilled in the art that the modules or steps of the present invention described above can be implemented by a general-purpose computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, optionally, they can be implemented by a program code executable by a computer device, so that they can be stored in a storage device and executed by the computing device, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. Thus, the present invention is not limited to any specific combination of hardware and software.
[0106] Note that the above are only preferred embodiments of the present invention and the technical principles used. Those skilled in the art will understand that the present invention is not limited to the specific embodiments herein, and that various obvious changes, readjustments and substitutions can be made by those skilled in the art without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in more detail through the above embodiments, the present invention is not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of the present invention, and the scope of the present invention is determined by the scope of the appended claims.
Claims
1. A data query optimization method, characterized in that: include: Obtaining an associated query statement, and determining a first associated field and a second associated field according to the associated query statement; Determine a first target query table corresponding to the first associated field, determine a second target query table corresponding to the second associated field, and determine a target query statement according to the first target query table and the second target query table; wherein the first associated field is a distribution key of the first target query table, and the second associated field is a distribution key of the second target query table; The target query statement is sent to the target data node, so that the target data node executes the data query task corresponding to the target query statement to obtain the data query result.
2. The method according to claim 1, characterized in that The determining the first target query table corresponding to the first associated field includes: Determine a first reference query table corresponding to the first associated field according to the associated query statement; When the first associated field is not a distribution key of the first reference query table and the first associated field is a global index of the first reference query table, the global index table corresponding to the first reference query table is used as the first target query table.
3. The method according to claim 1, characterized in that The determining the second target query table corresponding to the second associated field includes: Determine a second reference query table corresponding to the second associated field according to the associated query statement; When the second associated field is not the distribution key of the second reference query table and the second associated field is the global index of the second reference query table, the global index table corresponding to the second reference query table is used as the second target query table.
4. The method according to claim 1, characterized in that: The obtaining of the associated query statement and determining the first associated field and the second associated field according to the associated query statement include: Determine an associated equivalent condition according to the associated query statement; wherein the associated equivalent condition is used to represent an associated condition between two preset fields; One of the two preset fields is used as the first associated field, and the other field is used as the second associated field.
5. The method according to claim 1, characterized in that The sending of the target query statement to the target data node so that the target data node executes the data query task corresponding to the target query statement to obtain the data query result includes: Sending the target query statement to multiple target data sub-nodes, so that the target data sub-nodes execute the data query tasks corresponding to the target query statement, and obtain sub-node query results; The target computing node is controlled to obtain sub-node query results of the multiple target data sub-nodes, and the data query result is determined according to the sub-node query results.
6. The method according to claim 5, characterized in that The sending of the target query statement to multiple target data sub-nodes so that the target data sub-nodes execute the data query tasks corresponding to the target query statement to obtain sub-node query results includes: According to the number of the target data sub-nodes, the target query statement is split into multiple target sub-query statements, and each target sub-query statement is distributed to the corresponding target data sub-node; For each target data sub-node, the target data sub-node is controlled to execute a data query task of a corresponding target sub-query statement to obtain a sub-node query result corresponding to the target data sub-node.
7. The method according to claim 1, characterized in that After obtaining the data query result, the method further includes: The data query result is sent to the target client application.
8. A data query optimization device, characterized in that: The device comprises: A correlation field determination module, used to obtain a correlation query statement, and determine a first correlation field and a second correlation field according to the correlation query statement; A query table determination module, used to determine a first target query table corresponding to the first associated field, determine a second target query table corresponding to the second associated field, and determine a target query statement according to the first target query table and the second target query table; wherein the first associated field is a distribution key of the first target query table, and the second associated field is a distribution key of the second target query table; The data query module is used to send the target query statement to the target data node, so that the target data node executes the data query task corresponding to the target query statement to obtain the data query result.
9. A computer device, characterized in that: The computer device comprises: one or more processors; A memory for storing one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the data query optimization method as described in any one of claims 1-7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the data query optimization method as described in any one of claims 1 to 7 is implemented.