A method and device for joining tables, an electronic device, and a storage medium
By constructing a mapping tree of the driving table and storing it in the cache, the join query process is optimized, which solves the inefficiency problem caused by the low repetition rate of join fields in the existing technology and achieves more efficient query results.
Patent Information
- Application Number
- CN202210931199.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-04
- Publication Date
- 2026-02-27
- Estimated Expiration
- 2042-08-04
AI Technical Summary
Existing join query methods are inefficient when the repetition rate of the join fields is low, especially the INLJ algorithm which degenerates into the BNLJ algorithm, resulting in poor query efficiency.
Construct a mapping tree for the driving table. Based on the mapping relationship between index values and field values, reduce the number of traversals and comparisons of the driven table. Optimize the query process by storing the mapping tree in the cache.
It reduces the number of data traversals and comparisons during table join queries, improving query efficiency, and is particularly applicable in scenarios with many join fields and low repetition rates.
Smart Images

Figure CN115203246B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of computer, and in particular to a method and device for join query, electronic equipment and storage medium. BACKGROUND
[0002] With the development of computer technology, most business systems will involve join query, and the execution efficiency of the join query method is crucial to the response performance of the business system.
[0003] In the prior art, the join query method mainly includes Simple Nested-Loops Join (SNLJ) algorithm, Index Nested-Loops Join (INLJ) algorithm, and Block Nested-Loops Join (BNLJ) algorithm. The SNLJ algorithm is too violent and has too many access times, so the SNLJ algorithm is not commonly used in the prior art. Currently, the commonly used algorithms are BNLJ algorithm and INLJ algorithm.
[0004] Among them, the BNLJ algorithm is mainly applied to the case where the join field of the driven table has no index. For most business systems, an index is usually set when performing join query, so the INLJ algorithm is the most commonly used join query method in the business system. However, the INLJ algorithm is only good at processing join fields with high repetition rate. For the scene with low repetition rate of join fields, the INLJ algorithm will degenerate into the BNLJ algorithm, resulting in low join query efficiency. SUMMARY
[0005] The present application provides a join query method, device, electronic equipment and storage medium, which can reduce the traversal times and comparison times of data in the join query process, and improve the join query efficiency.
[0006] According to an aspect of the present application, a join query method is provided, comprising:
[0007] According to the mapping relationship between the index values and the field values in the driven table, a mapping tree matched with the driven table is constructed, and each index value in the mapping tree corresponds to at least one field value;
[0008] A driven table corresponding to the driven table is obtained, each field value in the driven table is traversed, and each field value in the driven table is compared with the field value in the mapping tree;
[0009] According to the comparison result, a target field value and a target index value are determined in the driven table, and a join query result is determined according to the target index value.
[0010] Optionally, after the mapping tree matching the driving table is constructed, further comprising:
[0011] storing the mapping tree into a preset mapping cache area;
[0012] comparing each field value in the driven table with the field value in the mapping tree comprises:
[0013] comparing each field value in the driven table with the field value in the mapping cache area.
[0014] Optionally, according to the comparison result, determining a target field value and a target index value in the driven table comprises:
[0015] judging whether there is a same field value in the driven table as the mapping tree;
[0016] if yes, taking the field value as the target field value, and taking the index value corresponding to the target field value in the driven table as the target index value.
[0017] Optionally, determining the join table query result according to the target index value comprises:
[0018] judging whether the target index value is consistent with the index value corresponding to the target field value on the mapping tree;
[0019] if yes, obtaining the associated data of the target index value in the driven table, and taking the associated data as the join table query result.
[0020] Optionally, the index value is a primary key value corresponding to each field value in the driving table.
[0021] According to another aspect of the present application, there is provided a join table query device, the device comprising:
[0022] a mapping tree construction module, configured to construct a mapping tree matching the driving table according to the mapping relationship between each index value and field value in the driving table; each index value in the mapping tree corresponds to at least one field value;
[0023] a traversal module, configured to obtain a driven table corresponding to the driving table, to traverse each field value in the driven table, and to compare each field value in the driven table with the field value in the mapping tree;
[0024] a result determination module, configured to determine a target field value and a target index value in the driven table according to the comparison result, and to determine a join table query result according to the target index value.
[0025] Optionally, the mapping tree construction module comprises:
[0026] a mapping tree storage unit, configured to store the mapping tree into a preset mapping cache area;
[0027] The traversal module comprises:
[0028] a comparison unit, configured to compare each field value in the driven table with the field value in the mapping cache area.
[0029] Optionally, the result determination module comprises:
[0030] a field value judgment unit, configured to judge whether there is a same field value as the mapping tree in the driven table;
[0031] a target field value determination unit, configured to, when there is a same field value as the mapping tree in the driven table, take the field value as a target field value, and take the index value corresponding to the target field value in the driven table as a target index value.
[0032] According to another aspect of the present application, an electronic device is provided, which comprises:
[0033] at least one processor; and
[0034] a memory connected with the at least one processor in communication; wherein,
[0035] the memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor to enable the at least one processor to execute the join table query method according to any one of the embodiments of the present application.
[0036] According to another aspect of the present application, a computer readable storage medium is provided, which stores computer instructions for enabling a processor to implement the join table query method according to any one of the embodiments of the present application when executed by the processor.
[0037] The technical scheme provided by the embodiments of the present application can reduce the number of data traversal and comparison in the join table query process and improve the join table query efficiency by constructing a mapping tree matched with the driven table according to the mapping relationship between each index value and field value in the driven table, obtaining a driven table corresponding to the driven table, traversing each field value in the driven table, comparing each field value in the driven table with the field value in the mapping tree, determining a target field value and a target index value in the driven table according to the comparison result, and determining a join table query result according to the target index value.
[0038] It is to be understood that the details set forth in the description contained herein do not limit the scope of the application. Other embodiments of the application will be readily apparent to those skilled in the art from the description herein. With reference to the drawings, embodiments of the application are herein described. BRIEF DESCRIPTION OF DRAWINGS
[0039] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the embodiments will be briefly introduced. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without any creative effort based on these drawings.
[0040] Figure 1 is a flow chart of a method for co-table query according to an embodiment of the present application;
[0041] Figure 2 is a flow chart of another method for co-table query according to an embodiment of the present application;
[0042] Figure 3 is a flow chart of another method for co-table query according to an embodiment of the present application;
[0043] Figure 4 is a structural schematic diagram of a co-table query device according to an embodiment of the present application;
[0044] Figure 5 is a structural schematic diagram of an electronic device for implementing the co-table query method according to an embodiment of the present application. DETAILED DESCRIPTION
[0045] In order to make the technical personnel in the art better understand the present application, the technical solutions in the embodiments of the present application will be described clearly and completely with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only some embodiments of the present application, not all. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without any creative effort should be within the scope of protection of the present application.
[0046] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and in the above drawings are used to distinguish similar objects, and do not necessarily have to be used to describe a specific order or sequence. It should be understood that the data thus used can be interchanged under appropriate circumstances, so that the embodiments of the application described herein can be implemented in an order other than that illustrated or described herein. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion, for example, a process, method, system, product or device that includes a series of steps or units does not have to be limited to only those steps or units clearly listed, but can include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0047] Figure 1 A flowchart of a join query method provided for Embodiment One of the present application. This embodiment can be applied to the case of querying target data in a plurality of data tables associated with a business system. The method can be executed by a join query device, which can be implemented in the form of hardware and / or software, and can be configured in an electronic device (such as a terminal or a server) with data processing functions. As shown in the figure, the method comprises: Figure 1
[0048] Step 110: constructing a mapping tree matching the driving table according to the mapping relationship between the index values and the field values in the driving table; each index value in the mapping tree corresponds to at least one field value.
[0049] In this embodiment, the driving table is usually a data table with less data in the database, which can be a data table that is read first in the execution process of a structured query language (SQL) statement. The index can be a data structure specially used to help users quickly query data in the database. Specifically, the index can be a catalog of the data table. Before searching for data in the data table, the user can first search for the index position in the catalog to quickly locate the query data.
[0050] In this step, the mapping relationship between the index values and the corresponding field values in the driving table can be obtained. The field can be a join query field between the driving table and the driven table. The driven table is usually a data table with more data in the database, which can be a data table that is read later in the execution process of a SQL statement.
[0051] After the mapping relationship between the index values and the field values in the driving table is acquired, a mapping tree can be constructed according to the mapping relationship. Specifically, when the index values in the driving table have a uniqueness constraint, each index value can correspond to a field value; when the index values do not have a uniqueness constraint, each index value can correspond to multiple field values.
[0052] In step 120, a driven table corresponding to the driving table is acquired, each field value in the driven table is traversed, and each field value in the driven table is compared with a field value in the mapping tree.
[0053] In step 130, a target field value and a target index value are determined in the driven table according to a comparison result, and a join query result is determined according to the target index value.
[0054] In this step, it can be judged whether there is a same field value as the mapping tree in the driven table, if yes, the field value can be taken as the target field value, and an index value corresponding to the target field value in the driven table can be taken as the target index value, and then associated data of the target index value in the driven table is acquired, and the associated data is taken as the join query result.
[0055] In the prior art, most business systems involve join table queries. Taking a financial business system as an example, a large number of query fields may be involved in the join table query process, such as the application information, credit investigation situation and debt information of an applicant. In this case, blindly adding query fields will affect the writing performance of the database; deleting old indexes and changing to joint indexes will also affect the existing business. Therefore, the existing BNLJ algorithm and INLJ algorithm cannot meet the actual join table query demand.
[0056] In the embodiment, by constructing a mapping tree between the indexes and the fields, the number of data traversal and comparison can be reduced, and the join table query efficiency is improved; secondly, for the scene with more join fields and lower repetition rate, the actual join table query demand can be met, and the applicability of the join table query method is improved.
[0057] The technical scheme provided by the embodiment of the application can reduce the number of data traversal and comparison in the join table query process, and improve the join table query efficiency, by constructing a mapping tree matched with the driving table according to the mapping relationship between the index values and the field values in the driving table, acquiring a driven table corresponding to the driving table, traversing each field value in the driven table, comparing each field value in the driven table with a field value in the mapping tree, determining a target field value and a target index value in the driven table according to a comparison result, and determining a join table query result according to the target index value.
[0058] Figure 2A flow chart of a join query method provided for the second embodiment of the present application, which is a further refinement of the above-mentioned embodiment. As shown in Figure 2 The method comprises the following steps:
[0059] Step 210: constructing a mapping tree matched with the driving table according to the mapping relationship between the index values and the field values in the driving table.
[0060] In one implementation of the embodiment, the index values are the primary key values ID corresponding to the field values in the driving table. Specifically, assuming that the field is "name", the mapping relationship between different IDs and the "name" values in the driving table can be obtained, and a mapping tree is constructed according to the mapping relationship.
[0061] Step 220: storing the mapping tree into a preset mapping cache area.
[0062] In this step, the mapping tree can be stored into the mapping cache area (map_buffer) based on the buffer mechanism.
[0063] Step 230: obtaining a driven table corresponding to the driving table, and traversing each field value in the driven table.
[0064] Step 240: comparing each field value in the driven table with the field values in the mapping cache area.
[0065] The advantage of such a setting is that by storing the mapping tree into the map_buffer, the records in the driving table can be cached, the number of data traversal in the driving table is reduced, and the join query method is optimized.
[0066] Step 250: determining a target field value and a target index value in the driven table according to the comparison result, and determining a join query result according to the target index value.
[0067] The technical solution provided by the embodiment of the present application can reduce the number of data traversal and comparison in the join query process, and improve the join query efficiency, by constructing a mapping tree matched with the driving table according to the mapping relationship between the index values and the field values in the driving table, storing the mapping tree into a preset mapping cache area, obtaining a driven table corresponding to the driving table, traversing each field value in the driven table, comparing each field value in the driven table with the field values in the mapping cache area, determining a target field value and a target index value in the driven table according to the comparison result, and determining a join query result according to the target index value.
[0068] Figure 3A flow chart of a join query method provided for the third embodiment of the present application, which is a further refinement of the above-mentioned embodiments. As shown in Figure 3 The method comprises the following steps:
[0069] Step 310: According to the mapping relationship between the index values and the field values in the driving table, a mapping tree matching the driving table is constructed.
[0070] Step 320: The driven table corresponding to the driving table is obtained, each field value in the driven table is traversed, and each field value in the driven table is compared with the field value in the mapping tree.
[0071] Step 330: It is judged whether there is a same field value in the driven table as the mapping tree, if yes, step 340 is executed, and if no, step 370 is executed.
[0072] Step 340: The field value is taken as a target field value, and the index value corresponding to the target field value in the driven table is taken as a target index value.
[0073] Step 350: It is judged whether the target index value is consistent with the index value corresponding to the target field value on the mapping tree, if yes, step 360 is executed, and if no, step 370 is executed.
[0074] Step 360: The associated data of the target index value in the driven table is obtained, and the associated data is taken as a join query result.
[0075] Step 370: The join query process is ended.
[0076] In a specific embodiment, it is assumed that in the join query specific business, there are a data table a (data amount is about 10 million) and a data table b (data amount is about 1 million), ID is the aggregation index of the data in the table, and name is the join query field between the data table a and the data table b. Since the data amount of the data table a is much larger than that of the data table b, the data table b can be taken as the driving table, and the data table a can be taken as the driven table.
[0077] In the join query process, the driving table b can be traversed row by row, the mapping tree can be constructed according to the mapping relationship between the different IDs and the name values in the driving table b, then the mapping tree is stored in the map_buffer, after the storage is completed, the driven table a is traversed row by row, it is judged whether each name value in the driven table a is consistent with the name value in the driving table b, if yes, it is compared whether the ID of the name value in the driven table a is consistent with the ID in the mapping tree, if yes, the associated data corresponding to the ID in the driven table a is obtained, and the associated data is taken as the join result.
[0078] In the prior art, taking the above data table as an example, when the INLJ algorithm is used for the join table query, the driving table b needs to be traversed first, and each row of data is read and then the driven table a is traversed in turn, and the traversal times are 100*10 million. When the BNLJ algorithm is used for the join table query, the driving table b needs to be traversed row by row, and the data of each row is divided into blocks and stored in the join_buffer, and the data in the join_buffer is unordered, so when the driven table a is traversed, each row of data needs to be compared 100 times, and the total traversal times are 10 million plus 100 times, and the comparison times are 1 million*100 (i.e. 100 million) times.
[0079] In the embodiment, compared with the prior art, by constructing the mapping tree, the traversal times are 10 million plus 100 times, and the comparison times are less than 100 million times, so that the join table query efficiency can be improved; secondly, by double comparison of the fields and the indexes, the accuracy of the join table query result can be improved.
[0080] The technical scheme provided by the embodiment of the application comprises the following steps: constructing a mapping tree matched with a driving table according to the mapping relationship between the index values and the field values in the driving table, obtaining a driven table corresponding to the driving table, traversing each field value in the driven table, comparing each field value in the driven table with the field values in the mapping tree, judging whether the same field values exist in the driven table as in the mapping tree, if so, taking the field value as a target field value, taking the index value corresponding to the target field value in the driven table as a target index value, judging whether the target index value is consistent with the index value corresponding to the target field value on the mapping tree, if so, obtaining the associated data of the target index value in the driven table, and taking the associated data as a join table query result. The technical scheme can reduce the traversal times and the comparison times of data in the join table query process, and improve the join table query efficiency.
[0081] Figure 4 A structure diagram of a join table query device provided for the fourth embodiment of the application is shown in FIG. 4, which comprises a mapping tree construction module 410, a traversal module 420 and a result determination module 430. Figure 4
[0082] The mapping tree construction module 410 is configured to construct a mapping tree matched with the driving table according to the mapping relationship between the index values and the field values in the driving table, and each index value in the mapping tree corresponds to at least one field value.
[0083] The traversal module 420 is configured to obtain a driven table corresponding to the driving table, traverse each field value in the driven table, and compare each field value in the driven table with the field values in the mapping tree.
[0084] The result determination module 430 is used to determine the target field value and the target index value in the driven table based on the comparison result, and to determine the join query result based on the target index value.
[0085] The technical solution provided by this invention constructs a mapping tree matching the driving table based on the mapping relationship between each index value and field value in the driving table, obtains the driven table corresponding to the driving table, traverses each field value in the driven table, compares each field value in the driven table with the field values in the mapping tree, determines the target field value and target index value in the driven table based on the comparison result, and determines the join query result based on the target index value. This technical means can reduce the number of data traversals and comparisons during the join query process and improve the join query efficiency.
[0086] Based on the above embodiments, the index value is the primary key value corresponding to each field value in the driving table.
[0087] The mapping tree construction module 410 includes:
[0088] A mapping tree storage unit is used to store the mapping tree in a preset mapping cache area.
[0089] The traversal module 420 includes:
[0090] The comparison unit is used to compare the values of each field in the driven table with the values of the fields in the mapping cache.
[0091] The result determination module 430 includes:
[0092] A field value determination unit is used to determine whether there is a field value in the driven table that is the same as the mapping tree;
[0093] The target field value determination unit is used to determine the target field value when the driven table has a field value that is the same as the mapping tree, and to determine the index value corresponding to the target field value in the driven table as the target index value.
[0094] An index value determination unit is used to determine whether the target index value is consistent with the index value corresponding to the target field value on the mapping tree;
[0095] The associated data acquisition unit is used to acquire associated data of the target index value in the driven table and use the associated data as the result of the join query.
[0096] The above-described apparatus can execute the methods provided in all the foregoing embodiments of the present invention, and has the corresponding functional modules and beneficial effects for executing the above methods. Technical details not described in detail in the embodiments of the present invention can be found in the methods provided in all the foregoing embodiments of the present invention.
[0097] Figure 5 A structural diagram of an electronic device 10 that can be used to implement embodiments of the present application is shown. The electronic device is intended to represent various forms of digital computers, such as laptops, desktops, tablets, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. The electronic device can also represent various forms of mobile devices, such as personal digital processors, cellular telephones, smart phones, wearable devices (e.g., headsets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are meant to be examples only, and are not meant to limit implementations of the present application described and / or claimed in this document.
[0098] As shown in Figure 5 The electronic device 10 includes at least one processor 11, and a memory, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., connected to the at least one processor 11 in communication, where the memory stores computer programs executable by the at least one processor. The processor 11 can perform various appropriate actions and processes according to the computer programs stored in the read-only memory (ROM) 12 or loaded into the random access memory (RAM) 13 from the storage unit 18. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0099] A plurality of components in the electronic device 10 are connected to the I / O interface 15, including an input unit 16, such as a keyboard, a mouse, etc., an output unit 17, such as various types of displays, speakers, etc., a storage unit 18, such as a magnetic disk, an optical disk, etc., and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network, such as the Internet, and / or various telecommunications networks.
[0100] The processor 11 can be various general and / or special-purpose processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 11 performs various methods and processes described above, such as the join query method.
[0101] In some embodiments, the join query method can be implemented as a computer program tangibly embodied in a computer readable storage medium, e.g., storage unit 18. In some embodiments, portions of or all of the computer program can be loaded onto the electronic device 10 via, e.g., ROM 12 and / or communication unit 19. When a computer program is loaded onto RAM 13 and executed by processor 11, one or more of the steps of the above-described join query method can be performed. Alternatively, in other embodiments, processor 11 can be configured to perform the join query method by other means, e.g., with the aid of firmware.
[0102] Various implementations of the systems and techniques described above can be realized in digital electronic circuitry, integrated circuitry, a field programmable gate array (FPGA), an application specific integrated circuit (ASIC), a system on a chip (SOC), a programmable logic device (PLD), a computer hardware, firmware, software, and / or combinations thereof. These various implementations can include implementation in one or more computer programs that are executable and / or interpretable on a programmable system including at least one programmable processor, which can be special or general purpose, coupled to receive data and instructions from, and to transmit data and instructions to, a storage system, at least one input device, and at least one output device.
[0103] Computer programs used to implement the methods of the present application can be written in any combination of one or more programming languages. These computer programs can be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus to produce a machine, such that the computer program, when executed by the processor of the machine, implements the functions / acts specified in the flowcharts and / or block diagrams. The computer program can be executed entirely on a machine, partially on a machine, partially on a machine as a stand-alone software package, partially on a machine and partially on a remote machine or entirely on a remote machine or server.
[0104] In the context of the present application, a computer-readable storage medium can be a tangible medium that can contain or store a computer program for use by or in connection with an instruction execution system, apparatus, or device. A computer-readable storage medium can include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium can be a machine-readable signal medium. More specific examples of a machine-readable storage medium will include one or more lines of a program of instructions in a transitory signal, a portable computer diskette, 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 disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0105] To provide for interaction with a user, the systems and techniques described here can be implemented on an electronic device having a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user and a keyboard and a pointing device (e.g., a mouse or a trackball) by which the user can provide input to the electronic device. Other kinds of devices can be used to provide for interaction with a user as well; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form, including acoustic, speech, or tactile input.
[0106] The systems and techniques described here can be implemented in a computing system that includes a back end component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front end component (e.g., a user computer having a graphical user interface or a Web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such back end, middleware, or front end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.
[0107] The computing system can include clients and servers. A client and server are generally remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. The server can be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system, to solve the defects of large management difficulty and weak business scalability in traditional physical host and VPS service.
[0108] It should be understood that the various forms of flow shown above can be used to reorder, add or delete steps. For example, each step described in the present application can be executed in parallel, sequentially or in a different order, as long as the desired results of the technical solutions of the present application can be achieved, which is not limited herein.
[0109] The above detailed description does not constitute a limitation on the scope of protection of the present application. Those skilled in the art should understand that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modifications, equivalent replacements and improvements made within the spirit and principles of the present application shall be included in the scope of protection of the present application.
Claims
1. A method of joining tables, characterized by, The method comprises the following steps: According to the mapping relationship between the index value and the field value in the driving table, a mapping tree matching the driving table is constructed; Each index value in the mapping tree corresponds to at least one field value; A driven table corresponding to the driving table is obtained, each field value in the driven table is traversed, and each field value in the driven table is compared with the field value in the mapping tree; According to the comparison result, the target field value and the target index value in the driven table are determined, and the join table query result is determined according to the target index value; Wherein, according to the comparison result, the target field value and the target index value in the driven table are determined, which comprises: Judge whether there is the same field value as the mapping tree in the driven table; If yes, the field value is taken as the target field value, and the index value corresponding to the target field value in the driven table is taken as the target index value; Wherein, according to the target index value, the join table query result is determined, which comprises: Judge whether the target index value is consistent with the index value corresponding to the target field value on the mapping tree; If yes, the associated data of the target index value in the driven table is obtained, and the associated data is taken as the join table query result.
2. The method of claim 1, wherein, After the mapping tree matching the driving table is constructed, it further comprises: The mapping tree is stored in the preset mapping cache area; The comparison of each field value in the driven table with the field value in the mapping tree comprises: Each field value in the driven table is compared with the field value in the mapping cache area.
3. The method of claim 1, wherein, The index value is the primary key value corresponding to each field value in the driving table.
4. A cross-table query apparatus characterized by comprising: The method comprises the following steps: A mapping tree construction module is used to construct a mapping tree matching the driving table according to the mapping relationship between the index value and the field value in the driving table; Each index value in the mapping tree corresponds to at least one field value; A traversal module is used to obtain a driven table corresponding to the driving table, traverse each field value in the driven table, and compare each field value in the driven table with the field value in the mapping tree; A result determination module is used to determine the target field value and the target index value in the driven table according to the comparison result, and determine the join table query result according to the target index value; Wherein, the result determination module comprises: A field value judgment unit is used to judge whether there is the same field value as the mapping tree in the driven table; A target field value determination unit is used to take the field value as the target field value when there is the same field value as the mapping tree in the driven table, and take the index value corresponding to the target field value in the driven table as the target index value; An index value judgment unit is used to judge whether the target index value is consistent with the index value corresponding to the target field value on the mapping tree; An associated data acquisition unit is used to obtain the associated data of the target index value in the driven table, and take the associated data as the join table query result.
5. The apparatus of claim 4, wherein, The mapping tree construction module comprises: A mapping tree storage unit is used to store the mapping tree in the preset mapping cache area; The traversal module comprises: a comparison unit for comparing each field value in the driven table with a field value in the mapping cache.
6. An electronic device, comprising: The electronic device comprises: at least one processor; and a memory connected with the at least one processor; wherein the memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor to enable the at least one processor to perform the join query method in any one of claims 1-3.
7. A computer-readable storage medium, characterized in that, The computer readable storage medium stores computer instructions for enabling the processor to implement the join query method in any one of claims 1-3 when executed.
Citation Information
Patent Citations
Method and system for connecting tables in a plurality of heterogeneous distributed databases
CN101685449A
Data extraction method and device, terminal and computer readable storage medium
CN110009514A