Data query method, device, storage medium and equipment

By matching the query identifier with the historical query identifier during the data query process, the problem of slow response speed in the prior art is solved, and faster query response and higher data processing efficiency are achieved.

CN114238404BActive Publication Date: 2025-09-05CCB FINTECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202111538851.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-15
Publication Date
2025-09-05
Estimated Expiration
2041-12-15

AI Technical Summary

Technical Problem

Existing data query methods have slow response speeds when querying or returning large amounts of data, making it difficult to meet the requirement of returning query results within the specified time.

Method used

By determining the query identifier in the query request and matching the historical query identifier in the cache area, the query result data is obtained, the number of visits to the search engine is reduced, and the response speed is improved.

Benefits of technology

Through the cache classification mechanism, the number of visits to the second database is reduced, the response speed of the query process is improved, and the processing capacity of data volume and query requests is increased.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114238404B_ABST
    Figure CN114238404B_ABST
Patent Text Reader

Abstract

The present application provides a data query method, device, storage medium and equipment, which belong to the field of data query technology. The main steps are: first, determine the first query identifier corresponding to the query condition in the query request sent by the terminal device; if the first query identifier exists in the first cache area corresponding to the first database, then determine the query result data corresponding to the first query identifier from the first database; the first cache area is used to cache historical query identifiers, and the first database contains historical query result data corresponding to the historical query identifiers. In this way, the first query identifier corresponding to the query request can be matched with the historical query identifier, and the query result data can be obtained according to the matched historical query identifier, thereby improving the response speed of the entire query process.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

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

[0002] With the rapid development of information technology, the amount of data in various fields has shown a significant growth trend. How to query massive data and extract useful information from it is a problem that needs to be solved.

[0003] In the prior art, large amounts of data are primarily queried using tools such as search engines. For example, a multi-field index provided by a real-time search engine (ElasticSearch) allows for flexible query requirements and the acquisition of query results from large amounts of data.

[0004] However, existing data query methods prolong the time required to return query results when the amount of data to be queried or returned is large, resulting in a slow response speed for the entire query process and making it difficult to meet the requirements of certain query scenarios that need to return query results within a specified time. Summary of the Invention

[0005] The present application provides a data query method, apparatus, storage medium and device to solve the technical problem of slow response speed in the query process in the prior art.

[0006] In a first aspect, the present application provides a data query method, the method comprising:

[0007] Determining a first query identifier corresponding to a query condition in a query request sent by a terminal device;

[0008] If the first query identifier exists in the first cache area corresponding to the first database, the query result data corresponding to the first query identifier is determined from the first database. The first cache area is used to cache historical query identifiers, and the first database contains historical query result data corresponding to the historical query identifier.

[0009] In an optional implementation, after determining the first query identifier corresponding to the query request, the method further includes:

[0010] If the first query identifier does not exist in the first cache area corresponding to the first database, determining the index data corresponding to the first query identifier from the second database;

[0011] Query result data corresponding to the first query identifier is determined from the first database according to the index data.

[0012] In an optional implementation, the first query identifier is determined according to structured query language.

[0013] In an optional implementation manner, determining the query result data corresponding to the first query identifier from the first database includes:

[0014] Determining the primary key data corresponding to the first query identifier based on the mapping relationship between the historical query identifier and the primary key data;

[0015] According to the primary key data, query result data corresponding to the first query identifier is determined from the historical query result data of the first database.

[0016] In an optional implementation manner, determining the index data corresponding to the first query identifier from the second database includes:

[0017] If the first query identifier does not exist in the first cache area corresponding to the first database, determining whether the first query identifier exists in the second cache area corresponding to the second database;

[0018] If not, determining index data corresponding to the first query identifier from the second database;

[0019] The first query identifier is cached in the second cache area.

[0020] In an optional implementation, after determining the query result data corresponding to the first query identifier from the first database, the method further includes:

[0021] Remove the first query identifier from the second cache area.

[0022] In an optional implementation, after determining whether the first query identifier exists in the second cache area corresponding to the second database, the method further includes:

[0023] If so, stop determining the index data corresponding to the first query identifier from the second database.

[0024] In an optional implementation manner, the first database also includes data to be queried obtained from a data source device.

[0025] In an optional implementation, after determining the index data corresponding to the first query identifier from the second database, the method further includes:

[0026] According to the index data, query result data corresponding to the first query identifier is determined from the data to be queried in the first database.

[0027] In an optional implementation, after determining the query result data corresponding to the first query identifier from the data to be queried in the first database, the method further includes:

[0028] Storing the query result data in the historical query result data of the first database;

[0029] The first query identifier is stored in the first cache area.

[0030] In an optional implementation, the method further includes:

[0031] If the first query identifier does not exist in the first cache area corresponding to the first database, a prompt message is sent to the terminal device, where the prompt message includes the first query identifier and is used to instruct the terminal device to submit a query request again.

[0032] In an optional implementation, after determining the query result data corresponding to the first query identifier from the historical query result data of the first database, the method further includes:

[0033] The first query identifier and query result data corresponding to the first query identifier are sent to the terminal device.

[0034] In a second aspect, the present application provides a data query device, the device comprising:

[0035] A determination module, configured to determine a first query identifier corresponding to a query condition in a query request sent by a terminal device;

[0036] A query module is used to determine the query result data corresponding to the first query identifier from the first database if the first query identifier exists in the first cache area corresponding to the first database, the first cache area is used to cache historical query identifiers, and the first database contains historical query result data corresponding to the historical query identifier.

[0037] In an optional embodiment, the query module is also used to determine the index data corresponding to the first query identifier from the second database if the first query identifier does not exist in the first cache area corresponding to the first database; and determine the query result data corresponding to the first query identifier from the first database based on the index data.

[0038] In an optional implementation, the first query identifier is determined according to structured query language.

[0039] In an optional embodiment, the query module is specifically used to determine the primary key data corresponding to the first query identifier based on the mapping relationship between the historical query identifier and the primary key data; and based on the primary key data, determine the query result data corresponding to the first query identifier from the historical query result data of the first database.

[0040] In an optional embodiment, the query module is specifically used to determine whether the first query identifier exists in the second cache area corresponding to the second database if the first query identifier does not exist in the first cache area corresponding to the first database; if not, determine the index data corresponding to the first query identifier from the second database; and cache the first query identifier to the second cache area.

[0041] In an optional implementation, the query module is further configured to remove the first query identifier from the second cache area.

[0042] In an optional implementation manner, the query module is further configured to, if yes, stop determining the index data corresponding to the first query identifier from the second database.

[0043] In an optional implementation manner, the first database also includes data to be queried obtained from a data source device.

[0044] In an optional implementation, the query module is further configured to determine, based on the index data, query result data corresponding to the first query identifier from the data to be queried in the first database.

[0045] In an optional implementation, the query module is further configured to store the query result data in the historical query result data of the first database; and store the first query identifier in the first cache area.

[0046] In an optional embodiment, the query module is also used to send a prompt message to the terminal device if the first query identifier does not exist in the first cache area corresponding to the first database, and the prompt message includes the first query identifier, and the prompt message is used to instruct the terminal device to submit the query request again.

[0047] In an optional implementation, the query module is further configured to send the first query identifier and query result data corresponding to the first query identifier to the terminal device.

[0048] In a third aspect, the present application further provides a computer program product, comprising a computer program, which, when executed by a processor, implements the method described in any one of the first aspects.

[0049] In a fourth aspect, the present invention further provides a computer storage medium storing a plurality of instructions, wherein the instructions are suitable for being loaded by a processor and executing the method as described in any one of the first aspects.

[0050] In a fifth aspect, the present application further provides an electronic device comprising: a processor and a memory; wherein the memory stores a computer program, and the computer program is suitable for being loaded by the processor and executing the method as described in any one of the first aspects.

[0051] The present application provides a data query method, apparatus, storage medium, and device. The method first determines a first query identifier corresponding to a query condition in a query request sent by a terminal device. If the first query identifier exists in a first cache area corresponding to a first database, query result data corresponding to the first query identifier is determined from the first database. The first cache area is used to cache historical query identifiers, and the first database contains historical query result data corresponding to the historical query identifiers. In this manner, the first query identifier corresponding to the query request can be matched with the historical query identifiers, and query result data can be obtained based on the matched historical query identifiers, thereby improving the response speed of the entire query process. BRIEF DESCRIPTION OF THE DRAWINGS

[0052] In order to more clearly illustrate the technical solutions in the present invention or the prior art, a brief introduction will be given below to the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0053] Figure 1 A schematic diagram of an application scenario of a data query method provided in an embodiment of the present application;

[0054] Figure 2 A flowchart of a data query method provided in an embodiment of the present application;

[0055] Figure 3 A schematic diagram of the structure of a data query system provided in an embodiment of the present application;

[0056] Figure 4 A flowchart of another data query method provided in an embodiment of the present application;

[0057] Figure 5 A flowchart of another data query method provided in an embodiment of the present application;

[0058] Figure 6 A schematic diagram of the structure of a data query device provided in an embodiment of the present application;

[0059] Figure 7 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0060] To make the purpose, technical solutions, and advantages of the embodiments of this application more clear, the technical solutions in the embodiments of this application will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of this application. Obviously, the described embodiments are part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.

[0061] With the rapid development of information technology, the amount of data in various fields has shown a significant growth trend. In the context of the big data era, how to query massive data and extract useful information from it is a problem that needs to be solved.

[0062] In the prior art, large amounts of data are primarily queried using tools such as search engines. For example, a multi-field index provided by a real-time search engine (ElasticSearch) allows for flexible query requirements and the acquisition of query results from large amounts of data.

[0063] However, existing data query methods prolong the time required to return query results when the amount of data to be queried or returned is large, resulting in a slow response speed for the entire query process and making it difficult to meet the requirements of certain query scenarios that require query results to be returned within a specified time.

[0064] To solve the above technical problems, the embodiments of the present application provide a data query method, apparatus, storage medium and device, which matches the first query identifier corresponding to the query request with the historical query identifier, and obtains query result data based on the matched historical query identifier, thereby reducing the number of visits to the search engine and improving the response speed of the query process.

[0065] The following describes an application scenario of a data query method involved in this application.

[0066] Figure 1 This is a schematic diagram of an application scenario of a data query method provided in an embodiment of the present application. Figure 1As shown, the system includes a terminal device 101 and a server 102. First, the terminal device 101 can send a query request to the server 102. After receiving the query request, the server 102 can determine a first query identifier corresponding to the query request, then match the first query identifier with historical query identifiers in the first cache area, select different query methods based on the matching results to determine query result data, and send the query result data or a preset prompt message to the terminal device 101.

[0067] Among them, the above-mentioned terminal device can be a mobile phone, a tablet computer, a computer with wireless transceiver function, a virtual reality (VR) terminal device, an augmented reality (AR) terminal device, a wireless terminal in self-driving, a wireless terminal in remote medical surgery, a wireless terminal in a smart grid, a wireless terminal in a smart home, etc. In the embodiment of the present application, the device for realizing the function of the terminal can be a terminal, or it can be a device that can support the terminal to realize the function, such as a chip system, which can be installed in the terminal. In the embodiment of the present application, the chip system can be composed of a chip, or it can include a chip and other discrete devices.

[0068] The server may be, but is not limited to, a single network server, a server group consisting of multiple network servers, or a cloud based on cloud computing consisting of a large number of computers or network servers.

[0069] It should be understood that the application scenario of the technical solution of this application can be Figure 1 The present invention is not limited to the query scenario of the data in the present invention, but can also be applied to other scenarios where data needs to be queried.

[0070] It can be understood that the above-mentioned data query method can be implemented by the data query device provided in the embodiment of the present application, and the data query device can be part or all of a certain device, such as a server.

[0071] The following specific embodiments are used to describe the technical solutions of the embodiments of the present application in detail. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described in detail in some embodiments.

[0072] Figure 2 This is a flow chart of a data query method provided in an embodiment of the present application. This embodiment involves the process of querying data according to a query request. This embodiment of the present application takes a server integrated or installed with relevant execution code as an example. Figure 2 As shown, the method includes:

[0073] S201: Determine a first query identifier corresponding to a query condition in a query request sent by a terminal device.

[0074] In an embodiment of the present application, the server may first determine a first query identifier corresponding to a query condition in a query request sent by a terminal device, and then determine the query result data that needs to be returned based on the first query identifier.

[0075] The embodiments of the present application do not limit the specific content contained in the query request. In some embodiments, the query request may include a first query identifier; in other embodiments, the query request may also include Structured Query Language (SQL). The SQL can be used to indicate the query conditions.

[0076] The server can determine the first query identifier based on the structured query language, and the embodiments of the present application do not limit this. In some embodiments, the server can encrypt the structured query language according to a preset encryption algorithm to generate a unique first query identifier corresponding to the query request. For example, the server can encrypt the SQL through the MD5 message digest algorithm (MD5Message-DigestAlgorithm), obtain a string with an MD5 value of "19c27f42b4d6a93f7f9ffc2ea9bdd765", and then use the string as the first query identifier (SQL ID). Among them, the encryption algorithm adopted by the server can be specifically set according to actual conditions, and the embodiments of the present application do not limit this.

[0077] It should be noted that, in some embodiments, when the query request includes structured query language but does not include the first query identifier, the server may first obtain the structured query language in the query request and generate the first query identifier corresponding to the query request based on the structured query language.

[0078] S202: If a first query identifier corresponding to the query request exists in a first cache area corresponding to the first database, query result data corresponding to the first query identifier is determined from the first database.

[0079] In this step, after determining the first query identifier, if the first query identifier exists in the first cache area corresponding to the first database, the server can determine the query result data corresponding to the first query identifier from the first database.

[0080] Among them, the first cache area is used to cache historical query identifiers, and the historical query identifiers include the first query identifiers for which corresponding query result data has been obtained. The first database contains historical query result data corresponding to the historical query identifiers. The embodiment of the present application does not limit the type of the first database. In some embodiments, the type of the first database can be determined based on the amount of data to be stored and the amount of query requests to be processed in parallel. For example, the first database can be an open source database (Hadoop Database, HBase) that can store massive amounts of data and process high-concurrency query requests.

[0081] The embodiments of the present application do not limit how to determine the query result data corresponding to the first query identifier from the first database. In some embodiments, if the first query identifier corresponding to the above-mentioned query request exists in the historical query identifiers stored in the first cache area, the server can determine the primary key data corresponding to the first query identifier based on the mapping relationship between the historical query identifier and the primary key data; and then determine the query result data corresponding to the first query identifier from the historical query result data of the first database based on the primary key data. Exemplarily, the server can determine the primary key data (RowKey) corresponding to the SQLID, and then determine the query result data from the historical query result data in the HBase database based on the RowKey.

[0082] Furthermore, after determining the query result data corresponding to the first query identifier from the historical query result data of the first database, the server may send the first query identifier and the query result data corresponding to the first query identifier to the terminal device, which is not limited in this application.

[0083] In other embodiments, if the first query identifier does not exist in the first cache area corresponding to the first database, the server may determine index data corresponding to the first query identifier from the second database; and then, based on the index data, determine the query result data corresponding to the first query identifier from the first database. It will be understood that if the first query identifier does not exist in the historical query data in the first cache area, the server cannot directly obtain the query result data corresponding to the first query identifier through the historical query result data.

[0084] It should be noted that the first database also includes the data to be queried obtained from the data source device, and the second database contains index data corresponding to the above-mentioned data to be queried. The embodiment of the present application does not limit how to obtain the data to be queried. In some embodiments, the server may first collect data that meets the requirements from a preset data source device as the data to be queried; and process the data to be queried to generate index data corresponding to the data to be queried; then store the data to be queried in the first database, and store the index data corresponding to the data to be queried in the second database. Exemplarily, the server may store the collected data to be queried in the Hbase database; at the same time, use the open source stream processing framework (Flink) to process the collected data in real time, generate index data corresponding to the data to be queried, and then store the index data in the ElsaticSearch database.

[0085] The embodiments of the present application do not limit how to determine the index data corresponding to the first query identifier. In some embodiments, if the first query identifier does not exist in the first cache area corresponding to the first database, then a determination is made as to whether the first query identifier exists in the second cache area corresponding to the second database; if not, then the index data corresponding to the first query identifier is determined from the second database, and the first query identifier is cached in the second cache area.

[0086] The second cache area is used to cache a first query identifier that is not present in the first cache area and is in the process of being queried. The query process may include determining index data based on the first query identifier and determining query result data based on the index data. It is understood that if a first query identifier identical to the first query identifier exists in the second cache area corresponding to the second database, it indicates that the query process corresponding to the first query identifier is in progress, and the determination of the index data corresponding to the first query identifier from the second database and the subsequent query process may be terminated.

[0087] If the second cache does not contain a first query identifier identical to the first query identifier, then there is no ongoing query process corresponding to the first query identifier. Furthermore, the server may cache the first query identifier that does not exist in the second cache in the second cache; simultaneously, based on the first query identifier, generate a query instruction, and determine index data corresponding to the first query identifier from the second database based on the query instruction; then, based on the index data, determine the query result data corresponding to the first query identifier from the data to be queried in the first database.

[0088] The embodiments of the present application do not limit how the index data is determined based on the first query identifier. In some embodiments, the server can generate a corresponding query instruction based on the first query identifier, such as an if conditional query statement, and then determine the index data based on the query instruction. Furthermore, after determining the query result data from the data to be queried, the server can remove the first query identifier from the second cache area.

[0089] It should be noted that the embodiments of the present application do not limit how to determine the historical query identifier and the corresponding historical query result data. In some embodiments, after determining the query result data corresponding to the first query identifier from the data to be queried, the server may also store the query result data as the historical query result data in the first database; and store the first query identifier corresponding to the query result data as the historical query identifier in the first cache area.

[0090] In other embodiments, if the first query identifier does not exist in the first cache area corresponding to the first database, the server may further send a prompt message to the terminal device. The prompt message includes the first query identifier, and the prompt message is used to instruct the terminal device to submit the query request again. For example, in certain query scenarios with strict requirements on the response time, for example, a scenario where a response to the query request must be made within 200 milliseconds (ms), if the query result is not returned within 200ms, the server may send the first query identifier and prompt field corresponding to the query request as prompt information to the terminal device. It can be understood that when submitting the query request again, the terminal device can directly provide the first query identifier.

[0091] Furthermore, the embodiments of the present application do not limit the specific content of the prompt field. In some embodiments, the content contained in the prompt field can be pre-set according to actual conditions. For example, the prompt field may include "Query in progress, please come back later to retrieve query results" or the like.

[0092] Figure 3 This is a schematic diagram of the structure of a data query system provided in an embodiment of the present application. Figure 3 As shown, it includes a terminal device 301, a memory cache area 302 and a database area 303. The memory cache area 302 includes a first cache area 3021, a second cache area 3022 and a request tracking component 3023; the database area 303 includes a first database 3031 and a second database 3032.

[0093] The first cache area 3021 can be represented by "CacheA", and the second cache area 3022 can be represented by "CacheB". The first database 3031 can include an HBase database, and the second database 3032 can include an ElasticSearch database. Terminal device 301 can initiate a query request on the front end through a related application. After the server determines the SQL ID corresponding to the query request, if the SQL ID exists in CacheA, it directly obtains the query result data from the HBase database and returns the SQL ID and the corresponding query result data to terminal device 301. If the SQL ID does not exist in CacheA but exists in CacheB, the subsequent query process is terminated.

[0094] If the SQL ID does not exist in CacheA and CacheB, a prompt message is sent to terminal device 301, instructing terminal device 301 to submit the query request again. The SQL ID is cached in CacheB, and the corresponding index data is obtained from the ElasticSearch database based on the SQL ID. The query result data is then obtained from the query data in the HBase database based on the index data. The obtained query result data is then stored in the historical query result data in the HBase database, the SQL ID is stored in the historical query identifier in the HBase database, and the SQL ID in CacheB is removed.

[0095] The request tracking component 3023 is responsible for data synchronization at each stage and monitors the query duration corresponding to each query request.

[0096] It should be noted that the server can use a least recently used (LRU) algorithm to maintain frequently queried or recently queried SQL IDs in CacheA and CacheB. For example, the SQL ID storage capacity of CacheA and CacheB can be set to 10Mb each, with these 10Mb used to store the most recent, frequently queried SQL IDs.

[0097] In an embodiment of the present application, the number of accesses to the ElsaticSearch database is reduced through cache tiering, thereby improving the response speed to query requests, while also increasing the amount of data stored and processed and the number of query requests that can be processed simultaneously.

[0098] The present application provides a data query method that first determines a first query identifier corresponding to a query condition in a query request sent by a terminal device. If the first query identifier exists in a first cache area corresponding to a first database, query result data corresponding to the first query identifier is determined from the first database. The first cache area is used to cache historical query identifiers, and the first database contains historical query result data corresponding to the historical query identifiers. In this way, the first query identifier corresponding to the query request can be matched with the historical query identifiers, and the query result data can be obtained based on the matched historical query identifiers, thereby reducing the number of visits to the second database and improving the response speed of the entire query process.

[0099] Based on the above embodiment, the following describes how to determine the query result data corresponding to the first query identifier when the first query identifier corresponding to the query request exists in the first cache area. Figure 4 A flow chart of another data query method provided in an embodiment of the present application is shown as follows: Figure 4 As shown, the method includes:

[0100] S401: The server determines a first query identifier corresponding to a query request sent by a terminal device.

[0101] S402: The server determines that a first query identifier corresponding to the query request exists in a first cache area corresponding to the first database.

[0102] S403: The server determines the primary key data corresponding to the first query identifier according to the mapping relationship between the historical query identifier and the primary key data.

[0103] S404: The server determines, based on the primary key data, query result data corresponding to the first query identifier from the historical query result data of the first database.

[0104] S405: The server sends the first query identifier and query result data corresponding to the first query identifier to the terminal device.

[0105] The technical terms, technical effects, technical features, and optional implementation methods of S401-S405 can be referred to Figure 2 The S201-S202 shown are understood, and the repeated content will not be repeated here.

[0106] Based on the above embodiment, the following describes how to determine the query result data corresponding to the first query identifier when the first query identifier corresponding to the query request does not exist in the first cache area. Figure 5 A flow chart of another data query method provided in an embodiment of the present application is shown as follows: Figure 5 As shown, the method includes:

[0107] S501: The server determines a first query identifier corresponding to a query request sent by a terminal device.

[0108] S502: The server determines that a first query identifier corresponding to the query request does not exist in a first cache area corresponding to the first database.

[0109] S503: The server sends a prompt message to the terminal device.

[0110] S504: The server determines whether the first query identifier corresponding to the query request exists in the second cache area corresponding to the second database.

[0111] If yes, execute step S505; if no, execute steps S506-S511.

[0112] S505: The server terminates the query process corresponding to the query request.

[0113] S506: The server caches the first query identifier corresponding to the query request in the second cache area.

[0114] S507: The server determines index data corresponding to the first query identifier from the second database.

[0115] S508: The server determines query result data corresponding to the first query identifier from the data to be queried in the first database according to the index data.

[0116] S509: The server stores the query result data corresponding to the first query identifier in the historical query result data of the first database.

[0117] S510: The server stores a first query identifier corresponding to the query request in the historical query identifiers of the first cache area.

[0118] S511: The server removes the first query identifier corresponding to the query request from the second cache area.

[0119] It should be noted that the embodiment of the present application does not limit the execution order of S503 and S504, and these two steps can be executed simultaneously; there is no limit on the execution order of S506 and S507, and these two steps can be executed simultaneously; there is no limit on the execution order of S509, S510 and S511, and these three steps can also be executed simultaneously.

[0120] The technical terms, technical effects, technical features, and optional implementation methods of S501-S511 can be referred to Figure 2 The S201-S202 shown are understood, and the repeated content will not be repeated here.

[0121] This application provides a data query method that first determines a first query identifier corresponding to a query condition in a query request sent by a terminal device. If the first query identifier exists in a first cache area corresponding to a first database, query result data corresponding to the first query identifier is determined from the first database. The first cache area is used to cache historical query identifiers, and the first database contains historical query result data corresponding to the historical query identifiers. In this way, the first query identifier corresponding to the query request can be matched with the historical query identifier, and the query result data can be obtained based on the matched historical query identifier, thereby improving the response speed of the entire query process.

[0122] Those skilled in the art will appreciate that all or part of the steps in the above-described method embodiments can be implemented by hardware associated with program instructions. The aforementioned program can be stored in a computer-readable storage medium. When executed, the program performs the steps of the above-described method embodiments. The aforementioned storage medium includes various media capable of storing program code, such as ROM, RAM, magnetic disks, or optical disks.

[0123] Figure 6 This is a schematic diagram of the structure of a data query device provided in an embodiment of the present application. The data query device can be implemented by software, hardware, or a combination of both, such as the server in the above embodiment, to execute the data query method in the above embodiment. Figure 6 As shown, the data query device 600 includes:

[0124] Determining module 601, configured to determine a first query identifier corresponding to a query condition in a query request sent by a terminal device;

[0125] Query module 602 is used to determine the query result data corresponding to the first query identifier from the first database if the first query identifier exists in the first cache area corresponding to the first database. The first cache area is used to cache historical query identifiers, and the first database contains historical query result data corresponding to the historical query identifier.

[0126] In an optional embodiment, the query module 602 is also used to determine the index data corresponding to the first query identifier from the second database if the first query identifier does not exist in the first cache area corresponding to the first database; and determine the query result data corresponding to the first query identifier from the first database based on the index data.

[0127] In an optional implementation, the first query identifier is determined according to a structured query language.

[0128] In an optional implementation, the query module 602 is specifically used to determine the primary key data corresponding to the first query identifier based on the mapping relationship between the historical query identifier and the primary key data; and based on the primary key data, determine the query result data corresponding to the first query identifier from the historical query result data of the first database.

[0129] In an optional embodiment, the query module 602 is specifically used to determine whether the first query identifier exists in the second cache area corresponding to the second database if the first query identifier does not exist in the first cache area corresponding to the first database; if not, determine the index data corresponding to the first query identifier from the second database; and cache the first query identifier to the second cache area.

[0130] In an optional implementation, the query module 602 is further configured to remove the first query identifier from the second cache area.

[0131] In an optional implementation manner, the query module 602 is further configured to stop determining the index data corresponding to the first query identifier from the second database if yes.

[0132] In an optional implementation, the first database also includes data to be queried obtained from a data source device.

[0133] In an optional implementation, the query module 602 is further configured to determine query result data corresponding to the first query identifier from the data to be queried in the first database according to the index data.

[0134] In an optional implementation, the query module 602 is further configured to store the query result data in the historical query result data of the first database; and store the first query identifier in the first cache area.

[0135] In an optional embodiment, the query module 602 is also used to send a prompt message to the terminal device if the first query identifier does not exist in the first cache area corresponding to the first database. The prompt message includes the first query identifier and is used to instruct the terminal device to submit the query request again.

[0136] In an optional implementation, the query module 602 is further configured to send the first query identifier and query result data corresponding to the first query identifier to the terminal device.

[0137] Need to explain, Figure 6 The data query device provided in the illustrated embodiment can be used to execute the data query method provided in any of the above embodiments. The specific implementation methods and technical effects are similar and will not be described in detail here.

[0138] Figure 7This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Figure 7 As shown, the electronic device 700 may include: at least one processor 701 and a memory 702 . Figure 7 An electronic device is shown using a processor as an example.

[0139] The memory 702 is used to store programs. Specifically, the programs may include program codes, and the program codes include computer operation instructions.

[0140] The memory 702 may include a high-speed RAM memory, and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory.

[0141] The processor 701 is configured to execute computer-executable instructions stored in the memory 702 to implement the above-mentioned data query method;

[0142] The processor 701 may be a central processing unit (CPU), an application specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of the present application.

[0143] Alternatively, in a specific implementation, if the communication interface, memory 702, and processor 701 are implemented independently, the communication interface, memory 702, and processor 701 may be interconnected via a bus and communicate with each other. The bus may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus. Buses can be classified as address buses, data buses, control buses, etc., but this does not mean that there is only one bus or only one type of bus.

[0144] Optionally, in a specific implementation, if the communication interface, memory 702 and processor 701 are integrated on a chip, the communication interface, memory 702 and processor 701 can complete communication through an internal interface.

[0145] The present application also provides a chip comprising a processor and an interface. The interface is used to input and output data or instructions processed by the processor. The processor is used to execute the method provided in the above method embodiment. The chip can be used in a data query device.

[0146] An embodiment of the present application also provides a program, which, when executed by a processor, is used to execute the data query method provided in the above method embodiment.

[0147] An embodiment of the present application also provides a program product, such as a computer-readable storage medium, which stores instructions. When the program product is run on a computer, it enables the computer to execute the data query method provided by the above method embodiment.

[0148] The present application also provides a computer-readable storage medium, which may include various media capable of storing program code, such as a USB flash drive, a mobile hard drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk. Specifically, the computer-readable storage medium stores program information, which is used in the above-mentioned data query method.

[0149] In the above embodiments, all or part of the embodiments can be implemented by software, hardware, firmware, or any combination thereof. When implemented using software, all or part of the embodiments can be implemented in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions according to the embodiments of the present invention are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via a wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) method. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive (SSD)).

[0150] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the above embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the above embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.

Claims

1. A data query method, characterized in that: The method comprises: Determining a first query identifier corresponding to a query condition in a query request sent by a terminal device; If the first query identifier exists in a first cache area corresponding to a first database, determining query result data corresponding to the first query identifier from the first database, the first cache area being used to cache historical query identifiers, the historical query identifiers including the first query identifiers for which corresponding query result data has been obtained, and the first database containing historical query result data corresponding to the historical query identifiers; If the first query identifier does not exist in the first cache area corresponding to the first database, determining the index data corresponding to the first query identifier from the second database; and determining the query result data corresponding to the first query identifier from the first database based on the index data; The method further includes: if the first query identifier does not exist in the first cache area corresponding to the first database, sending a prompt message to the terminal device, the prompt message including the first query identifier, the prompt message being used to instruct the terminal device to submit the query request again; If the first query identifier does not exist in the first cache area corresponding to the first database, determining index data corresponding to the first query identifier from the second database includes: If the first query identifier does not exist in the first cache area corresponding to the first database, determining whether the first query identifier exists in the second cache area corresponding to the second database; The second cache area is used to cache the first query identifier that does not exist in the first cache area and is in the query process; If not, determine the index data corresponding to the first query identifier from the second database; cache the first query identifier to the second cache area; if so, stop determining the index data corresponding to the first query identifier from the second database.

2. The method according to claim 1, characterized in that The first query identifier is determined according to structured query language.

3. The method according to claim 1, characterized in that The determining, from the first database, query result data corresponding to the first query identifier includes: Determining the primary key data corresponding to the first query identifier based on the mapping relationship between the historical query identifier and the primary key data; According to the primary key data, query result data corresponding to the first query identifier is determined from the historical query result data of the first database.

4. The method according to claim 1, wherein After determining the query result data corresponding to the first query identifier from the first database, the method further includes: Remove the first query identifier from the second cache area.

5. The method according to claim 1, wherein The first database also includes data to be queried obtained from a data source device.

6. The method according to claim 5, characterized in that After determining the index data corresponding to the first query identifier from the second database, the method further includes: According to the index data, query result data corresponding to the first query identifier is determined from the data to be queried in the first database.

7. The method according to any one of claims 1 to 6, characterized in that After determining the query result data corresponding to the first query identifier from the data to be queried in the first database, the method further includes: Storing the query result data in the historical query result data of the first database; The first query identifier is stored in the first cache area.

8. The method according to any one of claims 1 to 6, characterized in that After determining the query result data corresponding to the first query identifier from the historical query result data of the first database, the method further includes: The first query identifier and query result data corresponding to the first query identifier are sent to the terminal device.

9. A data query device, characterized in that: The device comprises: A determination module, configured to determine a first query identifier corresponding to a query condition in a query request sent by a terminal device; a query module configured to determine, from a first database, query result data corresponding to the first query identifier if the first query identifier exists in a first cache area corresponding to a first database, the first cache area being configured to cache historical query identifiers, the historical query identifiers including first query identifiers for which corresponding query result data has been obtained, the first database containing historical query result data corresponding to the historical query identifiers; The query module is further configured to determine, from a second database, index data corresponding to the first query identifier if the first cache area corresponding to the first database does not contain the first query identifier; and determine, from the first database, query result data corresponding to the first query identifier based on the index data; The query module is further configured to send a prompt message to the terminal device if the first query identifier does not exist in the first cache area corresponding to the first database, the prompt message including the first query identifier, and the prompt message being used to instruct the terminal device to submit the query request again; The query module is specifically configured to determine whether the first query identifier exists in a second cache area corresponding to the second database if the first query identifier does not exist in a first cache area corresponding to the first database; wherein the second cache area is configured to cache first query identifiers that do not exist in the first cache area and are in the process of being queried; If not, determine the index data corresponding to the first query identifier from the second database; cache the first query identifier to the second cache area; if so, stop determining the index data corresponding to the first query identifier from the second database.

10. A computer storage medium, characterized in that The computer-readable storage medium stores computer-executable instructions, which are used to implement the method according to any one of claims 1 to 8 when executed by a processor.

11. An electronic device, characterized in that: include: A processor and a memory; wherein the memory stores a computer program, and the computer program is suitable for being loaded by the processor and executing the method according to any one of claims 1 to 8.

12. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the method according to any one of claims 1 to 8 is implemented.

Citation Information

Patent Citations

  • Metadata query method and device

    CN110018983A