Cross-database query method, apparatus, device, medium and computer program product
By optimizing cross-database queries through batch queries and dynamic feature field filtering, the problems of high resource consumption and long query time in cross-database queries are solved, achieving efficient data retrieval and improved pagination performance.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- CHINA CONSTRUCTION BANK
- Filing Date
- 2023-05-24
- Publication Date
- 2026-06-09
Smart Images

Figure CN116628027B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of big data technology, and in particular to cross-database query methods, apparatus, devices, media, and computer program products. Background Technology
[0002] Software testers often spend a significant amount of time preparing data before conducting tests. Financial systems, in particular, are typically large and complex networks, making test data preparation a challenging and demanding task. A single test case often involves numerous upstream systems with long chains and a multitude of components and systems. Data in the test environment is often mixed with dirty and invalid data from different business component libraries, making it difficult to obtain complete and valid data. Currently, querying databases for valid data is a crucial method for test data preparation, but this requires traversing massive amounts of data to filter out complete and usable information, which is time-consuming and inefficient. Summary of the Invention
[0003] The purpose of this invention is to provide cross-database query methods, apparatus, devices, media, and computer program products to solve the technical problems of large resource consumption, long time consumption, and low efficiency in existing cross-database queries.
[0004] A first embodiment of the present invention discloses a cross-database query method for a system comprising multiple databases, the method comprising:
[0005] Receive user query requests;
[0006] Perform a single database query;
[0007] Determine if there is a subsequent single database query. If so, extract related data from the results of the single database query in the above steps and perform a subsequent single database query based on the related data. If not, merge all single database query results and return the merged single database query results to the user.
[0008] Based on the query results, determine the pagination and check if there is data for the next page. If there is, perform a single database query for the next page based on the pagination. If not, end the cross-database query.
[0009] Optionally, determining pagination based on query results further includes:
[0010] Based on the field and index characteristics of the multiple databases, analyze the structural characteristics of the query results to extract multiple feature fields;
[0011] Combine the multiple feature fields into a data key value;
[0012] Based on the data key values, conditional filtering is performed on the multiple databases.
[0013] Optionally, determining whether there is a subsequent single database query further includes:
[0014] Determine if data was found. If so, check if there is a subsequent single database query. If not, end the cross-database query.
[0015] Optionally, ending the cross-database query further includes:
[0016] Determine if there is a preceding single database query. If so, return the preceding single database query; otherwise, end the cross-database query.
[0017] Optionally, determining pagination based on query results and checking if there is a next page of data includes:
[0018] Determine if enough data has been retrieved. If so, end the cross-database query. If not, determine pagination based on the query results and check if there is data for the next page.
[0019] Optionally, it also includes:
[0020] Based on the query efficiency of each database in the multiple databases, the query order of the multiple databases is optimized.
[0021] Optionally, it also includes:
[0022] The method of ending a cross-database query also includes: recording the current query position and then ending the cross-database query;
[0023] The next time a cross-database query is performed, the query will begin from the position recorded in the record.
[0024] A second embodiment of the present invention discloses a cross-database query apparatus for a system including multiple databases, the apparatus comprising:
[0025] The receiving module receives user query requests;
[0026] The query module performs single-database queries;
[0027] The cross-database module determines whether there is a subsequent single database query. If there is, it extracts related data from the results of the single database query in the above steps and performs a subsequent single database query based on the related data. If there is no single database query, it merges all single database query results and returns the merged single database query results to the user.
[0028] The pagination module determines the pagination based on the query results, checks if there is data for the next page, and if so, performs a single-database query for the next page based on the pagination; otherwise, it terminates the cross-database query.
[0029] A third embodiment of the present invention discloses an electronic device, which includes a memory storing computer-executable instructions and a processor. When the instructions are executed by the processor, the electronic device performs a cross-database query method according to a first embodiment of the present invention.
[0030] A fourth embodiment of the present invention discloses a computer storage medium storing instructions that, when executed on a computer, cause the computer to perform a cross-database query method according to a first embodiment of the present invention.
[0031] The fifth embodiment of the present invention discloses a computer program product including computer-executable instructions, which are executed by a processor to implement a cross-database query method according to the first embodiment of the present invention.
[0032] The main differences and effects of the embodiments of the present invention compared with the prior art are as follows:
[0033] In this invention, cross-database queries are performed in batches (pages), using iterative, step-by-step queries to achieve cross-database queries. Multiple queries in small batches avoid timeout issues associated with large queries. Furthermore, single-page query results are output in real time, and the data results are saved to the dataset for easy monitoring of query progress and results.
[0034] In this invention, the query order of multiple databases is automatically optimized based on the query efficiency of each database, thereby improving the efficiency of cross-database queries.
[0035] In this invention, feature fields are dynamically extracted and combined during the query process to form data key values for filtering conditions. Pagination is converted into conditional filtering to replace conventional pagination, achieving dual filtering through the database and code. This better utilizes indexes, effectively avoids pagination performance issues, and improves pagination efficiency.
[0036] In this invention, when a query task is executed again, the query position at the end of the previous query task is automatically located and the query continues, skipping duplicate data queries and avoiding the need to start the query from the beginning every time a query task is executed. Attached Figure Description
[0037] Figure 1 An exemplary block diagram of a system including multiple databases according to an embodiment of this application is shown.
[0038] Figure 2A flowchart illustrating a cross-database query method according to an embodiment of this application is shown.
[0039] Figure 3 Showing based on Figure 2 A flowchart of a preferred embodiment of the improved cross-database query method shown in the example.
[0040] Figure 4 A flowchart illustrating a method for implementing cross-database queries by configuring and executing query tasks according to an embodiment of this application is shown.
[0041] Figure 5 A schematic diagram illustrating a query template according to an embodiment of this application is shown.
[0042] Figure 6 A block diagram of a cross-database query apparatus according to an embodiment of this application is shown.
[0043] Figure 7 A hardware structure block diagram of an electronic device according to an embodiment of this application is shown. Detailed Implementation
[0044] To make the objectives, technical solutions, and advantages of this application clearer, the embodiments of this application will be described in further detail below with reference to the accompanying drawings.
[0045] Software development and testing require a large amount of test data, especially in the financial sector where numerous business systems and complex data dependencies make data acquisition a challenging task. Querying existing data from current systems for testing is a common data preparation method. However, the test data needed for a single testing activity is often distributed across numerous business system databases, requiring cross-database joins to obtain effective test data. Existing technologies require manual queries to each database separately, resulting in complex cross-database join operations and the need to traverse massive amounts of data to search for related data, leading to high resource consumption, long processing times, and low efficiency. Furthermore, traditional pagination performs poorly in querying large batches of paginated data, particularly for end-of-line or high-page-number data, and there is a problem of duplicate queries when executing multiple query tasks.
[0046] To address the aforementioned technical issues, embodiments of this application provide a cross-database query method for systems comprising multiple databases. The acquisition, storage, use, and processing of data in the technical solution of this application all comply with relevant national laws and regulations. Figure 1 An exemplary block diagram of a system including multiple databases according to an embodiment of this application is shown. Figure 2 A flowchart of a cross-database query method according to an embodiment of this application is shown below, in conjunction with... Figure 1 and Figure 2 This cross-database query method is described.
[0047] like Figure 1 As shown, system 100 includes database 101, database 102, and database 103. Figure 2 As shown, cross-database query methods include:
[0048] S201, Receive user query request; for example, a software tester in the financial field sends a data query request to obtain dataset A, dataset B and dataset C from system 100, wherein dataset A is stored in database 101, dataset B is stored in database 102 and dataset C is stored in database 103.
[0049] S202, perform a single database query; for example, in response to the received query request, first query data b1 belonging to the first page of dataset B from database 102.
[0050] S203, Determine if there is a subsequent database query;
[0051] S204, if any, extract related data from the results of the single database query in the above steps, and based on the related data, return to S202 to perform subsequent single database queries; for example, after querying data b1 belonging to the first page of dataset B from database 102, determine that the data belonging to the first page of datasets A and C has not yet been queried, and according to the configured query order, query database 103 after querying database 102, and query database 101 after querying database 103, then extract related data from data b1, and then based on the related data, query data c1 belonging to the first page of dataset C from the subsequent database 103.
[0052] S205, if not, then merge all single database query results and return the merged single database query results to the user; for example, after querying data b1, data c1 and data a1 belonging to the first page of dataset A, all data on the first page has been queried. For the data on the first page, there are no further single database queries. Therefore, the queried data b1, data c1 and data a1 are filtered and merged into the first page result dataset P1, and the first page result dataset P1 is returned to the aforementioned software tester.
[0053] S206, determine pagination based on query results, and determine if there is data on the next page;
[0054] S207, if applicable, proceed to the next page of data based on pagination, and return to S202 to perform a single database query for the next page; for example, after querying the first page of data, i.e., obtaining the first page result dataset P1, pagination is performed. If, after pagination, it is found that there are second pages of data in datasets A, B, and C that need to be queried, the above steps are repeated, sequentially querying the second page of data b2 of dataset B from database 102, the second page of data c2 of dataset C from database 103, and the second page of data a2 of dataset A from database 101.
[0055] If not, the cross-database query ends.
[0056] Figure 3 It shows the basis Figure 2 A flowchart of a preferred embodiment of the improved cross-database query method shown in the example is provided, wherein:
[0057] S202 specifically includes: S301, inputting query filter conditions and combining SQL statements according to the configuration; S302, executing the SQL; S303, processing the query results. S207 specifically includes setting pagination conditions and querying the next page of data.
[0058] Between S202 and S203, there is also S304, which determines whether data has been found; between S205 and S206, there is also S305, which determines whether enough data has been found; after S206 and before the cross-database query ends, there is also S306, which determines whether there is a preceding single-database query.
[0059] If the result of S304 is yes, proceed to S203 to determine if there is a subsequent order database query. If the result of S304 is no, proceed to S306 to determine if there is a preceding order database query.
[0060] If the result of S305 is yes, the cross-database query ends. If the result of S305 is no, proceed to S206, determine pagination based on the query result, and determine if there is data for the next page.
[0061] If the judgment result of S306 is yes, then after returning the previous single database query in S307, proceed to S206, determine pagination based on the query result, and determine whether there is data for the next page. If the judgment result of S306 is no, then end the cross-database query.
[0062] In this invention, cross-database queries are performed in batches (pages), using iterative, step-by-step queries to achieve cross-database queries. Multiple queries in small batches avoid timeout issues associated with large queries. Furthermore, single-page query results are output in real time, and the data results are saved to the dataset for easy monitoring of query progress and results.
[0063] According to some embodiments of this application, determining pagination based on query results further includes: analyzing the structural characteristics of the query results based on the field and index characteristics of multiple databases to extract multiple feature fields; combining the multiple feature fields into data key values; and performing conditional filtering on multiple databases based on the data key values.
[0064] In large-volume paginated data queries, traditional pagination has low performance for querying tail data and large page number data. In this application, feature fields are dynamically extracted and combined to form data key values for filtering conditions during the query process. Pagination is converted into conditional filtering to replace conventional pagination. This achieves dual filtering of database and code, better utilizes indexes, effectively avoids pagination performance problems, and improves pagination efficiency.
[0065] According to some embodiments of this application, the method further includes: optimizing the query order of multiple databases based on the query efficiency of each database in the multiple databases. For example, in accordance with... Figure 2 The steps shown involve first querying the related databases in real time during the initial query. Based on field and index characteristics, the resulting data structure is analyzed, and multiple feature fields are extracted and combined to form data keys. Then, the data b1 from the first page of dataset B is queried sequentially from database 102, the data c1 from the first page of dataset C is queried from database 103, and the data a1 from the first page of dataset A is queried from database 101. Considering the query efficiency of the target database, it is determined that querying in the order of database 101, database 102, and database 103 is more efficient. Therefore, when querying the data for the second page, databases 101, 102, and 103 are queried in this order.
[0066] In this invention, the query order of multiple databases is automatically optimized based on the query efficiency of each database, thereby improving the efficiency of cross-database queries.
[0067] According to some embodiments of this application, the method further includes: ending the cross-database query further includes: recording the current query position and then ending the cross-database query.
[0068] According to some embodiments of this application, the following query configuration steps are further included before starting to execute cross-database queries:
[0069] Configure the query task; obtain database information; generate an SQL query set based on the received query request; obtain the query position recorded at the end of the last cross-database query and start the query from that query position.
[0070] This invention addresses the problem of duplicate data retrieval by employing a breakpoint-based query continuation method. This avoids the need to start the query from the beginning each time a query task is executed, thus accelerating the retrieval of valid data. When a query task is executed again, the system automatically locates the position where the previous query task ended, prioritizes reading from that position, and continues querying data from there. This breakpoint-based query continuation method effectively solves the problem of duplicate data retrieval, preventing the need to start the query from the beginning each time a query task is executed and accelerating the retrieval of valid data.
[0071] The cross-database query method according to this application can be implemented based on a visual interface. Specifically, in scenarios where software testers in the financial field want to obtain a dataset from system 100, they can configure query tasks in the visual interface of system 100 or other systems associated with system 100. Figure 4 A flowchart illustrating a method for implementing cross-database queries by configuring and executing query tasks is shown, including:
[0072] S410, Configure the query element; a query element is a component used to query data from a single database. For each database, configuring the query element may include the following sub-steps: S411, Configure the database link; S412, Import database tables; S413, Select database tables; S414, Configure the join fields between database tables; S415, Configure the query fields; and S416, Configure the output fields; then in S417, generate the corresponding single-database query SQL statement. For example, as... Figure 5 As shown, if a software tester wants to obtain the datasets stored in database 101, database 102, and database 103 from system 100, they can configure query elements 501, 502, and 503 for database 101, database 102, and database 103 respectively on the system's web visualization interface based on the data to be queried.
[0073] S420, Configure the query template; the query template is a component used to query data from multiple databases, containing multiple query elements and their interrelationships. Configuring the query template includes the following sub-steps: S421, Select query elements; S422, Configure the relationships between query elements; S423, Configure query fields; S424, Configure output fields; and S425, Configure the output result dataset, where the result dataset is a component used to store and manage the query template execution results. For example, software testers configure the query template in the system's web visualization interface as follows: Figure 5The query template 500 shown configures the relationships between query elements 501 and 502, and between query elements 502 and 503, because the execution of query element 503 depends on the execution result of query element 502, and the execution of query element 502 depends on the execution result of query element 501, or, depending on the current query task, connections need to be established between databases 101 and 102, and between databases 102 and 103, for related queries. Furthermore, a result dataset 504 is configured to store and manage the execution results of query template 500.
[0074] S430, execute the query template. For example, based on... Figure 2 The process steps shown for executing query template 500 include: receiving a user's instruction to complete configuration and request execution of query template 500. Then, based on the configured query template 500, first, query element 501 is executed, i.e., a single database query is performed on database 101; then, if a subsequent query element 502 is found in query template 500, related data is extracted from the execution result of query element 501, and query element 502 is executed based on this related data; then, if a subsequent query element 503 is found in query template 500, related data is extracted from the execution result of query element 502, and query element 503 is executed based on this related data; finally, if no subsequent query element is found in query template 500, the execution results (i.e., the retrieved data) of query elements 501, 502, and 503 are merged and stored in the result dataset 504, which is then returned to the software testers. Afterwards, pagination is determined based on the above query results. It is determined whether there is a next page of data. If there is, the above steps are repeated to query the next page of data; otherwise, the current query task ends.
[0075] Figure 6 A block diagram of a cross-database query apparatus according to an embodiment of this application is shown. The cross-database query apparatus 600 is used in a system including multiple databases, and includes:
[0076] Receiver module 601 receives user query requests;
[0077] Query module 602 performs single database queries;
[0078] The cross-database module 603 determines whether there is a subsequent single database query. If there is, it extracts related data from the results of the single database query in the above steps and performs a subsequent single database query based on the related data. If there is no single database query, it merges all single database query results and returns the merged single database query results to the user.
[0079] The pagination module 604 determines pagination based on the query results. It checks if there is data for the next page. If there is, it performs a single-database query for the next page based on the pagination. If not, it terminates the cross-database query.
[0080] The method embodiments of this application correspond to this embodiment, and this embodiment can be implemented in conjunction with the method embodiments of this application. The relevant technical details mentioned in the method embodiments of this application are still valid in this embodiment, and will not be repeated here to reduce repetition. Accordingly, the relevant technical details mentioned in this embodiment can also be applied to the method embodiments of this application.
[0081] Figure 7 This is a hardware structure block diagram of an electronic device that implements cross-database queries according to embodiments of this application.
[0082] like Figure 7 As shown, the electronic device 700 may include one or more processors 702, a system motherboard 708 connected to at least one of the processors 702, a system memory 704 connected to the system motherboard 708, a non-volatile memory (NVM) 706 connected to the system motherboard 708, and a network interface 710 connected to the system motherboard 708.
[0083] Processor 702 may include one or more single-core or multi-core processors. Processor 702 may include any combination of general-purpose processors and special-purpose processors (e.g., graphics processors, application processors, baseband processors, etc.). In embodiments of the invention, processor 702 may be configured to perform operations according to... Figures 1-5 One or more embodiments of the various embodiments shown.
[0084] In some embodiments, the system motherboard 708 may include any suitable interface controller to provide any suitable interface to at least one of the processors 702 and / or any suitable device or component communicating with the system motherboard 708.
[0085] In some embodiments, system motherboard 708 may include one or more memory controllers to provide an interface to system memory 704. System memory 704 may be used to load and store data and / or instructions. In some embodiments, system memory 704 of electronic device 700 may include any suitable volatile memory, such as suitable dynamic random access memory (DRAM).
[0086] The NVM 706 may include one or more tangible, non-transitory computer-readable media for storing data and / or instructions. In some embodiments, the NVM 706 may include any suitable non-volatile memory such as flash memory and / or any suitable non-volatile storage device, such as at least one of an HDD (Hard Disk Drive), a CD (Compact Disc) drive, or a DVD (Digital Versatile Disc) drive.
[0087] The NVM 706 may include a portion of the storage resources on a device installed on the electronic device 700, or it may be accessible by the device, but is not necessarily part of the device. For example, the NVM 706 may be accessed over a network via the network interface 710.
[0088] Specifically, system memory 704 and NVM 706 may each include a temporary copy and a permanent copy of instruction 720, respectively. Instruction 720 may include, when executed by at least one of processors 702, causing electronic device 700 to perform, as Figures 1-5 The instructions for the method shown. In some embodiments, the instructions 720, hardware, firmware and / or their software components may additionally / alternatively be located in the system motherboard 708, network interface 710 and / or processor 702.
[0089] Network interface 710 may include a transceiver for providing a radio interface to electronic device 700, thereby enabling communication with any other suitable device (e.g., front-end module, antenna, etc.) via one or more networks. In some embodiments, network interface 710 may be integrated into other components of electronic device 700. For example, network interface 710 may be integrated into at least one of processor 702, system memory 704, NVM 706, and firmware device (not shown) with instructions, wherein electronic device 700 implements [the desired functionality] when at least one of processor 702 executes the instructions. Figures 1-5 One or more embodiments of the various embodiments shown.
[0090] The network interface 710 may further include any suitable hardware and / or firmware to provide a multiple-input multiple-output radio interface. For example, the network interface 710 may be a network adapter, a wireless network adapter, a telephone modem, and / or a wireless modem.
[0091] In one embodiment, at least one of the processors 702 may be packaged together with one or more controllers for the system motherboard 708 to form a system-in-package (SiP). In another embodiment, at least one of the processors 702 may be integrated on the same die with one or more controllers for the system motherboard 708 to form a system-on-a-chip (SoC).
[0092] The electronic device 700 may further include an input / output (I / O) device 712 connected to the system motherboard 708. The I / O device 712 may include a user interface enabling a user to interact with the electronic device 700; the peripheral component interface is designed to allow peripheral components to also interact with the electronic device 700. In some embodiments, the electronic device 700 may also include sensors for determining at least one type of environmental condition and location information related to the electronic device 700.
[0093] In some embodiments, the I / O device 712 may include, but is not limited to, a display (e.g., a liquid crystal display, a touch screen display, etc.), a speaker, a microphone, one or more cameras (e.g., a still image camera and / or a video camera), a flashlight (e.g., an LED flash) and a keyboard.
[0094] In some embodiments, the peripheral component interface may include, but is not limited to, a non-volatile memory port, an audio jack, and a power interface.
[0095] In some embodiments, the sensor may include, but is not limited to, a gyroscope sensor, an accelerometer, a proximity sensor, an ambient light sensor, and a positioning unit. The positioning unit may also be part of or interact with the network interface 710 to communicate with components of the positioning network (e.g., Global Positioning System (GPS) satellites).
[0096] It is understood that the structures illustrated in the embodiments of the present invention do not constitute a specific limitation on the electronic device 700. In other embodiments of this application, the electronic device 700 may include more or fewer components than illustrated, or combine some components, or split some components, or have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
[0097] Program code can be applied to input instructions to perform the functions described in this invention and generate output information. The output information can be applied to one or more output devices in a known manner. For the purposes of this application, a system for processing instructions including processor 702 includes any system having a processor such as a digital signal processor (DSP), microcontroller, application-specific integrated circuit (ASIC), or microprocessor.
[0098] The program code can be implemented using a high-level procedural language or an object-oriented programming language to communicate with the processing system. Assembly language or machine language can also be used when needed. In fact, the mechanisms described in this invention are not limited to any particular programming language. In either case, the language can be a compiled language or an interpreted language.
[0099] One or more aspects of at least one embodiment can be implemented by instructions stored on a computer-readable storage medium, which, when read and executed by a processor, enable an electronic device to implement the methods of the embodiments described in this invention.
[0100] According to some embodiments of this application, a computer storage medium is disclosed, on which instructions are stored, which, when executed on a computer, cause the computer to perform a cross-database query method according to embodiments of this application.
[0101] The method embodiments of this application correspond to this embodiment, and this embodiment can be implemented in conjunction with the method embodiments of this application. The relevant technical details mentioned in the method embodiments of this application are still valid in this embodiment, and will not be repeated here to reduce repetition. Accordingly, the relevant technical details mentioned in this embodiment can also be applied to the method embodiments of this application.
[0102] According to some embodiments of this application, a computer program product is disclosed, including computer-executable instructions that are executed by a processor to implement a cross-database query method according to embodiments of this application.
[0103] The method embodiments of this application correspond to this embodiment, and this embodiment can be implemented in conjunction with the method embodiments of this application. The relevant technical details mentioned in the method embodiments of this application are still valid in this embodiment, and will not be repeated here to reduce repetition. Accordingly, the relevant technical details mentioned in this embodiment can also be applied to the method embodiments of this application.
[0104] It is understood that the specific embodiments described herein are merely for illustrative purposes and not for limiting the scope of this application. Furthermore, for ease of description, the accompanying drawings show only the parts relevant to this application, and not all of the structures or processes. It should be noted that similar reference numerals and letters in this specification denote similar items in the accompanying drawings.
[0105] It should be understood that although the terms "first," "second," etc., may be used herein to describe various features, these features should not be limited by these terms. The use of these terms is merely for distinction and should not be construed as indicating or implying relative importance. For example, without departing from the scope of the exemplary embodiments, a first feature may be referred to as a second feature, and similarly, a second feature may be referred to as a first feature.
[0106] The illustrative embodiments of this application include, but are not limited to, cross-database query methods, apparatuses, devices, media, and computer program products.
[0107] Various aspects of the illustrative embodiments will be described using terminology commonly employed by those skilled in the art to convey the essence of their work to others skilled in the art. However, it will be apparent to those skilled in the art that some alternative embodiments will be practiced using the features partially described. Specific figures and configurations are set forth for purposes of explanation in order to provide a more thorough understanding of the illustrative embodiments. However, it will be apparent to those skilled in the art that alternative embodiments may be practiced without specific details. In some other instances, well-known features have been omitted or simplified herein to avoid obscuring the illustrative embodiments of this application.
[0108] Furthermore, the various operations will be described as multiple separate operations in a manner most conducive to understanding the illustrative embodiments; however, the order of description should not be construed as implying that these operations must depend on the order of description, and many of these operations may be performed in parallel, concurrently, or simultaneously. Moreover, the order of the operations may also be rearranged. The process may be terminated when the described operations are completed, but may also include additional steps not included in the figures. The process may correspond to a method, function, procedure, subroutine, subroutine, etc.
[0109] References to "an embodiment," "embodiment," "illustrative embodiment," etc., in this specification indicate that the described embodiment may include specific features, structures, or properties; however, each embodiment may or may not necessarily include specific features, structures, or properties. Furthermore, these phrases are not necessarily directed to the same embodiment. Additionally, when specific features are described in conjunction with specific embodiments, the knowledge of those skilled in the art can influence the combination of these features with other embodiments, whether or not those embodiments are explicitly described.
[0110] Unless the context otherwise specifies, the terms “comprising,” “having,” and “including” are synonyms. The phrase “A and / or B” means “(A), (B), or (A and B).”
[0111] As used herein, the term "module" may refer to, as part of, or include: a memory (shared, dedicated, or grouped), an application-specific integrated circuit (ASIC), electronic circuitry and / or a processor (shared, dedicated, or grouped), combinational logic circuitry, and / or other suitable components that provide the said functionality for running one or more software or firmware programs.
[0112] In the accompanying drawings, some structural or methodological features may be shown in a specific arrangement and / or order. However, it should be understood that such a specific arrangement and / or order is not necessary. Rather, in some embodiments, these features may be illustrated in a manner and / or order different from that shown in the illustrative drawings. Furthermore, the inclusion of structural or methodological features in a particular drawing does not mean that all embodiments need to include such features; in some embodiments, these features may be omitted or may be combined with other features.
[0113] In some cases, the disclosed embodiments may be implemented in hardware, firmware, software, or any combination thereof. The disclosed embodiments may also be implemented as instructions or programs carried or stored on one or more transient or non-transient machine-readable (e.g., computer-readable) storage media, which may be read and executed by one or more processors, etc. When the instructions or program are run by a machine, the machine may perform the various methods described above. For example, the instructions may be distributed via a network or other computer-readable media. Therefore, machine-readable media may include, but are not limited to, any mechanism for storing or transmitting information in a machine-readable (e.g., computer-readable) form, such as floppy disks, optical disks, optical disc read-only memories (CD-ROMs), magneto-optical disks, read-only memories (ROMs), random access memories (RAMs), erasable programmable read-only memories (EPROMs), electronically erasable programmable read-only memories (EEPROMs), magnetic cards or optical cards, or flash memory or tangible machine-readable storage for transmitting network information via electrical, optical, acoustic, or other forms of signals (e.g., carrier waves, infrared signals, digital signals, etc.). Therefore, machine-readable media includes any form of machine-readable medium suitable for storing or transmitting electronic instructions or machine (e.g., computer) readable information.
[0114] The embodiments of this application have been described in detail above with reference to the accompanying drawings. However, the use of the technical solutions of this application is not limited to the various applications mentioned in the embodiments of this application. Various structures and modifications can be easily implemented with reference to the technical solutions of this application to achieve the various beneficial effects mentioned herein. Within the scope of knowledge possessed by those skilled in the art, all changes made without departing from the spirit of this application should be considered within the scope of this patent application.
Claims
1. A cross-database query method for a system comprising a plurality of databases, characterized by, The method includes: Receive a query request to execute a pre-configured query template; wherein the query template includes multiple query elements and associations for defining the query order and data dependencies of the multiple query elements, and each query element corresponds to a single database query; According to the query order configured in the query template, the first query element is executed to perform a single database query; Determine if there are any subsequent query elements. If so, extract the related data from the results of the single database query based on the relationship, and execute the subsequent query elements based on the related data. If not, merge the execution results of all query elements into a single database query result and return the merged single database query result to the user. Based on the merged single database query results, determine the pagination conditions, and check if there is data for the next page. If there is, perform a single database query for the next page based on the pagination conditions; otherwise, end the cross-database query. The method of determining pagination conditions based on merged single database query results includes: Based on the field and index characteristics of the multiple databases, analyze the structural characteristics of the merged single database query results to extract multiple feature fields; Combine the multiple feature fields into a data key value; The data key is used as the pagination condition to filter the multiple databases.
2. The method of claim 1, wherein, The determination of whether there is a subsequent query element also includes: Determine if data was found. If so, check if there are any subsequent query components. If not, end the cross-database query.
3. The method of claim 2, wherein, The termination of cross-database queries also includes: Determine if there is a preceding single database query. If so, return the preceding single database query; otherwise, end the cross-database query.
4. The method of claim 1, wherein, The process of determining pagination conditions based on merged single database query results, and determining whether there is a next page of data, includes: Determine if enough data has been retrieved. If so, end the cross-database query. If not, determine the pagination conditions based on the merged single-database query results and determine if there is data for the next page.
5. The method according to claim 1, characterized in that, Also includes: Based on the query efficiency of each database in the multiple databases, the query order of the multiple databases is optimized.
6. The method according to claim 1, characterized in that, Also includes: The method of ending a cross-database query also includes: recording the current query position and then ending the cross-database query; The next time a cross-database query is performed, the query will begin from the position recorded in the record.
7. A cross-database query apparatus for a system comprising multiple databases, characterized in that, The device includes: The receiving module receives a query request to execute a pre-configured query template; wherein the query template includes multiple query elements and the association relationship for defining the query order and data dependencies of the multiple query elements, and each query element corresponds to a single database query; The query module executes the first query element to perform a single database query according to the query order configured in the query template; The cross-database module determines whether there are subsequent query elements. If there are, it extracts the related data from the results of the single database query based on the relationship and executes the subsequent query elements based on the related data. If there are no subsequent query elements, it merges the execution results of all query elements into a single database query result and returns the merged single database query result to the user. The pagination module determines pagination conditions based on the merged single database query results, checks whether there is data for the next page, and if so, performs a single database query for the next page based on the pagination conditions; otherwise, it ends the cross-database query. The method of determining pagination conditions based on merged single database query results includes: Based on the field and index characteristics of the multiple databases, analyze the structural characteristics of the merged single database query results to extract multiple feature fields; Combine the multiple feature fields into a data key value; The data key is used as the pagination condition to filter the multiple databases.
8. An electronic device, characterized in that, The electronic device includes a memory storing computer-executable instructions and a processor, which, when executed by the processor, cause the electronic device to perform the cross-database query method according to any one of claims 1-6.
9. A computer storage medium, characterized in that, Instructions are stored on the computer storage medium, which, when executed on the computer, cause the computer to perform the cross-database query method according to any one of claims 1-6.
10. A computer program product, characterized in that, It includes computer-executable instructions that are executed by a processor to implement the cross-database query method according to any one of claims 1-6.