WO2015074466A1 - Data search method and apparatus - Google Patents

Data search method and apparatus Download PDF

Info

Publication number
WO2015074466A1
WO2015074466A1 PCT/CN2014/088343 CN2014088343W WO2015074466A1 WO 2015074466 A1 WO2015074466 A1 WO 2015074466A1 CN 2014088343 W CN2014088343 W CN 2014088343W WO 2015074466 A1 WO2015074466 A1 WO 2015074466A1
Authority
WO
WIPO (PCT)
Prior art keywords
query
data
request
historical
query request
Prior art date
Application number
PCT/CN2014/088343
Other languages
French (fr)
Chinese (zh)
Inventor
张桂刚
李超
邢春晓
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Publication of WO2015074466A1 publication Critical patent/WO2015074466A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/33Querying
    • G06F16/3331Query processing
    • G06F16/3349Reuse of stored results of previous queries

Definitions

  • the present invention relates to the field of data processing technologies, and in particular, to a data query method and apparatus.
  • the data storage method is characterized by the fact that most of the data is saved in an additional way.
  • the data is updated and deleted less frequently.
  • the deletion is usually a new record with a delete tag, and each record is There is a record time, the timestamp.
  • a data query method and device are provided, which can ensure data query efficiency without maintaining a materialized view.
  • the first aspect provides a data query method, which pre-stores a plurality of historical query requests and their timestamps, and a historical query result corresponding to the historical query request, the query method includes:
  • the decomposing the data query request into the at least one subquery request according to the matching result includes:
  • the data query request When the data query request completely matches the first historical query request in the historical query request, the data query request is decomposed into a historical data sub-query request and an incremental data sub-query request;
  • the performing data query according to the subquery request includes:
  • the method further includes:
  • the decomposing the data query request according to the matching result Request for at least one subquery including:
  • the data query request When the data query request does not completely match the plurality of historical query requests, the data query request is decomposed into a new sub-query request;
  • the performing data query according to the subquery request includes:
  • the data requested by the data query request is queried in all the original data according to the brand new subquery request.
  • the method further includes:
  • the decomposing the data query request into the at least one subquery request according to the matching result includes:
  • the data query request When the data query request partially matches the first historical query request of the plurality of historical query requests, the data query request is decomposed into a historical data subquery request, an incremental data subquery request, and a brand new subquery request. ;
  • the performing data query according to the subquery request includes:
  • the method further includes:
  • a data query apparatus including:
  • a storage unit configured to store a plurality of historical query requests and their timestamps, and a historical query result corresponding to the historical query request;
  • a receiving unit configured to receive a data query request
  • a matching unit configured to match the data query request with multiple historical query requests stored in the storage unit
  • a decomposition unit configured to divide the data query request into at least one sub-query request according to the matching result
  • a query unit configured to perform data query according to the subquery request
  • a result output unit configured to merge the query result of the at least one subquery request, and use the merged query result as a result of the data query request.
  • the decomposing unit is specifically configured to: when the data query request completely matches the first historical query request in the historical query request, The data query request is decomposed into a historical data subquery request and an incremental data subquery request;
  • the query unit includes:
  • a historical query unit configured to query, in the historical query result, a first historical query result corresponding to the first historical query request according to the historical data sub-query request;
  • an incremental query unit configured to query, according to the incremental data subquery request, the data of the requested query of the data query request in the original data after the timestamp of the first historical query request.
  • the method further includes:
  • An update unit configured to update the first historical query result to the merged query As a result, the timestamp of the first historical query request is updated to the latest recording time of the data queried according to the incremental data subquery request.
  • the decomposing unit is specifically configured to use the data When the query request does not completely match the plurality of historical query requests, the data query request is decomposed into a new sub-query request;
  • the query unit includes a new query unit, and the new query unit is configured to query the data requested by the data query request in all the original data according to the brand new sub-query request.
  • An update unit configured to add the data query request to the plurality of historical query requests as a second historical query request, and use the latest record time of the data according to the new sub-query as the second historical query request Time stamp, and the merged query result is used as a historical query result corresponding to the second historical query request.
  • the decomposing unit is specifically configured to: when the data query request partially matches a first historical query request of the plurality of historical query requests, decompose the data query request Subquery request for historical data, incremental data subquery request, and new subquery request;
  • the query unit includes:
  • a historical query unit configured to query, in the historical query result, a first historical query result corresponding to the first historical query request according to the historical data sub-query request;
  • An incremental query unit configured to query, according to the incremental data subquery request, data of the requested query of the first historical query request in the original data after the timestamp of the first historical query request ;
  • the new query unit is configured to query, in the original data, the data of the requested query in the data query request that is not matched with the first historical query request according to the new subquery request.
  • the method further includes:
  • an updating unit configured to update the first historical query result to a combined result according to the result of the historical data subquery request and the incremental data subquery request, and the first historical query request Updating the timestamp to the latest recording time of the queried data according to the incremental data subquery request; adding the data query request as a second historical query request to the plurality of historical query requests, according to each of the sub-questions Querying the latest record time of the data requested by the query as the time stamp of the second historical query request, and using the merged query result as a historical query result corresponding to the second historical query request; The query request is added to the plurality of historical query requests as a third history query request, and the latest record time of the query data according to the brand new subquery request is used as a time stamp of the third history query request, and the The query result of the new subquery request is the result of the historical query corresponding to the third historical query request.
  • the embodiment of the present invention can store the historical query result and the historical query result in advance, and can reuse the historical query result when receiving the data query request, and obtain the final data query result by combining the historical query result and the incremental query result, and the method does not need to be established. And maintain the materialized view, and do not need to repeat the query for the historical result data and the query, which can greatly reduce the amount of data scanned and calculated, improve the query efficiency, improve the query performance, and reduce the query cost.
  • FIG. 1 is a flowchart of a data query method according to an embodiment of the present invention.
  • FIG. 2 is a flowchart of another data query method according to an embodiment of the present invention.
  • FIG. 3 is a schematic diagram of a data query framework according to an embodiment of the present invention.
  • FIG. 5 is a flowchart of another data query method according to an embodiment of the present invention.
  • FIG. 6 is a schematic diagram of waiting for execution when multiple identical data query requests exist simultaneously in an embodiment of the present invention.
  • FIG. 7 is a schematic structural diagram of a data query apparatus according to an embodiment of the present invention.
  • FIG. 8 is a schematic structural diagram of another data query apparatus according to an embodiment of the present invention.
  • FIG. 1 is a flowchart of a data query method according to an embodiment of the present invention.
  • two databases may be pre-established for storing a historical query request (and its timestamp) and a historical query result corresponding to the historical query request.
  • the two databases are empty, and the user is in the initial stage.
  • the data query request is added as a historical query request to the database for storing the historical query request, and the query result corresponding to the data query request is stored as a historical query result in a database for storing the historical query result.
  • the query may be performed according to the method of the embodiment of the present invention.
  • Each historical query request records a timestamp, which indicates both the time of receiving the historical query request and the time when the original data from the historical query result corresponding to the historical query request is recorded before the timestamp.
  • the data query method can include:
  • Step 101 Receive a data query request.
  • Step 102 Match the data query request with the plurality of historical query requests.
  • the historical query request stored in the database is searched and matched with the received data query request one by one.
  • the result of the matching may be a historical query request or a plurality of historical query requests in the database that exactly match the received data query request.
  • the received data query request is query data A+B, and the database exists. Query the historical query request of the data A+B, or the historical query request of the query data A and the historical query request of the query data B, which is also an exact match; or the historical query request stored in the database and the received data The query request does not match at all.
  • the received data query request is the query data A+B
  • the database does not have any historical query request containing the query data A, and there is no historical query request containing the query data B; there may be a presence and receipt in the database.
  • the data query request partially matches the historical query request.
  • the received data query request is the query data A+B, and the historical query request of the query data A exists in the database, but there is no historical query request of the query data B.
  • the above matching process may adopt keyword matching or other matching methods, which is not limited herein.
  • Step 103 Divide the data query request into at least one sub-query request according to the matching result.
  • the data query request is decomposed according to the matching result in this step.
  • the data query request is divided into subquery requests for the same data in the specified data storage area; if the matching result is not completely matched, the data query request is split into multiple A subquery request for different data in multiple specified data storage areas.
  • the matching result is an exact match or a complete mismatch
  • the data query request is split into multiple A subquery request for different data in multiple specified data storage areas.
  • Step 104 Perform a data query according to the subquery request.
  • Step 105 Combine the query result of the at least one subquery request, and use the merged query result as a result of the data query request.
  • the results of each query are combined, and the combined result is the result of the data query request.
  • the embodiment of the present invention can store the historical query result and the historical query result in advance, and can reuse the historical query result when receiving the data query request, and obtain the final data query result by combining the historical query result and the incremental query result, and the method does not need to be established. And maintain the materialized view, and do not need to repeat the query for the historical result data and the query, which can greatly reduce the amount of data scanned and calculated, improve the query efficiency, improve the query performance, and reduce the query cost.
  • FIG. 2 is a flowchart of another data query method according to an embodiment of the present invention.
  • FIG. 3 is a schematic diagram of a data query framework according to an embodiment of the present invention, wherein three databases, a historical query request database, and a cloud database 1 and a cloud database 2 are pre-established, and the historical query request database includes all historical query request data and Timestamp, the cloud database 1 stores all the original data and its timestamp, and the cloud database 2 stores the historical query.
  • the historical query request in the request database has a one-to-one correspondence with the historical query result.
  • the query method can include:
  • Step 201 Receive a data query request.
  • Step 202 Match the data query request with multiple historical query requests.
  • the matching result is that the historical query request database has a first historical query request that completely matches the data query request.
  • the historical query request of the query data A+B exists in the database.
  • step 203 After determining the matching result, step 203 is performed.
  • step 203 the data query request is decomposed into a historical data subquery request and an incremental data subquery request.
  • the data query request can be decomposed into a historical data sub-query request for querying the historical query result in the cloud database 2, and an incremental data sub-query request queried in the newly added original data of the cloud database 1.
  • the process proceeds to steps 204-205, and the data query is performed according to the sub-query request.
  • Step 204 Query the first historical query result corresponding to the first historical query request in the historical query result according to the historical data sub-query request.
  • the first historical query result corresponding to the first historical query request is directly found according to the historical data sub-query request, and is recorded as R1.
  • Step 205 Query, according to the incremental data sub-query request, the data requested by the data query request in the original data after the timestamp is located in the timestamp of the first historical query request.
  • the newly added original data in the cloud database 1 to be queried is a timestamp.
  • the original data after T1 according to the incremental data subquery request, find the data A+B in the newly added original data, obtain the result R4, and record the current The latest record timestamp T1' of the original data in the cloud database 1 being queried.
  • Step 206 Combine the query result of the historical data subquery request and the incremental data subquery request, and use the merged query result as a result of the data query request.
  • the results R1 and R4 are combined as a result of the data query request.
  • Step 207 Update the first historical query result to the merged query result, and update the timestamp of the first historical query request to the latest record of the data queried according to the incremental data subquery request. time
  • the merged results R1 and R4 are updated to the new first historical query result corresponding to the first historical query request, and the first historical query request is obtained.
  • the timestamp is updated to T1'.
  • the matching result is the presence and the data query request.
  • a fully matched historical query request is a collection of multiple historical query requests, such as a historical query request for query data A and a historical query request for query data B.
  • the data query request is decomposed into a historical data subquery request and an incremental data subquery request. Then, an operation similar to steps 204-205 is performed for each historical query request in the set: if the fully matched historical query request is a historical query request of the query data A and a set of historical query requests of the query data B, then The historical data subquery request finds the historical query result corresponding to the historical query request of the query data A and the historical query result corresponding to the historical query request of the query data B in the historical query result, respectively, and records them as R2 and R3, respectively.
  • the timestamp of the historical query request of the data A is T2
  • the timestamp of the historical query request of the data B is T3
  • the data A is searched in the original data after the time T2 is recorded in the cloud database 1 according to the incremental data subquery request.
  • the result R5 is obtained, and the latest time stamp T2' of the found original data is recorded, the data B is searched for in the original data after the recording time T3, the result R6 is obtained, and the latest time stamp T3' of the found original data is recorded.
  • step 206 Operations similar to step 206 are then performed for the results of all queries, combining the results R2, R3 and R5, R6 as a result of the data query request.
  • the data may be first queried.
  • the request is added as a new history query request in the database of the historical query request, and the latest time in T2' and T3' is recorded as a timestamp, and the historical query result corresponding to the newly added historical query request is R2, R3.
  • the result of the combination of R5 and R6 is added to the cloud database 2, and then the historical query result corresponding to the historical query request of the query data A is updated to R2+R5, the update timestamp is T2', and the historical query request of the query data B is corresponding.
  • the historical query result is updated to R3+R6 and the update timestamp is T3'.
  • the result of the matching is that there is a historical query request that exactly matches the data query request.
  • the matching historical query request includes the received data query request, such as the query data A or B when the found complete matching historical query request is found.
  • the data query request is decomposed into a historical data subquery request and an incremental data subquery request. Then, operations similar to steps 204-205 are performed:
  • the historical query result corresponding to the historical query request of the query data A or B is searched in the historical query result according to the historical data sub-query request, and then the query result corresponding to the query data A is filtered out from the historical query result, that is, Rx, And obtain the timestamp Tx of the historical query request A or B.
  • the data A is searched in the original data after the time Tx is recorded in the cloud database 1 according to the incremental data subquery request, the result Ry is obtained, and the latest time stamp Tx' of the found original data is recorded.
  • Step 206 Operations similar to step 206 are then performed for the results of all queries, combining the results Rx, Ry as a result of the data query request.
  • the data query request may be first added as a new history query request in the database of the historical query request, and the record timestamp is Tx', and the newly added history query request is added.
  • the result of the corresponding historical query that is, the combined result of Rx and Ry is added to the cloud database 2.
  • FIG. 4 is a flowchart of another data query method according to an embodiment of the present invention.
  • the data query framework shown in FIG. 3 is taken as an example, and the query method may include:
  • Step 401 Receive a data query request.
  • Step 402 Match the data query request with multiple historical query requests.
  • step 403 is performed.
  • step 403 the data query request is decomposed into a new subquery request.
  • step 404 is directly executed to query the data of the requested query in the cloud database 1.
  • Step 404 Query the data requested by the data query request in all the original data according to the new sub-query request.
  • step 405 the query result of the new subquery request is taken as the result of the data query request.
  • Step 406 Add the data query request to the plurality of historical query requests as a second historical query request, and use the latest record time of the query data according to the new subquery request as the second historical query request. a timestamp, and the merged query result is used as a historical query result corresponding to the second historical query request.
  • FIG. 5 is a flowchart of another data query method according to an embodiment of the present invention.
  • the data query framework shown in FIG. 3 is taken as an example, and the query method may include:
  • Step 501 Receive a data query request.
  • the query data A+B is still taken as an example for the received data query request.
  • Step 502 Match the data query request with multiple historical query requests.
  • the matching result is that the data query request partially matches the first historical query request in the historical query request database. For example, only the historical query request of the query data A exists in the historical query request database, and the query data A+ does not exist. B or data B history query request.
  • step 503 is performed.
  • Step 503 Decompose the data query request into a historical data sub-query request, an incremental data sub-query request, and a brand new sub-query request.
  • steps 504-506 are performed to perform the query.
  • Step 504 Query, according to the historical data sub-query request, the first historical query result corresponding to the first historical query request in the historical query result.
  • the first historical query result corresponding to the first historical query request that is partially matched with the data query request is queried in the cloud database 2.
  • the query process is the same as step 204 in the foregoing embodiment. like.
  • Step 505 Query, according to the incremental data sub-query request, the data requested by the first historical query request in the original data after the timestamp is located in the timestamp of the first historical query request.
  • the data A is queried according to the incremental data subquery request, and the query result is X2, and the original query of the cloud database 1 is recorded.
  • the latest record time of the data is t2.
  • Step 506 Query, according to the new sub-query request, data in the data query request that is requested by the first historical query request mismatch portion in all the original data.
  • the data B is directly searched for all the original data in the cloud database 1, and the query result is X3, and the latest recording time t3 of the original data in the current cloud database 1 is recorded.
  • Step 507 merge the historical data subquery request, the incremental data subquery request, and the query result of the brand new subquery request, and use the merged query result as a result of the data query request.
  • the query result of the data query request is the combined result of X1, X2 and X3.
  • Step 508 updating the historical query request database and the cloud database 1 and the cloud database 2.
  • the incremental data subquery requests the latest recording time of the queried data; specifically, the first historical query result corresponding to the first historical query request of the query data A is updated to X1+X2, and the time of the first historical query request is The stamp is updated to the latest time in t1, t2.
  • the query request is added to the historical query request database, the timestamp is the latest time in t1, t2, t3, and the historical query result X1+X2+X3 corresponding to the second historical query request is added to the cloud database 2.
  • data query when a plurality of identical data query requests exist at the same time, data query may be performed by using a method such as waiting for execution or concurrent execution.
  • the manner of waiting for execution is as shown in FIG. 6.
  • the corresponding branch in the historical query request database is in progress, and the corresponding branch is also querying whether the history query request database exists.
  • the query request of the data A if yes, waits for the execution of the corresponding branch to succeed, and if the corresponding branch is successfully executed, executes the next data query task; if the corresponding branch execution is unsuccessful or no corresponding branch is in progress, the task 1 is executed, and the task is executed.
  • the corresponding branch annotation of the task in the historical query request database is in progress.
  • the execution of the task 1 is successful, the historical query request database is updated, and the new historical query result is written into the cloud database 2, and then the next data query task is executed, if the task 1 is performed If the execution is unsuccessful, the annotations created on the corresponding branches in the historical query request database are cleared and then exited.
  • the task 1 performs the query on the data A
  • the existing historical query request and the historical query result in the cloud database 2 are directly applied, and the same task currently being performed is not detected, indicating that the task is in the task.
  • the corresponding historical query result in the cloud database 2 if not, the timestamp of the historical query request is updated to the timestamp of the current task 1, and the new historical query result is updated to the cloud database 2.
  • the cloud database 2 may be periodically cleaned according to the historical query request database, that is, the invalid historical query result in the cloud database 2 is deleted according to the historical query request, and the historical query request database may be periodically merged or deleted. And periodically merge or delete historical query results for cloud database 2.
  • the embodiment of the present invention decomposes the data query request into one or more of the new query, the historical query, and the incremental query according to the data query request matching the historical query request, and does not need to repeat the query request and the data that has been queried.
  • Query which can greatly reduce the amount of data scanned and calculated, improve query efficiency, and reduce query cost
  • the present invention uses historical query database and cloud database 2 to store historical query requests and corresponding historical query result metadata, each time After the query is completed, the database can be updated with individual data, which is much less expensive than the prior art materialized view maintenance method.
  • FIG. 7 is a schematic structural diagram of a data query apparatus according to an embodiment of the present invention.
  • the device can include:
  • the storage unit 701 is configured to store a plurality of historical query requests and their timestamps, and a historical query result corresponding to the historical query request;
  • the receiving unit 702 is configured to receive a data query request.
  • the matching unit 703 is configured to match the data query request with multiple historical query requests stored in the storage unit 701.
  • the decomposing unit 704 is configured to divide the data query request into at least one subquery request according to the matching result
  • the query unit 705 is configured to perform data query according to the subquery request
  • the result output unit 706 is configured to merge the query result of the at least one subquery request, and use the merged query result as a result of the data query request.
  • the receiving unit 702 matches the data query request with the plurality of historical query requests stored in the storage unit 701, and the decomposing unit 704 divides the data query request into at least one according to the matching result.
  • the subquery request may be one or more of a historical data subquery request, an incremental data subquery request, and a brand new subquery request, and then the query unit 705 performs data query according to the decomposed subquery request, and finally outputs the result.
  • Unit 706 merge query unit 705 according to respective subquery request
  • the result of the query is the result of the data query request.
  • the embodiment of the present invention pre-stores the historical query request and the historical query result by using the foregoing unit, and can reuse the historical query result when receiving the data query request, and obtain the final data query result by combining the historical query result and the incremental query result, the device There is no need to establish and maintain a materialized view, and there is no need to repeat the query for historical result data and queries. This can greatly reduce the amount of data scanned and calculated, improve query efficiency, improve query performance, and reduce query costs.
  • FIG. 8 is a schematic structural diagram of another data query apparatus according to an embodiment of the present invention.
  • the device may include an update unit 807 in addition to the storage unit 801, the receiving unit 802, the matching unit 803, the decomposition unit 804, the query unit 805, and the result output unit 806.
  • the storage unit 801 stores three databases, including a historical query request database, a cloud database 1 and a cloud database 2.
  • the historical query request database includes a plurality of historical query requests and their timestamps
  • the cloud database 1 includes all the original data and The time stamp
  • the cloud database 2 includes a historical query result corresponding to the historical query request.
  • the decomposing unit 804 may be specifically configured to: when the data query request completely matches the first historical query request in the historical query request, decompose the data query request into a historical data subquery request and An incremental data subquery request; when the data query request does not completely match the plurality of historical query requests, decomposing the data query request into a new subquery request; and when the data query request is related to the plurality of When the first historical query request in the historical query request partially matches, the data query request is decomposed into a historical data sub-query request, an incremental data sub-query request, and a brand new sub-query request.
  • the query unit 805 can include:
  • the history query unit 8051 is configured to query, according to the historical data sub-query request, the first historical query result corresponding to the first historical query request in the historical query result;
  • the incremental query unit 8052 is configured to query, according to the incremental data sub-query request, the data requested by the data query request in the original data after the timestamp is located in the timestamp of the first historical query request;
  • a new query unit 8053 configured to query, in the original data, the data query request and the data requested by the unmatched portion of the plurality of historical query requests in all the original data according to the new subquery request, that is, when Data query request and the multiple historical queries please When the complete mismatch is found, the data requested by the data query request is queried in all the original data according to the new subquery request, when the data query request and the first of the plurality of historical query requests are When the historical query request is partially matched, the data requested by the part of the data query request that is not matched with the first historical query request is queried.
  • the result output unit 806 is configured to merge and output the query result of the history query unit 8051, the delta query unit 8052, and the new query unit 8053 according to the subquery request decomposed by the decomposition unit 804.
  • the updating unit 807 is configured to update the first historical query result to a result that is queried according to the historical data subquery request and the incremental data subquery request when the matching result is a perfect match or an incomplete match. Merging the result, and updating the timestamp of the first historical query request to the latest recording time of the data queried according to the incremental data subquery request; when the matching result is not completely matched or completely mismatched, The data query request is added to the plurality of historical query requests as a second historical query request, and the latest record time of the query data according to each of the sub-query requests is used as a time stamp of the second historical query request, and The merged query result is used as a historical query result corresponding to the second historical query request; when the matching result is not completely matched, the new subquery request is added as the third historical query request to the plurality of history In the query request, the latest record time of the query data according to the new subquery request is used as the third history query. Time stamp, and the new sub-query request as
  • the disclosed systems, devices, and methods may be implemented in other manners.
  • the device embodiment described above For example, the division of the unit is only a logical function division, and the actual implementation may have another division manner, for example, multiple units or components may be combined or may be integrated into another system, or some Features can be ignored or not executed.
  • the mutual coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection through some interface, device or unit, and may be in an electrical, mechanical or other form.
  • the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, may be located in one place, or may be distributed to multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of the embodiment.
  • each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
  • the functions may be stored in a computer readable storage medium if implemented in the form of a software functional unit and sold or used as a standalone product.
  • the technical solution of the present invention which is essential or contributes to the prior art, or a part of the technical solution, may be embodied in the form of a software product, which is stored in a storage medium, including
  • the instructions are used to cause a computer device (which may be a personal computer, server, or network device, etc.) or a processor to perform all or part of the steps of the methods described in various embodiments of the present invention.
  • the foregoing storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk, and the like. .

Abstract

Disclosed are a data search method and apparatus. In the data search method, multiple historical search request and timestamps thereof, as well as historical search results corresponding to the historical search requests one by one are prestored. The search method comprises: receiving a data search request; performing matching on the data search request and the multiple historical search requests; dividing the data search request into at least one sub-search request according to a matching result; performing a data search according to the sub-search request; and combining search results of the at least one sub-search request, and using the combined search results as results of the data search request. In the method, a materialized view does not need to be established and maintained, and repeated searches do not need to be performed for historical result data and data on which a search has been performed. In this way, data amounts of scanning and computation can be significantly reduced, thereby improving search efficiency, enhancing search performance, and reducing a search cost.

Description

一种数据查询方法及装置Data query method and device 技术领域Technical field
本发明涉及数据处理技术领域,特别是涉及一种数据查询方法及装置。The present invention relates to the field of data processing technologies, and in particular, to a data query method and apparatus.
背景技术Background technique
随着IT技术和互联网的快速发展,许多应用均伴随着大量数据的产生,如股票交易、电子商务、社交网络等。这些应用逐渐采用NoSQL来保存数据,该数据保存方法的特征是大多采用追加的方式保存数据,数据的更新和删除操作比较少,删除一般也是追加一条带删除标签的新记录,且每条记录都有一个记录时间,即时间戳。With the rapid development of IT technology and the Internet, many applications are accompanied by a large amount of data, such as stock trading, e-commerce, social networking and so on. These applications gradually use NoSQL to save data. The data storage method is characterized by the fact that most of the data is saved in an additional way. The data is updated and deleted less frequently. The deletion is usually a new record with a delete tag, and each record is There is a record time, the timestamp.
基于上述数据保存方法,现有技术中,在针对云环境下大数据进行数据查询时,为了提高查询效率,需要预先定义查询请求,并根据预先定义的查询请求及数据库中的原始数据计算建立物化视图,在接收到查询请求时,若该查询请求为预先定义的查询请求,则物化视图根据预先规则进行计算,直接输出查询结果,对于未预先定义的查询请求,再在原始数据上进行完全扫描,然后输出查询结果。然而,该方法中若要保障查询效率就需要实时维护物化视图,例如,每当有新数据插入时,均需要重新计算更新物化视图,物化视图的维护过程较复杂,代价高。Based on the foregoing data saving method, in the prior art, in order to improve query efficiency when performing data query for big data in a cloud environment, it is necessary to define a query request in advance, and calculate and materialize according to a predefined query request and original data in the database. The view, when receiving the query request, if the query request is a predefined query request, the materialized view is calculated according to the pre-rule, and the query result is directly output, and for the undefined query request, the full scan is performed on the original data. And then output the query results. However, in this method, if the query efficiency is to be guaranteed, the materialized view needs to be maintained in real time. For example, whenever new data is inserted, the materialized view needs to be recalculated, and the maintenance process of the materialized view is complicated and costly.
发明内容Summary of the invention
本发明实施例中提供了一种数据查询方法及装置,能够保障数据查询效率的同时无需维护物化视图。In the embodiment of the present invention, a data query method and device are provided, which can ensure data query efficiency without maintaining a materialized view.
为了解决上述技术问题,本发明实施例公开了如下技术方案:In order to solve the above technical problem, the embodiment of the present invention discloses the following technical solutions:
第一方面,提供一种数据查询方法,预先存储多个历史查询请求及其时间戳,以及与所述历史查询请求一一对应的历史查询结果,所述查询方法包括:The first aspect provides a data query method, which pre-stores a plurality of historical query requests and their timestamps, and a historical query result corresponding to the historical query request, the query method includes:
接收数据查询请求; Receiving a data query request;
将所述数据查询请求与所述多个历史查询请求进行匹配;Matching the data query request with the plurality of historical query requests;
根据匹配结果将所述数据查询请求划分为至少一个子查询请求;Dividing the data query request into at least one sub-query request according to the matching result;
根据所述子查询请求进行数据查询;Performing a data query according to the subquery request;
合并所述至少一个子查询请求的查询结果,并将合并后的查询结果作为所述数据查询请求的结果。Merging the query result of the at least one subquery request and using the merged query result as a result of the data query request.
结合上述第一方面,在第一种可能的实现方式中,所述根据匹配结果将所述数据查询请求分解为至少一个子查询请求,包括:With reference to the foregoing first aspect, in a first possible implementation, the decomposing the data query request into the at least one subquery request according to the matching result includes:
当所述数据查询请求与所述历史查询请求中的第一历史查询请求完全匹配时,将所述数据查询请求分解为历史数据子查询请求和增量数据子查询请求;When the data query request completely matches the first historical query request in the historical query request, the data query request is decomposed into a historical data sub-query request and an incremental data sub-query request;
所述根据所述子查询请求进行数据查询,包括:The performing data query according to the subquery request includes:
根据所述历史数据子查询请求在所述历史查询结果中查询所述第一历史查询请求对应的第一历史查询结果;Querying, according to the historical data sub-query request, the first historical query result corresponding to the first historical query request in the historical query result;
根据所述增量数据子查询请求在时间戳位于所述第一历史查询请求的时间戳之后的原始数据中对所述数据查询请求所请求查询的数据进行查询。And querying, according to the incremental data sub-query request, data of the requested query of the data query request in the original data after the timestamp is located in the timestamp of the first historical query request.
结合上述第一方面,和/或第一种可能的实现方式,在第二种可能的实现方式中,还包括:In combination with the foregoing first aspect, and/or the first possible implementation manner, in a second possible implementation manner, the method further includes:
将所述第一历史查询结果更新为所述合并后的查询结果,并将所述第一历史查询请求的时间戳更新为根据所述增量数据子查询请求所查询数据的最新记录时间。Updating the first historical query result to the merged query result, and updating the timestamp of the first historical query request to the latest recording time of the queryed data according to the incremental data subquery request.
结合上述第一方面,和/或第一种可能的实现方式,和/或第二种可能的实现方式,在第三种可能的实现方式中,所述根据匹配结果将所述数据查询请求分解为至少一个子查询请求,包括:With reference to the foregoing first aspect, and/or the first possible implementation manner, and/or the second possible implementation manner, in a third possible implementation manner, the decomposing the data query request according to the matching result Request for at least one subquery, including:
当所述数据查询请求与所述多个历史查询请求完全不匹配时,将所述数据查询请求分解为全新子查询请求;When the data query request does not completely match the plurality of historical query requests, the data query request is decomposed into a new sub-query request;
所述根据所述子查询请求进行数据查询,包括:The performing data query according to the subquery request includes:
根据所述全新子查询请求在所有原始数据中对所述数据查询请求所请求查询的数据进行查询。The data requested by the data query request is queried in all the original data according to the brand new subquery request.
结合上述第一方面,和/或第一种可能的实现方式,和/或第二种可 能的实现方式,和/或第三种可能的实现方式,在第四种可能的实现方式中,还包括:In combination with the first aspect above, and/or the first possible implementation, and/or the second The implementation of the energy, and/or the third possible implementation manner, in the fourth possible implementation manner, the method further includes:
将所述数据查询请求作为第二历史查询请求增添至所述多个历史查询请求中,将根据所述全新子查询请求所查询数据的最新记录时间作为所述第二历史查询请求的时间戳,并将所述合并后的查询结果作为与所述第二历史查询请求对应的历史查询结果。Adding the data query request as the second historical query request to the plurality of historical query requests, and using the latest record time of the queryed data according to the brand new subquery request as the time stamp of the second historical query request. And the merged query result is used as a historical query result corresponding to the second historical query request.
结合上述第一方面,和/或第一种可能的实现方式,和/或第二种可能的实现方式,和/或第三种可能的实现方式,和/或第四种可能的实现方式,在第五种可能的实现方式中,所述根据匹配结果将所述数据查询请求分解为至少一个子查询请求,包括:In combination with the first aspect above, and/or the first possible implementation, and/or the second possible implementation, and/or the third possible implementation, and/or the fourth possible implementation, In a fifth possible implementation, the decomposing the data query request into the at least one subquery request according to the matching result includes:
当所述数据查询请求与所述多个历史查询请求中的第一历史查询请求部分匹配时,将所述数据查询请求分解为历史数据子查询请求、增量数据子查询请求和全新子查询请求;When the data query request partially matches the first historical query request of the plurality of historical query requests, the data query request is decomposed into a historical data subquery request, an incremental data subquery request, and a brand new subquery request. ;
所述根据所述子查询请求进行数据查询,包括:The performing data query according to the subquery request includes:
根据所述历史数据子查询请求在所述历史查询结果中查询所述第一历史查询请求对应的第一历史查询结果;Querying, according to the historical data sub-query request, the first historical query result corresponding to the first historical query request in the historical query result;
根据所述增量数据子查询请求在时间戳位于所述第一历史查询请求的时间戳之后的原始数据中对所述第一历史查询请求所请求查询的数据进行查询;And querying, according to the incremental data sub-query request, the data of the requested query by the first historical query request in the original data after the timestamp of the first historical query request;
根据所述全新子查询请求在所有原始数据中对所述数据查询请求中与所述第一历史查询请求不匹配部分所请求查询的数据进行查询。And querying data of the requested query in the data query request that is not matched with the first historical query request in all the original data according to the brand new subquery request.
结合上述第一方面,和/或第一种可能的实现方式,和/或第二种可能的实现方式,和/或第三种可能的实现方式,和/或第四种可能的实现方式,和/或第五种可能的实现方式,在第六种可能的实现方式中,还包括:In combination with the first aspect above, and/or the first possible implementation, and/or the second possible implementation, and/or the third possible implementation, and/or the fourth possible implementation, And/or the fifth possible implementation manner. In the sixth possible implementation manner, the method further includes:
将所述第一历史查询结果更新为根据所述历史数据子查询请求与所述增量数据子查询请求所查询的结果的合并结果,并将所述第一历史查询请求的时间戳更新为根据所述增量数据子查询请求所查询数据的最新记录的时间;Updating the first historical query result to a merge result according to the result of the historical data sub-query request and the incremental data sub-query request, and updating the timestamp of the first historical query request to The time at which the incremental data subquery requests the most recent record of the queried data;
将所述数据查询请求作为第二历史查询请求增添至所述多个历史查询请求中,将根据各所述子查询请求所查询数据的最新记录时间作为所 述第二历史查询请求的时间戳,并将所述合并后的查询结果作为与所述第二历史查询请求对应的历史查询结果;Adding the data query request as a second history query request to the plurality of historical query requests, and using the latest record time of the query data according to each of the subquery requests as a Determining a timestamp of the second historical query request, and using the merged query result as a historical query result corresponding to the second historical query request;
将所述全新子查询请求作为第三历史查询请求增添至所述多个历史查询请求中,将根据所述全新子查询请求所查询数据的最新记录时间作为所述第三历史查询请求的时间戳,并将所述全新子查询请求的查询结果作为与所述第三历史查询请求对应的历史查询结果。Adding the new subquery request as the third historical query request to the plurality of historical query requests, and using the latest record time of the queryed data according to the new subquery request as the time stamp of the third historical query request And the query result of the new subquery request is used as a historical query result corresponding to the third historical query request.
第二方面,提供一种数据查询装置,包括:In a second aspect, a data query apparatus is provided, including:
存储单元,用于存储多个历史查询请求及其时间戳,以及与所述历史查询请求一一对应的历史查询结果;a storage unit, configured to store a plurality of historical query requests and their timestamps, and a historical query result corresponding to the historical query request;
接收单元,用于接收数据查询请求;a receiving unit, configured to receive a data query request;
匹配单元,用于将所述数据查询请求与所述存储单元中存储的多个历史查询请求进行匹配;a matching unit, configured to match the data query request with multiple historical query requests stored in the storage unit;
分解单元,用于根据匹配结果将所述数据查询请求划分为至少一个子查询请求;a decomposition unit, configured to divide the data query request into at least one sub-query request according to the matching result;
查询单元,用于根据所述子查询请求进行数据查询;a query unit, configured to perform data query according to the subquery request;
结果输出单元,用于合并所述至少一个子查询请求的查询结果,并将合并后的查询结果作为所述数据查询请求的结果。a result output unit, configured to merge the query result of the at least one subquery request, and use the merged query result as a result of the data query request.
结合上述第二方面,在第一种可能的实现方式中,所述分解单元,具体用于当所述数据查询请求与所述历史查询请求中的第一历史查询请求完全匹配时,将所述数据查询请求分解为历史数据子查询请求和增量数据子查询请求;With reference to the foregoing second aspect, in a first possible implementation, the decomposing unit is specifically configured to: when the data query request completely matches the first historical query request in the historical query request, The data query request is decomposed into a historical data subquery request and an incremental data subquery request;
所述查询单元包括:The query unit includes:
历史查询单元,用于根据所述历史数据子查询请求在所述历史查询结果中查询所述第一历史查询请求对应的第一历史查询结果;a historical query unit, configured to query, in the historical query result, a first historical query result corresponding to the first historical query request according to the historical data sub-query request;
增量查询单元,用于根据所述增量数据子查询请求在时间戳位于所述第一历史查询请求的时间戳之后的原始数据中对所述数据查询请求所请求查询的数据进行查询。And an incremental query unit, configured to query, according to the incremental data subquery request, the data of the requested query of the data query request in the original data after the timestamp of the first historical query request.
结合上述第二方面,和/或第一种可能的实现方式,在第二种可能的实现方式中,还包括:With reference to the foregoing second aspect, and/or the first possible implementation manner, in a second possible implementation manner, the method further includes:
更新单元,用于将所述第一历史查询结果更新为所述合并后的查询 结果,并将所述第一历史查询请求的时间戳更新为根据所述增量数据子查询请求所查询数据的最新记录时间。An update unit, configured to update the first historical query result to the merged query As a result, the timestamp of the first historical query request is updated to the latest recording time of the data queried according to the incremental data subquery request.
结合上述第二方面,和/或第一种可能的实现方式,和/或第二种可能的实现方式,在第三种可能的实现方式中,所述分解单元,具体用于当所述数据查询请求与所述多个历史查询请求完全不匹配时,将所述数据查询请求分解为全新子查询请求;With reference to the foregoing second aspect, and/or the first possible implementation manner, and/or the second possible implementation manner, in a third possible implementation manner, the decomposing unit is specifically configured to use the data When the query request does not completely match the plurality of historical query requests, the data query request is decomposed into a new sub-query request;
所述查询单元包括全新查询单元,所述全新查询单元,用于根据所述全新子查询请求在所有原始数据中对所述数据查询请求所请求查询的数据进行查询。The query unit includes a new query unit, and the new query unit is configured to query the data requested by the data query request in all the original data according to the brand new sub-query request.
结合上述第二方面,和/或第一种可能的实现方式,和/或第二种可能的实现方式,和/或第三种可能的实现方式,在第四种可能的实现方式中,还包括:In combination with the second aspect above, and/or the first possible implementation manner, and/or the second possible implementation manner, and/or the third possible implementation manner, in the fourth possible implementation manner, include:
更新单元,用于将所述数据查询请求作为第二历史查询请求增添至所述多个历史查询请求中,将根据所述全新子查询所查询数据的最新记录时间作为所述第二历史查询请求的时间戳,并将所述合并后的查询结果作为与所述第二历史查询请求对应的历史查询结果。An update unit, configured to add the data query request to the plurality of historical query requests as a second historical query request, and use the latest record time of the data according to the new sub-query as the second historical query request Time stamp, and the merged query result is used as a historical query result corresponding to the second historical query request.
结合上述第二方面,和/或第一种可能的实现方式,和/或第二种可能的实现方式,和/或第三种可能的实现方式,和/或第四种可能的实现方式,在第五种可能的实现方式中,所述分解单元,具体用于当所述数据查询请求与所述多个历史查询请求中的第一历史查询请求部分匹配时,将所述数据查询请求分解为历史数据子查询请求、增量数据子查询请求和全新子查询请求;In combination with the second aspect above, and/or the first possible implementation, and/or the second possible implementation, and/or the third possible implementation, and/or the fourth possible implementation, In a fifth possible implementation, the decomposing unit is specifically configured to: when the data query request partially matches a first historical query request of the plurality of historical query requests, decompose the data query request Subquery request for historical data, incremental data subquery request, and new subquery request;
所述查询单元包括:The query unit includes:
历史查询单元,用于根据所述历史数据子查询请求在所述历史查询结果中查询所述第一历史查询请求对应的第一历史查询结果;a historical query unit, configured to query, in the historical query result, a first historical query result corresponding to the first historical query request according to the historical data sub-query request;
增量查询单元,用于根据所述增量数据子查询请求在时间戳位于所述第一历史查询请求的时间戳之后的原始数据中对所述第一历史查询请求所请求查询的数据进行查询;An incremental query unit, configured to query, according to the incremental data subquery request, data of the requested query of the first historical query request in the original data after the timestamp of the first historical query request ;
全新查询单元,用于根据所述全新子查询请求在所有原始数据中对所述数据查询请求中与所述第一历史查询请求不匹配部分所请求查询的数据进行查询。 The new query unit is configured to query, in the original data, the data of the requested query in the data query request that is not matched with the first historical query request according to the new subquery request.
结合上述第二方面,和/或第一种可能的实现方式,和/或第二种可能的实现方式,和/或第三种可能的实现方式,和/或第四种可能的实现方式,和/或第五种可能的实现方式,在第六种可能的实现方式中,还包括:In combination with the second aspect above, and/or the first possible implementation, and/or the second possible implementation, and/or the third possible implementation, and/or the fourth possible implementation, And/or the fifth possible implementation manner. In the sixth possible implementation manner, the method further includes:
更新单元,用于将所述第一历史查询结果更新为根据所述历史数据子查询请求与所述增量数据子查询请求所查询的结果的合并结果,并将所述第一历史查询请求的时间戳更新为根据所述增量数据子查询请求所查询数据的最新记录时间;将所述数据查询请求作为第二历史查询请求增添至所述多个历史查询请求中,将根据各所述子查询请求所查询数据的最新记录时间作为所述第二历史查询请求的时间戳,并将所述合并后的查询结果作为与所述第二历史查询请求对应的历史查询结果;将所述全新子查询请求作为第三历史查询请求增添至所述多个历史查询请求中,将根据所述全新子查询请求所查询数据的最新记录时间作为所述第三历史查询请求的时间戳,并将所述全新子查询请求的查询结果作为与所述第三历史查询请求对应的历史查询结果。And an updating unit, configured to update the first historical query result to a combined result according to the result of the historical data subquery request and the incremental data subquery request, and the first historical query request Updating the timestamp to the latest recording time of the queried data according to the incremental data subquery request; adding the data query request as a second historical query request to the plurality of historical query requests, according to each of the sub-questions Querying the latest record time of the data requested by the query as the time stamp of the second historical query request, and using the merged query result as a historical query result corresponding to the second historical query request; The query request is added to the plurality of historical query requests as a third history query request, and the latest record time of the query data according to the brand new subquery request is used as a time stamp of the third history query request, and the The query result of the new subquery request is the result of the historical query corresponding to the third historical query request.
本发明实施例通过预先存储历史查询请求及历史查询结果,在接收到数据查询请求时可以重用历史查询结果,通过合并历史查询结果和增量查询结果来获得最终的数据查询结果,该方法无需建立和维护物化视图,而且对历史结果数据以及查询过的不需要重复查询,这样可以大大减少扫描和计算的数据量,提高查询效率,改善查询性能,降低查询费用。The embodiment of the present invention can store the historical query result and the historical query result in advance, and can reuse the historical query result when receiving the data query request, and obtain the final data query result by combining the historical query result and the incremental query result, and the method does not need to be established. And maintain the materialized view, and do not need to repeat the query for the historical result data and the query, which can greatly reduce the amount of data scanned and calculated, improve the query efficiency, improve the query performance, and reduce the query cost.
附图说明DRAWINGS
为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,对于本领域普通技术人员而言,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the embodiments or the description of the prior art will be briefly described below, and it will be apparent to those skilled in the art that In other words, other drawings can be obtained based on these drawings without paying for creative labor.
图1为本发明实施例一种数据查询方法的流程图;1 is a flowchart of a data query method according to an embodiment of the present invention;
图2为本发明实施例另一种数据查询方法的流程图;2 is a flowchart of another data query method according to an embodiment of the present invention;
图3为本发明实施例中数据查询框架示意图;3 is a schematic diagram of a data query framework according to an embodiment of the present invention;
图4为本发明实施例另一种数据查询方法的流程图; 4 is a flowchart of another data query method according to an embodiment of the present invention;
图5为本发明实施例另一种数据查询方法的流程图;FIG. 5 is a flowchart of another data query method according to an embodiment of the present invention;
图6为本发明实施例中当同时存在多个相同的数据查询请求时,等待执行的示意图;6 is a schematic diagram of waiting for execution when multiple identical data query requests exist simultaneously in an embodiment of the present invention;
图7为本发明实施例一种数据查询装置的结构示意图;FIG. 7 is a schematic structural diagram of a data query apparatus according to an embodiment of the present invention;
图8为本发明实施例另一种数据查询装置的结构示意图。FIG. 8 is a schematic structural diagram of another data query apparatus according to an embodiment of the present invention.
具体实施方式detailed description
为了使本技术领域的人员更好地理解本发明实施例中的技术方案,并使本发明实施例的上述目的、特征和优点能够更加明显易懂,下面结合附图对本发明实施例中技术方案作进一步详细的说明。The above-mentioned objects, features, and advantages of the embodiments of the present invention will become more apparent and understood. Give further details.
参见图1,为本发明实施例一种数据查询方法的流程图。FIG. 1 is a flowchart of a data query method according to an embodiment of the present invention.
在本发明实施例中,可以预先建立两个数据库,分别用于存储历史查询请求(及其时间戳)和与历史查询请求对应的历史查询结果,在初始阶段,两数据库是空的,在用户进行数据查询后,将数据查询请求作为历史查询请求增加到用于存储历史查询请求的数据库中,将与数据查询请求对应的查询结果作为历史查询结果存储到用于存储历史查询结果的数据库中。后续再进行数据查询时,即可按照本发明实施例的方法进行查询。其中,每个历史查询请求都记录有时间戳,该时间戳既表明了接收该历史查询请求时间,也表明了与历史查询请求相对应的历史查询结果所来源的原始数据为该时间戳之前记录的原始数据。In the embodiment of the present invention, two databases may be pre-established for storing a historical query request (and its timestamp) and a historical query result corresponding to the historical query request. In the initial stage, the two databases are empty, and the user is in the initial stage. After the data query is performed, the data query request is added as a historical query request to the database for storing the historical query request, and the query result corresponding to the data query request is stored as a historical query result in a database for storing the historical query result. When the data query is performed later, the query may be performed according to the method of the embodiment of the present invention. Each historical query request records a timestamp, which indicates both the time of receiving the historical query request and the time when the original data from the historical query result corresponding to the historical query request is recorded before the timestamp. Raw data.
该数据查询方法可以包括:The data query method can include:
步骤101,接收数据查询请求。Step 101: Receive a data query request.
步骤102,将所述数据查询请求与所述多个历史查询请求进行匹配。Step 102: Match the data query request with the plurality of historical query requests.
在接收到数据查询请求后,查找数据库中存储的历史查询请求,并与接收到的数据查询请求进行逐一匹配。匹配的结果可能是数据库中存在与接收到的数据查询请求完全匹配的一个历史查询请求或多个历史查询请求的集合,例如,接收到的数据查询请求为查询数据A+B,数据库中正好存在查询数据A+B的历史查询请求,或者存在查询数据A的历史查询请求以及查询数据B的历史查询请求,这也属于完全匹配;也可能是数据库中存储的历史查询请求均与接收到的数据查询请求完全不匹配, 例如,接收到的数据查询请求为查询数据A+B,数据库中没有任何包含查询数据A的历史查询请求,也没有任何包含查询数据B的历史查询请求;还有可能是数据库中存在与接收到的数据查询请求部分匹配的历史查询请求,例如,接收到的数据查询请求为查询数据A+B,数据库中存在查询数据A的历史查询请求,但不存在查询数据B的历史查询请求。After receiving the data query request, the historical query request stored in the database is searched and matched with the received data query request one by one. The result of the matching may be a historical query request or a plurality of historical query requests in the database that exactly match the received data query request. For example, the received data query request is query data A+B, and the database exists. Query the historical query request of the data A+B, or the historical query request of the query data A and the historical query request of the query data B, which is also an exact match; or the historical query request stored in the database and the received data The query request does not match at all. For example, the received data query request is the query data A+B, the database does not have any historical query request containing the query data A, and there is no historical query request containing the query data B; there may be a presence and receipt in the database. The data query request partially matches the historical query request. For example, the received data query request is the query data A+B, and the historical query request of the query data A exists in the database, but there is no historical query request of the query data B.
其中,上述匹配过程可以采用关键词匹配或其他匹配方式,此处不做限定。The above matching process may adopt keyword matching or other matching methods, which is not limited herein.
步骤103,根据匹配结果将所述数据查询请求划分为至少一个子查询请求。Step 103: Divide the data query request into at least one sub-query request according to the matching result.
在获得上述完全匹配,或完全不匹配,或不完全匹配的匹配结果后,在本步骤即根据匹配结果对数据查询请求进行分解。After obtaining the above matching result, or not matching at all, or not matching the matching result, the data query request is decomposed according to the matching result in this step.
如果匹配结果为完全匹配或完全不匹配,则将该数据查询请求划分为在指定数据存储区域针对相同数据的子查询请求;如果匹配结果为不完全匹配,则将该数据查询请求拆分为多在多个指定数据存储区域针对不同数据的子查询请求。具体请参见后续实施例的描述。If the matching result is an exact match or a complete mismatch, the data query request is divided into subquery requests for the same data in the specified data storage area; if the matching result is not completely matched, the data query request is split into multiple A subquery request for different data in multiple specified data storage areas. For details, please refer to the description of the subsequent embodiments.
步骤104,根据所述子查询请求进行数据查询。Step 104: Perform a data query according to the subquery request.
步骤105,合并所述至少一个子查询请求的查询结果,并将合并后的查询结果作为所述数据查询请求的结果。Step 105: Combine the query result of the at least one subquery request, and use the merged query result as a result of the data query request.
在获得各子查询请求的查询结果后,合并各查询结果,合并后的结果即为数据查询请求的结果。After obtaining the query result of each subquery request, the results of each query are combined, and the combined result is the result of the data query request.
本发明实施例通过预先存储历史查询请求及历史查询结果,在接收到数据查询请求时可以重用历史查询结果,通过合并历史查询结果和增量查询结果来获得最终的数据查询结果,该方法无需建立和维护物化视图,而且对历史结果数据以及查询过的不需要重复查询,这样可以大大减少扫描和计算的数据量,提高查询效率,改善查询性能,降低查询费用。The embodiment of the present invention can store the historical query result and the historical query result in advance, and can reuse the historical query result when receiving the data query request, and obtain the final data query result by combining the historical query result and the incremental query result, and the method does not need to be established. And maintain the materialized view, and do not need to repeat the query for the historical result data and the query, which can greatly reduce the amount of data scanned and calculated, improve the query efficiency, improve the query performance, and reduce the query cost.
参见图2,为本发明实施例另一种数据查询方法的流程图。2 is a flowchart of another data query method according to an embodiment of the present invention.
如图3所示为本发明实施例的数据查询框架示意图,其中预先建立三个数据库,历史查询请求数据库以及云数据库1和云数据库2,历史查询请求数据库包含有所有的历史查询请求数据及其时间戳,云数据库1中存储有所有的原始数据及其时间戳,云数据库2中存储有与历史查询 请求数据库中的历史查询请求一一对应的历史查询结果。该查询方法可以包括:FIG. 3 is a schematic diagram of a data query framework according to an embodiment of the present invention, wherein three databases, a historical query request database, and a cloud database 1 and a cloud database 2 are pre-established, and the historical query request database includes all historical query request data and Timestamp, the cloud database 1 stores all the original data and its timestamp, and the cloud database 2 stores the historical query. The historical query request in the request database has a one-to-one correspondence with the historical query result. The query method can include:
步骤201,接收数据查询请求。Step 201: Receive a data query request.
假设接收到的数据查询请求为查询数据A+B。Assume that the received data query request is the query data A+B.
步骤202,将数据查询请求与多个历史查询请求进行匹配。Step 202: Match the data query request with multiple historical query requests.
将数据查询请求与历史查询请求数据库中的历史查询请求进行匹配。本实施例中,假设匹配结果为历史查询请求数据库中存在与数据查询请求完全匹配的第一历史查询请求,例如,数据库中正好存在查询数据A+B的历史查询请求。Match the data query request with the historical query request in the historical query request database. In this embodiment, it is assumed that the matching result is that the historical query request database has a first historical query request that completely matches the data query request. For example, the historical query request of the query data A+B exists in the database.
在确定匹配结果后,执行步骤203。After determining the matching result, step 203 is performed.
步骤203,将数据查询请求分解为历史数据子查询请求和增量数据子查询请求。In step 203, the data query request is decomposed into a historical data subquery request and an incremental data subquery request.
在确定完全匹配后,即可将数据查询请求分解为在云数据库2中查询历史查询结果的历史数据子查询请求,以及在云数据库1的新增原始数据中查询的增量数据子查询请求。After determining the exact match, the data query request can be decomposed into a historical data sub-query request for querying the historical query result in the cloud database 2, and an incremental data sub-query request queried in the newly added original data of the cloud database 1.
对查询请求分解后,转入步骤204~205,分别按照子查询请求进行数据查询。After the query request is decomposed, the process proceeds to steps 204-205, and the data query is performed according to the sub-query request.
步骤204,根据所述历史数据子查询请求在所述历史查询结果中查询所述第一历史查询请求对应的第一历史查询结果。Step 204: Query the first historical query result corresponding to the first historical query request in the historical query result according to the historical data sub-query request.
根据该历史数据子查询请求直接查找到该第一历史查询请求对应的第一历史查询结果,记为R1。The first historical query result corresponding to the first historical query request is directly found according to the historical data sub-query request, and is recorded as R1.
步骤205,根据所述增量数据子查询请求在时间戳位于所述第一历史查询请求的时间戳之后的原始数据中对所述数据查询请求所请求查询的数据进行查询。Step 205: Query, according to the incremental data sub-query request, the data requested by the data query request in the original data after the timestamp is located in the timestamp of the first historical query request.
在进行增量查询之前,首先要确定出需要查询的云数据库1中的新增的原始数据。Before performing an incremental query, first determine the new raw data in the cloud database 1 that needs to be queried.
如果上述第一历史查询请求为请求查询数据A+B,且根据历史查询请求数据库该第一历史查询请求的时间戳为T1,则需要查询的云数据库1中的新增的原始数据为时间戳在T1之后的原始数据,根据增量数据子查询请求在该新增的原始数据中查找数据A+B,得到结果R4,并记录当前 所查询的云数据库1中原始数据的最新记录时间戳T1′。If the first historical query request is the request query data A+B, and the timestamp of the first historical query request is T1 according to the historical query request, the newly added original data in the cloud database 1 to be queried is a timestamp. The original data after T1, according to the incremental data subquery request, find the data A+B in the newly added original data, obtain the result R4, and record the current The latest record timestamp T1' of the original data in the cloud database 1 being queried.
步骤206,合并历史数据子查询请求和增量数据子查询请求的查询结果,并将合并后的查询结果作为所述数据查询请求的结果。Step 206: Combine the query result of the historical data subquery request and the incremental data subquery request, and use the merged query result as a result of the data query request.
如果上述第一历史查询请求为请求查询数据A+B,则合并结果R1及R4,作为数据查询请求的结果。If the first historical query request is the request query data A+B, the results R1 and R4 are combined as a result of the data query request.
本实施例还可以进一步包括:This embodiment may further include:
步骤207,将所述第一历史查询结果更新为所述合并后的查询结果,并将所述第一历史查询请求的时间戳更新为根据所述增量数据子查询请求所查询数据的最新记录时间Step 207: Update the first historical query result to the merged query result, and update the timestamp of the first historical query request to the latest record of the data queried according to the incremental data subquery request. time
具体的,如果上述第一历史查询请求为请求查询数据A+B,则将合并结果R1及R4更新为该第一历史查询请求对应的新的第一历史查询结果,并将第一历史查询请求的时间戳更新为T1′。Specifically, if the first historical query request is the request query data A+B, the merged results R1 and R4 are updated to the new first historical query result corresponding to the first historical query request, and the first historical query request is obtained. The timestamp is updated to T1'.
在另一实施例中,仍以接收到的的数据查询请求为查询数据A+B为例,在将数据查询请求与多个历史查询请求进行匹配时,匹配的结果是存在与该数据查询请求完全匹配的历史查询请求,但是,该完全匹配的历史查询结果是多个历史查询请求的集合,例如存在查询数据A的历史查询请求以及查询数据B的历史查询请求。In another embodiment, taking the received data query request as the query data A+B as an example, when the data query request is matched with multiple historical query requests, the matching result is the presence and the data query request. A fully matched historical query request, however, the fully matched historical query result is a collection of multiple historical query requests, such as a historical query request for query data A and a historical query request for query data B.
则将数据查询请求分解为历史数据子查询请求和增量数据子查询请求。然后,针对集合中的每一个历史查询请求均执行与步骤204~205类似的操作:如果完全匹配的历史查询请求为查询数据A的历史查询请求以及查询数据B的历史查询请求的集合,则按照历史数据子查询请求在历史查询结果中分别查找查询数据A的历史查询请求对应的历史查询结果以及查询数据B的历史查询请求对应的历史查询结果,分别记为R2和R3。数据A的历史查询请求的时间戳为T2,数据B的历史查询请求的时间戳为T3,则根据增量数据子查询请求在云数据库1中记录时间为T2之后的原始数据中查找数据A,获得结果R5,并记录所查找原始数据的最新时间戳T2′,在记录时间为T3之后的原始数据中查找数据B,获得结果R6,并记录所查找原始数据的最新时间戳T3′。The data query request is decomposed into a historical data subquery request and an incremental data subquery request. Then, an operation similar to steps 204-205 is performed for each historical query request in the set: if the fully matched historical query request is a historical query request of the query data A and a set of historical query requests of the query data B, then The historical data subquery request finds the historical query result corresponding to the historical query request of the query data A and the historical query result corresponding to the historical query request of the query data B in the historical query result, respectively, and records them as R2 and R3, respectively. The timestamp of the historical query request of the data A is T2, and the timestamp of the historical query request of the data B is T3, and the data A is searched in the original data after the time T2 is recorded in the cloud database 1 according to the incremental data subquery request. The result R5 is obtained, and the latest time stamp T2' of the found original data is recorded, the data B is searched for in the original data after the recording time T3, the result R6 is obtained, and the latest time stamp T3' of the found original data is recorded.
然后针对所有查询的结果执行与步骤206类似的操作,合并结果R2,R3以及R5,R6,作为数据查询请求的结果。Operations similar to step 206 are then performed for the results of all queries, combining the results R2, R3 and R5, R6 as a result of the data query request.
然后执行与步骤207类似操作,具体的,可以首先将该数据查询请 求作为新增的历史查询请求增加在历史查询请求的数据库中,将T2′和T3′中最新的时间记录为时间戳,并将该新增的历史查询请求对应的历史查询结果即R2,R3以及R5,R6的合并结果增加至云数据库2中,然后将查询数据A的历史查询请求对应的历史查询结果更新为R2+R5,更新时间戳为T2′,将查询数据B的历史查询请求对应的历史查询结果更新为R3+R6,更新时间戳为T3′。Then perform a similar operation to step 207. Specifically, the data may be first queried. The request is added as a new history query request in the database of the historical query request, and the latest time in T2' and T3' is recorded as a timestamp, and the historical query result corresponding to the newly added historical query request is R2, R3. And the result of the combination of R5 and R6 is added to the cloud database 2, and then the historical query result corresponding to the historical query request of the query data A is updated to R2+R5, the update timestamp is T2', and the historical query request of the query data B is corresponding. The historical query result is updated to R3+R6 and the update timestamp is T3'.
在另一实施例中,假设接收到的数据查询请求为查询数据A,在将数据查询请求与多个历史查询请求进行匹配时,匹配的结果是存在与该数据查询请求完全匹配的历史查询请求,但是该匹配的历史查询请求包含该接收到的数据查询请求,例如查找到的完全匹配的历史查询请求时查询数据A or B。In another embodiment, assuming that the received data query request is the query data A, when the data query request is matched with the plurality of historical query requests, the result of the matching is that there is a historical query request that exactly matches the data query request. , but the matching historical query request includes the received data query request, such as the query data A or B when the found complete matching historical query request is found.
则将数据查询请求分解为历史数据子查询请求和增量数据子查询请求。然后,执行与步骤204~205类似的操作:The data query request is decomposed into a historical data subquery request and an incremental data subquery request. Then, operations similar to steps 204-205 are performed:
首先按照历史数据子查询请求在历史查询结果中查找查询数据A orB的历史查询请求对应的历史查询结果,然后针对该历史查询结果进行过滤从中筛选出查询数据A对应的查询结果,即为Rx,并获得该历史查询请求A or B的时间戳Tx。根据增量数据子查询请求在云数据库1中记录时间为Tx之后的原始数据中查找数据A,获得结果Ry,并记录所查找原始数据的最新时间戳Tx′。First, the historical query result corresponding to the historical query request of the query data A or B is searched in the historical query result according to the historical data sub-query request, and then the query result corresponding to the query data A is filtered out from the historical query result, that is, Rx, And obtain the timestamp Tx of the historical query request A or B. The data A is searched in the original data after the time Tx is recorded in the cloud database 1 according to the incremental data subquery request, the result Ry is obtained, and the latest time stamp Tx' of the found original data is recorded.
然后针对所有查询的结果执行与步骤206类似的操作,合并结果Rx、Ry作为数据查询请求的结果。Operations similar to step 206 are then performed for the results of all queries, combining the results Rx, Ry as a result of the data query request.
然后执行与步骤207类似操作,具体的,可以首先将该数据查询请求作为新增的历史查询请求增加在历史查询请求的数据库中,记录时间戳为Tx′,并将该新增的历史查询请求对应的历史查询结果即Rx、Ry的合并结果增加至云数据库2中。Then, the operation similar to step 207 is performed. Specifically, the data query request may be first added as a new history query request in the database of the historical query request, and the record timestamp is Tx', and the newly added history query request is added. The result of the corresponding historical query, that is, the combined result of Rx and Ry is added to the cloud database 2.
参见图4,为本发明实施例另一种数据查询方法的流程图。FIG. 4 is a flowchart of another data query method according to an embodiment of the present invention.
仍以图3所示的数据查询框架示意图为例,该查询方法可以包括:For example, the data query framework shown in FIG. 3 is taken as an example, and the query method may include:
步骤401,接收数据查询请求。Step 401: Receive a data query request.
步骤402,将数据查询请求与多个历史查询请求进行匹配。Step 402: Match the data query request with multiple historical query requests.
将数据查询请求与历史查询请求数据库中的历史查询请求进行匹配。本实施例中,假设匹配结果为历史查询请求数据库中不存在与数据 查询请求匹配的历史查询请求,则执行步骤403。Match the data query request with the historical query request in the historical query request database. In this embodiment, it is assumed that the matching result is that the historical query request database does not exist and the data If the query request matches the historical query request, step 403 is performed.
步骤403,将数据查询请求分解为全新子查询请求。In step 403, the data query request is decomposed into a new subquery request.
在确定完全不匹配后,即可确定无需在云数据库2中进行查询,直接执行步骤404在云数据库1中对所请求查询的数据进行查询。After the complete mismatch is determined, it can be determined that the query is not performed in the cloud database 2, and the step 404 is directly executed to query the data of the requested query in the cloud database 1.
步骤404,根据所述全新子查询请求在所有原始数据中对所述数据查询请求所请求查询的数据进行查询。Step 404: Query the data requested by the data query request in all the original data according to the new sub-query request.
步骤405,将全新子查询请求的查询结果作为数据查询请求的结果。In step 405, the query result of the new subquery request is taken as the result of the data query request.
该实施例还可以进一步包括:The embodiment may further include:
步骤406,将所述数据查询请求作为第二历史查询请求增添至所述多个历史查询请求中,将根据所述全新子查询请求所查询数据的最新记录时间作为所述第二历史查询请求的时间戳,并将所述合并后的查询结果作为与所述第二历史查询请求对应的历史查询结果。Step 406: Add the data query request to the plurality of historical query requests as a second historical query request, and use the latest record time of the query data according to the new subquery request as the second historical query request. a timestamp, and the merged query result is used as a historical query result corresponding to the second historical query request.
参见图5,为本发明实施例另一种数据查询方法的流程图。FIG. 5 is a flowchart of another data query method according to an embodiment of the present invention.
仍以图3所示的数据查询框架示意图为例,该查询方法可以包括:For example, the data query framework shown in FIG. 3 is taken as an example, and the query method may include:
步骤501,接收数据查询请求。Step 501: Receive a data query request.
仍以接收到的数据查询请求为查询数据A+B为例进行说明。The query data A+B is still taken as an example for the received data query request.
步骤502,将数据查询请求与多个历史查询请求进行匹配。Step 502: Match the data query request with multiple historical query requests.
将数据查询请求与历史查询请求数据库中的历史查询请求进行匹配。本实施例中,假设匹配结果为数据查询请求与历史查询请求数据库中的第一历史查询请求部分匹配,例如,历史查询请求数据库中只存在查询数据A的历史查询请求,不存在查询数据A+B或数据B的历史查询请求。Match the data query request with the historical query request in the historical query request database. In this embodiment, it is assumed that the matching result is that the data query request partially matches the first historical query request in the historical query request database. For example, only the historical query request of the query data A exists in the historical query request database, and the query data A+ does not exist. B or data B history query request.
在确定匹配结果为不完全匹配后,执行步骤503。After determining that the matching result is not completely matched, step 503 is performed.
步骤503,将所述数据查询请求分解为历史数据子查询请求、增量数据子查询请求和全新子查询请求。Step 503: Decompose the data query request into a historical data sub-query request, an incremental data sub-query request, and a brand new sub-query request.
在分解数据查询请求后,分别执行步骤504~506进行查询。After the data query request is decomposed, steps 504-506 are performed to perform the query.
步骤504,根据所述历史数据子查询请求在所述历史查询结果中查询所述第一历史查询请求对应的第一历史查询结果。Step 504: Query, according to the historical data sub-query request, the first historical query result corresponding to the first historical query request in the historical query result.
在云数据库2中查询与数据查询请求部分匹配的第一历史查询请求所对应的第一历史查询结果。该查询过程与前述实施例中的步骤204类 似。The first historical query result corresponding to the first historical query request that is partially matched with the data query request is queried in the cloud database 2. The query process is the same as step 204 in the foregoing embodiment. like.
假设历史查询请求数据库中只存在查询数据A的第一历史查询请求,第一历史查询请求的时间戳为t1,查找到的第一历史查询结果为X1。It is assumed that only the first historical query request of the query data A exists in the historical query request database, the time stamp of the first historical query request is t1, and the first historical query result found is X1.
步骤505,根据所述增量数据子查询请求在时间戳位于所述第一历史查询请求的时间戳之后的原始数据中对所述第一历史查询请求所请求查询的数据进行查询。Step 505: Query, according to the incremental data sub-query request, the data requested by the first historical query request in the original data after the timestamp is located in the timestamp of the first historical query request.
对于云数据库1中记录时间位于第一历史查询请求的时间戳t1之后的原始数据,则根据增量数据子查询请求对数据A进行查询,查询结果为X2,记录当前所查询云数据库1中原始数据的最新记录时间t2。For the original data in the cloud database 1 after the timestamp t1 of the first historical query request is recorded, the data A is queried according to the incremental data subquery request, and the query result is X2, and the original query of the cloud database 1 is recorded. The latest record time of the data is t2.
步骤506,根据所述全新子查询请求在所有原始数据中对所述数据查询请求中与所述第一历史查询请求不匹配部分所请求查询的数据进行查询。Step 506: Query, according to the new sub-query request, data in the data query request that is requested by the first historical query request mismatch portion in all the original data.
对于数据B的查询,由于没有相关的历史查询请求,所以,直接在云数据库1中的所有原始数据中查找数据B,查询结果为X3,记录当前云数据库1中原始数据的最新记录时间t3。For the query of the data B, since there is no relevant historical query request, the data B is directly searched for all the original data in the cloud database 1, and the query result is X3, and the latest recording time t3 of the original data in the current cloud database 1 is recorded.
步骤507,合并历史数据子查询请求、增量数据子查询请求和全新子查询请求的查询结果,并将合并后的查询结果作为所述数据查询请求的结果。Step 507: merge the historical data subquery request, the incremental data subquery request, and the query result of the brand new subquery request, and use the merged query result as a result of the data query request.
该数据查询请求的查询结果即为X1、X2及X3的合并结果。The query result of the data query request is the combined result of X1, X2 and X3.
本实施例还可以进一步包括:This embodiment may further include:
步骤508,更新历史查询请求数据库及云数据库1和云数据库2。 Step 508, updating the historical query request database and the cloud database 1 and the cloud database 2.
其中包括:These include:
将所述第一历史查询结果更新为根据所述历史数据子查询请求与所述增量数据子查询请求所查询的结果的合并结果,并将所述第一历史查询请求的时间戳更新为根据所述增量数据子查询请求所查询数据的最新记录时间;具体的,将查询数据A的第一历史查询请求对应的第一历史查询结果更新为X1+X2,将第一历史查询请求的时间戳更新为t1,t2中的最新时间。Updating the first historical query result to a merge result according to the result of the historical data sub-query request and the incremental data sub-query request, and updating the timestamp of the first historical query request to The incremental data subquery requests the latest recording time of the queried data; specifically, the first historical query result corresponding to the first historical query request of the query data A is updated to X1+X2, and the time of the first historical query request is The stamp is updated to the latest time in t1, t2.
将所述数据查询请求作为第二历史查询请求增添至所述多个历史查询请求中,根据将所述子查询请求所查询数据的最新记录时间作为所述 第二历史查询请求的时间戳,并将所述合并后的查询结果作为与所述第二历史查询请求对应的历史查询结果;具体的,将查询数据A+B的数据查询请求作为第二历史查询请求增加至历史查询请求数据库,时间戳为t1,t2,t3中的最新时间,并将与该第二历史查询请求对应的历史查询结果X1+X2+X3增加至云数据库2中。Adding the data query request as a second historical query request to the plurality of historical query requests, according to the latest recording time of the data that is queried by the subquery request a timestamp of the second historical query request, and the merged query result is used as a historical query result corresponding to the second historical query request; specifically, the data query request of the query data A+B is used as the second history The query request is added to the historical query request database, the timestamp is the latest time in t1, t2, t3, and the historical query result X1+X2+X3 corresponding to the second historical query request is added to the cloud database 2.
将所述全新子查询请求作为第三历史查询请求增添至所述多个历史查询结果中,可以将根据所述全新子查询请求所查询数据的最新记录时间作为所述第三历史查询请求的时间戳,并将所述全新子查询请求的查询结果作为与所述第三历史查询请求对应的历史查询结果;具体的,将查询数据B的全新子查询请求作为第三历史查询请求增加至历史查询请求的数据库中,时间戳为t3,并将于该第三历史查询请求对应的查询结果X3增加至云数据库2中。Adding the new subquery request as the third historical query request to the plurality of historical query results, and using the latest record time of the queryed data according to the brand new subquery request as the time of the third historical query request Stamping, and using the query result of the new subquery request as a historical query result corresponding to the third historical query request; specifically, adding a new subquery request of the query data B as a third historical query request to the historical query In the requested database, the timestamp is t3, and the query result X3 corresponding to the third historical query request is added to the cloud database 2.
在本发明的另一实施例中,当同时存在多个相同的数据查询请求时,可以采用等待执行或并发执行等方法进行数据查询。In another embodiment of the present invention, when a plurality of identical data query requests exist at the same time, data query may be performed by using a method such as waiting for execution or concurrent execution.
其中,等待执行的方式如图6所示,在执行任务1对数据A进行查询时,首先判断历史查询请求数据库中相应分支是否正在进行,该相应分支也即查询历史查询请求数据库中是否存在对数据A的查询请求,若是,则等待相应分支执行成功,若相应分支执行成功,再执行下一数据查询任务;若相应分支执行不成功或没有相应分支正在进行,则执行任务1,并将该任务在历史查询请求数据库中的相应分支标注正在进行,若任务1执行成功则更新历史查询请求数据库,并将新的历史查询结果写入云数据库2,然后执行下一数据查询任务,若任务1执行不成功,则清除在历史查询请求数据库中的相应分支上建立的标注,然后退出。The manner of waiting for execution is as shown in FIG. 6. When performing task 1 to query data A, it is first determined whether the corresponding branch in the historical query request database is in progress, and the corresponding branch is also querying whether the history query request database exists. The query request of the data A, if yes, waits for the execution of the corresponding branch to succeed, and if the corresponding branch is successfully executed, executes the next data query task; if the corresponding branch execution is unsuccessful or no corresponding branch is in progress, the task 1 is executed, and the task is executed. The corresponding branch annotation of the task in the historical query request database is in progress. If the execution of the task 1 is successful, the historical query request database is updated, and the new historical query result is written into the cloud database 2, and then the next data query task is executed, if the task 1 is performed If the execution is unsuccessful, the annotations created on the corresponding branches in the historical query request database are cleared and then exited.
在并行执行的方式中,在执行任务1对数据A进行查询时,直接应用已经存在的历史查询请求及云数据库2中的历史查询结果,对当前正在进行的相同任务不进行检测,指示在任务1执行完成后,更新历史查询请求及历史查询结果时,首先判断当前匹配的历史查询请求的时间戳是否比当前任务1的时间新,若是,则不更新历史查询请求的时间戳,也不更新云数据库2中对应的历史查询结果,若否,再将历史查询请求的时间戳更新为当前任务1的时间戳,将新的历史查询结果更新至云数据库2。 In the parallel execution mode, when the task 1 performs the query on the data A, the existing historical query request and the historical query result in the cloud database 2 are directly applied, and the same task currently being performed is not detected, indicating that the task is in the task. 1 After the execution is completed, when updating the historical query request and the historical query result, it is first determined whether the time stamp of the currently matched historical query request is newer than the current task 1, and if so, the timestamp of the historical query request is not updated, nor updated. The corresponding historical query result in the cloud database 2, if not, the timestamp of the historical query request is updated to the timestamp of the current task 1, and the new historical query result is updated to the cloud database 2.
本发明实施例中还可以根据历史查询请求数据库对云数据库2进行定期清理,即根据历史查询请求删除云数据库2中的无效历史查询结果,还可以对历史查询请求数据库定期合并或删除历史查询请求,并对云数据库2定期合并或删除历史查询结果。In the embodiment of the present invention, the cloud database 2 may be periodically cleaned according to the historical query request database, that is, the invalid historical query result in the cloud database 2 is deleted according to the historical query request, and the historical query request database may be periodically merged or deleted. And periodically merge or delete historical query results for cloud database 2.
本发明实施例通过根据数据查询请求匹配历史查询请求的情况,将数据查询请求分解为全新查询、历史查询和增量查询中的一个或多个,对曾经查询过查询请求及数据的不需要重复查询,这样可以大大减少了扫描和计算的数据量,提高查询效率,降低了查询费用,而且本发明采用历史查询数据库和云数据库2来保存历史查询请求及对应的历史查询结果元数据,每次查询结束后对数据库进行个别数据的更新即可,相对现有技术中的物化视图维护方式代价小很多。The embodiment of the present invention decomposes the data query request into one or more of the new query, the historical query, and the incremental query according to the data query request matching the historical query request, and does not need to repeat the query request and the data that has been queried. Query, which can greatly reduce the amount of data scanned and calculated, improve query efficiency, and reduce query cost, and the present invention uses historical query database and cloud database 2 to store historical query requests and corresponding historical query result metadata, each time After the query is completed, the database can be updated with individual data, which is much less expensive than the prior art materialized view maintenance method.
以上是对本发明方法实施例的描述,下面对实现上述方法的装置进行介绍。The above is a description of the embodiment of the method of the present invention, and the apparatus for implementing the above method will be described below.
参见图7,为本发明实施例一种数据查询装置的结构示意图。FIG. 7 is a schematic structural diagram of a data query apparatus according to an embodiment of the present invention.
该装置可以包括:The device can include:
存储单元701,用于存储多个历史查询请求及其时间戳,以及与所述历史查询请求一一对应的历史查询结果;The storage unit 701 is configured to store a plurality of historical query requests and their timestamps, and a historical query result corresponding to the historical query request;
接收单元702,用于接收数据查询请求;The receiving unit 702 is configured to receive a data query request.
匹配单元703,用于将所述数据查询请求与所述存储单元701中存储的多个历史查询请求进行匹配;The matching unit 703 is configured to match the data query request with multiple historical query requests stored in the storage unit 701.
分解单元704,用于根据匹配结果将所述数据查询请求划分为至少一个子查询请求;The decomposing unit 704 is configured to divide the data query request into at least one subquery request according to the matching result;
查询单元705,用于根据所述子查询请求进行数据查询;The query unit 705 is configured to perform data query according to the subquery request;
结果输出单元706,用于合并所述至少一个子查询请求的查询结果,并将合并后的查询结果作为所述数据查询请求的结果。The result output unit 706 is configured to merge the query result of the at least one subquery request, and use the merged query result as a result of the data query request.
接收单元702接收到数据查询请求后,由匹配单元703将该数据查询请求与存储单元701中存储的多个历史查询请求进行匹配,分解单元704根据匹配结果将所述数据查询请求划分为至少一个子查询请求,具体可以是历史数据子查询请求、增量数据子查询请求以及全新子查询请求中的一个或多个,然后由查询单元705根据分解的子查询请求进行数据查询,最后由结果输出单元706合并查询单元705根据各自子查询请求 查询获得的结果,作为数据查询请求的结果。After receiving the data query request, the receiving unit 702 matches the data query request with the plurality of historical query requests stored in the storage unit 701, and the decomposing unit 704 divides the data query request into at least one according to the matching result. The subquery request may be one or more of a historical data subquery request, an incremental data subquery request, and a brand new subquery request, and then the query unit 705 performs data query according to the decomposed subquery request, and finally outputs the result. Unit 706 merge query unit 705 according to respective subquery request The result of the query is the result of the data query request.
本发明实施例通过上述单元预先存储历史查询请求及历史查询结果,在接收到数据查询请求时可以重用历史查询结果,通过合并历史查询结果和增量查询结果来获得最终的数据查询结果,该装置无需建立和维护物化视图,而且对历史结果数据以及查询过的不需要重复查询,这样可以大大减少扫描和计算的数据量,提高查询效率,改善查询性能,降低查询费用。The embodiment of the present invention pre-stores the historical query request and the historical query result by using the foregoing unit, and can reuse the historical query result when receiving the data query request, and obtain the final data query result by combining the historical query result and the incremental query result, the device There is no need to establish and maintain a materialized view, and there is no need to repeat the query for historical result data and queries. This can greatly reduce the amount of data scanned and calculated, improve query efficiency, improve query performance, and reduce query costs.
参见图8,为本发明实施例另一种数据查询装置的结构示意图。FIG. 8 is a schematic structural diagram of another data query apparatus according to an embodiment of the present invention.
该装置中除了包括存储单元801,接收单元802,匹配单元803,分解单元804,查询单元805和结果输出单元806之外,还可以包括更新单元807。The device may include an update unit 807 in addition to the storage unit 801, the receiving unit 802, the matching unit 803, the decomposition unit 804, the query unit 805, and the result output unit 806.
其中,存储单元801中存储有三个数据库,包括历史查询请求数据库、云数据库1和云数据库2,历史查询请求数据库中包括多个历史查询请求及其时间戳,云数据库1中包括所有原始数据及其时间戳,云数据库2中包括与所述历史查询请求一一对应的历史查询结果。The storage unit 801 stores three databases, including a historical query request database, a cloud database 1 and a cloud database 2. The historical query request database includes a plurality of historical query requests and their timestamps, and the cloud database 1 includes all the original data and The time stamp, the cloud database 2 includes a historical query result corresponding to the historical query request.
本实施例中,分解单元804,具体可以用于当所述数据查询请求与所述历史查询请求中的第一历史查询请求完全匹配时,将所述数据查询请求分解为历史数据子查询请求和增量数据子查询请求;当所述数据查询请求与所述多个历史查询请求完全不匹配时,将所述数据查询请求分解为全新子查询请求;当所述数据查询请求与所述多个历史查询请求中的第一历史查询请求部分匹配时,将所述数据查询请求分解为历史数据子查询请求、增量数据子查询请求和全新子查询请求。In this embodiment, the decomposing unit 804 may be specifically configured to: when the data query request completely matches the first historical query request in the historical query request, decompose the data query request into a historical data subquery request and An incremental data subquery request; when the data query request does not completely match the plurality of historical query requests, decomposing the data query request into a new subquery request; and when the data query request is related to the plurality of When the first historical query request in the historical query request partially matches, the data query request is decomposed into a historical data sub-query request, an incremental data sub-query request, and a brand new sub-query request.
查询单元805可以包括:The query unit 805 can include:
历史查询单元8051,用于根据所述历史数据子查询请求在所述历史查询结果中查询所述第一历史查询请求对应的第一历史查询结果;The history query unit 8051 is configured to query, according to the historical data sub-query request, the first historical query result corresponding to the first historical query request in the historical query result;
增量查询单元8052,用于根据所述增量数据子查询请求在时间戳位于所述第一历史查询请求的时间戳之后的原始数据中对所述数据查询请求所请求查询的数据进行查询;The incremental query unit 8052 is configured to query, according to the incremental data sub-query request, the data requested by the data query request in the original data after the timestamp is located in the timestamp of the first historical query request;
全新查询单元8053,用于根据所述全新子查询请求在所有原始数据中对所述数据查询请求与所述多个历史查询请求的不匹配部分所请求查询的数据进行查询,也就是当所述数据查询请求与所述多个历史查询请 求完全不匹配时,根据所述全新子查询请求在所有原始数据中对所述数据查询请求所请求查询的数据进行查询,当所述数据查询请求与所述多个历史查询请求中的第一历史查询请求部分匹配时,对所述数据查询请求中与所述第一历史查询请求不匹配部分所请求查询的数据进行查询。a new query unit 8053, configured to query, in the original data, the data query request and the data requested by the unmatched portion of the plurality of historical query requests in all the original data according to the new subquery request, that is, when Data query request and the multiple historical queries please When the complete mismatch is found, the data requested by the data query request is queried in all the original data according to the new subquery request, when the data query request and the first of the plurality of historical query requests are When the historical query request is partially matched, the data requested by the part of the data query request that is not matched with the first historical query request is queried.
结果输出单元806,用于根据分解单元804分解的子查询请求,合并历史查询单元8051、增量查询单元8052、全新查询单元8053的查询结果并输出。The result output unit 806 is configured to merge and output the query result of the history query unit 8051, the delta query unit 8052, and the new query unit 8053 according to the subquery request decomposed by the decomposition unit 804.
更新单元807,用于当匹配结果为完全匹配或不完全匹配时,将所述第一历史查询结果更新为根据所述历史数据子查询请求与所述增量数据子查询请求所查询的结果的合并结果,并将所述第一历史查询请求的时间戳更新为根据所述增量数据子查询请求所查询数据的最新记录时间;当匹配结果为不完全匹配或完全不匹配时,将所述数据查询请求作为第二历史查询请求增添至所述多个历史查询请求中,将根据各所述子查询请求所查询数据的最新记录时间作为所述第二历史查询请求的时间戳,并将所述合并后的查询结果作为与所述第二历史查询请求对应的历史查询结果;当匹配结果为不完全匹配时,将所述全新子查询请求作为第三历史查询请求增添至所述多个历史查询请求中,将根据所述全新子查询请求所查询数据的最新记录时间作为所述第三历史查询请求的时间戳,并将所述全新子查询请求的查询结果作为与所述第三历史查询请求对应的历史查询结果。The updating unit 807 is configured to update the first historical query result to a result that is queried according to the historical data subquery request and the incremental data subquery request when the matching result is a perfect match or an incomplete match. Merging the result, and updating the timestamp of the first historical query request to the latest recording time of the data queried according to the incremental data subquery request; when the matching result is not completely matched or completely mismatched, The data query request is added to the plurality of historical query requests as a second historical query request, and the latest record time of the query data according to each of the sub-query requests is used as a time stamp of the second historical query request, and The merged query result is used as a historical query result corresponding to the second historical query request; when the matching result is not completely matched, the new subquery request is added as the third historical query request to the plurality of history In the query request, the latest record time of the query data according to the new subquery request is used as the third history query. Time stamp, and the new sub-query request as a query result historical query results corresponding to the query request third history.
本领域普通技术人员可以意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,能够以电子硬件、或者计算机软件和电子硬件的结合来实现。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本发明的范围。Those of ordinary skill in the art will appreciate that the elements and algorithm steps of the various examples described in connection with the embodiments disclosed herein can be implemented in electronic hardware or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the solution. A person skilled in the art can use different methods for implementing the described functions for each particular application, but such implementation should not be considered to be beyond the scope of the present invention.
所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,上述描述的系统、装置和单元的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。A person skilled in the art can clearly understand that for the convenience and brevity of the description, the specific working process of the system, the device and the unit described above can refer to the corresponding process in the foregoing method embodiment, and details are not described herein again.
在本申请所提供的几个实施例中,应该理解到,所揭露的系统、装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例 仅仅是示意性的,例如,所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。In the several embodiments provided by the present application, it should be understood that the disclosed systems, devices, and methods may be implemented in other manners. For example, the device embodiment described above For example, the division of the unit is only a logical function division, and the actual implementation may have another division manner, for example, multiple units or components may be combined or may be integrated into another system, or some Features can be ignored or not executed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection through some interface, device or unit, and may be in an electrical, mechanical or other form.
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。The units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, may be located in one place, or may be distributed to multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of the embodiment.
另外,在本发明各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
所述功能如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本发明的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)或处理器(processor)执行本发明各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、磁碟或者光盘等各种可以存储程序代码的介质。The functions may be stored in a computer readable storage medium if implemented in the form of a software functional unit and sold or used as a standalone product. Based on such understanding, the technical solution of the present invention, which is essential or contributes to the prior art, or a part of the technical solution, may be embodied in the form of a software product, which is stored in a storage medium, including The instructions are used to cause a computer device (which may be a personal computer, server, or network device, etc.) or a processor to perform all or part of the steps of the methods described in various embodiments of the present invention. The foregoing storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk, and the like. .
以上所述,仅为本发明的具体实施方式,但本发明的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本发明揭露的技术范围内,可轻易想到变化或替换,都应涵盖在本发明的保护范围之内。因此,本发明的保护范围应所述以权利要求的保护范围为准。 The above is only a specific embodiment of the present invention, but the scope of the present invention is not limited thereto, and any person skilled in the art can easily think of changes or substitutions within the technical scope of the present invention. It should be covered by the scope of the present invention. Therefore, the scope of the invention should be determined by the scope of the claims.

Claims (14)

  1. 一种数据查询方法,其特征在于,预先存储多个历史查询请求及其时间戳,以及与所述历史查询请求一一对应的历史查询结果,所述查询方法包括:A data query method, characterized in that a plurality of historical query requests and their time stamps are stored in advance, and historical query results corresponding to the historical query requests are one-to-one, the query method includes:
    接收数据查询请求;Receiving a data query request;
    将所述数据查询请求与所述多个历史查询请求进行匹配;Matching the data query request with the plurality of historical query requests;
    根据匹配结果将所述数据查询请求划分为至少一个子查询请求;Dividing the data query request into at least one sub-query request according to the matching result;
    根据所述子查询请求进行数据查询;Performing a data query according to the subquery request;
    合并所述至少一个子查询请求的查询结果,并将合并后的查询结果作为所述数据查询请求的结果。Merging the query result of the at least one subquery request and using the merged query result as a result of the data query request.
  2. 根据权利要求1所述的方法,其特征在于,所述根据匹配结果将所述数据查询请求分解为至少一个子查询请求,包括:The method according to claim 1, wherein the decomposing the data query request into at least one sub-query request according to the matching result comprises:
    当所述数据查询请求与所述历史查询请求中的第一历史查询请求完全匹配时,将所述数据查询请求分解为历史数据子查询请求和增量数据子查询请求;When the data query request completely matches the first historical query request in the historical query request, the data query request is decomposed into a historical data sub-query request and an incremental data sub-query request;
    所述根据所述子查询请求进行数据查询,包括:The performing data query according to the subquery request includes:
    根据所述历史数据子查询请求在所述历史查询结果中查询所述第一历史查询请求对应的第一历史查询结果;Querying, according to the historical data sub-query request, the first historical query result corresponding to the first historical query request in the historical query result;
    根据所述增量数据子查询请求在时间戳位于所述第一历史查询请求的时间戳之后的原始数据中对所述数据查询请求所请求查询的数据进行查询。And querying, according to the incremental data sub-query request, data of the requested query of the data query request in the original data after the timestamp is located in the timestamp of the first historical query request.
  3. 根据权利要求2所述的方法,其特征在于,还包括:The method of claim 2, further comprising:
    将所述第一历史查询结果更新为所述合并后的查询结果,并将所述第一历史查询请求的时间戳更新为根据所述增量数据子查询请求所查询数据的最新记录时间。Updating the first historical query result to the merged query result, and updating the timestamp of the first historical query request to the latest recording time of the queryed data according to the incremental data subquery request.
  4. 根据权利要求1所述的方法,其特征在于,所述根据匹配结果将所述数据查询请求分解为至少一个子查询请求,包括:The method according to claim 1, wherein the decomposing the data query request into at least one sub-query request according to the matching result comprises:
    当所述数据查询请求与所述多个历史查询请求完全不匹配时,将所述数据查询请求分解为全新子查询请求; When the data query request does not completely match the plurality of historical query requests, the data query request is decomposed into a new sub-query request;
    所述根据所述子查询请求进行数据查询,包括:The performing data query according to the subquery request includes:
    根据所述全新子查询请求在所有原始数据中对所述数据查询请求所请求查询的数据进行查询。The data requested by the data query request is queried in all the original data according to the brand new subquery request.
  5. 根据权利要求4所述的方法,其特征在于,还包括:The method of claim 4, further comprising:
    将所述数据查询请求作为第二历史查询请求增添至所述多个历史查询请求中,将根据所述全新子查询请求所查询数据的最新记录时间作为所述第二历史查询请求的时间戳,并将所述合并后的查询结果作为与所述第二历史查询请求对应的历史查询结果。Adding the data query request as the second historical query request to the plurality of historical query requests, and using the latest record time of the queryed data according to the brand new subquery request as the time stamp of the second historical query request. And the merged query result is used as a historical query result corresponding to the second historical query request.
  6. 根据权利要求1所述的方法,其特征在于,所述根据匹配结果将所述数据查询请求分解为至少一个子查询请求,包括:The method according to claim 1, wherein the decomposing the data query request into at least one sub-query request according to the matching result comprises:
    当所述数据查询请求与所述多个历史查询请求中的第一历史查询请求部分匹配时,将所述数据查询请求分解为历史数据子查询请求、增量数据子查询请求和全新子查询请求;When the data query request partially matches the first historical query request of the plurality of historical query requests, the data query request is decomposed into a historical data subquery request, an incremental data subquery request, and a brand new subquery request. ;
    所述根据所述子查询请求进行数据查询,包括:The performing data query according to the subquery request includes:
    根据所述历史数据子查询请求在所述历史查询结果中查询所述第一历史查询请求对应的第一历史查询结果;Querying, according to the historical data sub-query request, the first historical query result corresponding to the first historical query request in the historical query result;
    根据所述增量数据子查询请求在时间戳位于所述第一历史查询请求的时间戳之后的原始数据中对所述第一历史查询请求所请求查询的数据进行查询;And querying, according to the incremental data sub-query request, the data of the requested query by the first historical query request in the original data after the timestamp of the first historical query request;
    根据所述全新子查询请求在所有原始数据中对所述数据查询请求中与所述第一历史查询请求不匹配部分所请求查询的数据进行查询。And querying data of the requested query in the data query request that is not matched with the first historical query request in all the original data according to the brand new subquery request.
  7. 根据权利要求6所述的方法,其特征在于,还包括:The method of claim 6 further comprising:
    将所述第一历史查询结果更新为根据所述历史数据子查询请求与所述增量数据子查询请求所查询的结果的合并结果,并将所述第一历史查询请求的时间戳更新为根据所述增量数据子查询请求所查询数据的最新记录的时间;Updating the first historical query result to a merge result according to the result of the historical data sub-query request and the incremental data sub-query request, and updating the timestamp of the first historical query request to The time at which the incremental data subquery requests the most recent record of the queried data;
    将所述数据查询请求作为第二历史查询请求增添至所述多个历史查询请求中,将根据各所述子查询请求所查询数据的最新记录时间作为所述第二历史查询请求的时间戳,并将所述合并后的查询结果作为与所 述第二历史查询请求对应的历史查询结果;Adding the data query request as the second historical query request to the plurality of historical query requests, and using the latest record time of the query data according to each of the subquery requests as the time stamp of the second historical query request. And the combined query result is used as the same Determining a historical query result corresponding to the second historical query request;
    将所述全新子查询请求作为第三历史查询请求增添至所述多个历史查询请求中,将根据所述全新子查询请求所查询数据的最新记录时间作为所述第三历史查询请求的时间戳,并将所述全新子查询请求的查询结果作为与所述第三历史查询请求对应的历史查询结果。Adding the new subquery request as the third historical query request to the plurality of historical query requests, and using the latest record time of the queryed data according to the new subquery request as the time stamp of the third historical query request And the query result of the new subquery request is used as a historical query result corresponding to the third historical query request.
  8. 一种数据查询装置,其特征在于,包括:A data query device, comprising:
    存储单元,用于存储多个历史查询请求及其时间戳,以及与所述历史查询请求一一对应的历史查询结果;a storage unit, configured to store a plurality of historical query requests and their timestamps, and a historical query result corresponding to the historical query request;
    接收单元,用于接收数据查询请求;a receiving unit, configured to receive a data query request;
    匹配单元,用于将所述数据查询请求与所述存储单元中存储的多个历史查询请求进行匹配;a matching unit, configured to match the data query request with multiple historical query requests stored in the storage unit;
    分解单元,用于根据匹配结果将所述数据查询请求划分为至少一个子查询请求;a decomposition unit, configured to divide the data query request into at least one sub-query request according to the matching result;
    查询单元,用于根据所述子查询请求进行数据查询;a query unit, configured to perform data query according to the subquery request;
    结果输出单元,用于合并所述至少一个子查询请求的查询结果,并将合并后的查询结果作为所述数据查询请求的结果。a result output unit, configured to merge the query result of the at least one subquery request, and use the merged query result as a result of the data query request.
  9. 根据权利要求8所述的装置,其特征在于,The device of claim 8 wherein:
    所述分解单元,具体用于当所述数据查询请求与所述历史查询请求中的第一历史查询请求完全匹配时,将所述数据查询请求分解为历史数据子查询请求和增量数据子查询请求;The decomposing unit is specifically configured to decompose the data query request into a historical data sub-query request and an incremental data sub-query when the data query request completely matches the first historical query request in the historical query request. request;
    所述查询单元包括:The query unit includes:
    历史查询单元,用于根据所述历史数据子查询请求在所述历史查询结果中查询所述第一历史查询请求对应的第一历史查询结果;a historical query unit, configured to query, in the historical query result, a first historical query result corresponding to the first historical query request according to the historical data sub-query request;
    增量查询单元,用于根据所述增量数据子查询请求在时间戳位于所述第一历史查询请求的时间戳之后的原始数据中对所述数据查询请求所请求查询的数据进行查询。And an incremental query unit, configured to query, according to the incremental data subquery request, the data of the requested query of the data query request in the original data after the timestamp of the first historical query request.
  10. 根据权利要求9所述的装置,其特征在于,还包括:The device according to claim 9, further comprising:
    更新单元,用于将所述第一历史查询结果更新为所述合并后的查询结果,并将所述第一历史查询请求的时间戳更新为根据所述增量数据子 查询请求所查询数据的最新记录时间。An update unit, configured to update the first historical query result to the merged query result, and update a timestamp of the first historical query request according to the incremental data sub Query the latest recording time of the data requested by the query.
  11. 根据权利要求8所述的装置,其特征在于,The device of claim 8 wherein:
    所述分解单元,具体用于当所述数据查询请求与所述多个历史查询请求完全不匹配时,将所述数据查询请求分解为全新子查询请求;The decomposing unit is configured to: when the data query request completely does not match the plurality of historical query requests, decompose the data query request into a new subquery request;
    所述查询单元包括全新查询单元,所述全新查询单元,用于根据所述全新子查询请求在所有原始数据中对所述数据查询请求所请求查询的数据进行查询。The query unit includes a new query unit, and the new query unit is configured to query the data requested by the data query request in all the original data according to the brand new sub-query request.
  12. 根据权利要求11所述的装置,其特征在于,还包括:The device according to claim 11, further comprising:
    更新单元,用于将所述数据查询请求作为第二历史查询请求增添至所述多个历史查询请求中,将根据所述全新子查询所查询数据的最新记录时间作为所述第二历史查询请求的时间戳,并将所述合并后的查询结果作为与所述第二历史查询请求对应的历史查询结果。An update unit, configured to add the data query request to the plurality of historical query requests as a second historical query request, and use the latest record time of the data according to the new sub-query as the second historical query request Time stamp, and the merged query result is used as a historical query result corresponding to the second historical query request.
  13. 根据权利要求8所述的装置,其特征在于,The device of claim 8 wherein:
    所述分解单元,具体用于当所述数据查询请求与所述多个历史查询请求中的第一历史查询请求部分匹配时,将所述数据查询请求分解为历史数据子查询请求、增量数据子查询请求和全新子查询请求;The decomposing unit is configured to: when the data query request partially matches the first historical query request of the plurality of historical query requests, decompose the data query request into a historical data subquery request, incremental data Subquery request and new subquery request;
    所述查询单元包括:The query unit includes:
    历史查询单元,用于根据所述历史数据子查询请求在所述历史查询结果中查询所述第一历史查询请求对应的第一历史查询结果;a historical query unit, configured to query, in the historical query result, a first historical query result corresponding to the first historical query request according to the historical data sub-query request;
    增量查询单元,用于根据所述增量数据子查询请求在时间戳位于所述第一历史查询请求的时间戳之后的原始数据中对所述第一历史查询请求所请求查询的数据进行查询;An incremental query unit, configured to query, according to the incremental data subquery request, data of the requested query of the first historical query request in the original data after the timestamp of the first historical query request ;
    全新查询单元,用于根据所述全新子查询请求在所有原始数据中对所述数据查询请求中与所述第一历史查询请求不匹配部分所请求查询的数据进行查询。The new query unit is configured to query, in the original data, the data of the requested query in the data query request that is not matched with the first historical query request according to the new subquery request.
  14. 根据权利要求13所述的装置,其特征在于,还包括:The device according to claim 13, further comprising:
    更新单元,用于将所述第一历史查询结果更新为根据所述历史数据子查询请求与所述增量数据子查询请求所查询的结果的合并结果,并将 所述第一历史查询请求的时间戳更新为根据所述增量数据子查询请求所查询数据的最新记录时间;将所述数据查询请求作为第二历史查询请求增添至所述多个历史查询请求中,将根据各所述子查询请求所查询数据的最新记录时间作为所述第二历史查询请求的时间戳,并将所述合并后的查询结果作为与所述第二历史查询请求对应的历史查询结果;将所述全新子查询请求作为第三历史查询请求增添至所述多个历史查询请求中,将根据所述全新子查询请求所查询数据的最新记录时间作为所述第三历史查询请求的时间戳,并将所述全新子查询请求的查询结果作为与所述第三历史查询请求对应的历史查询结果。 And an updating unit, configured to update the first historical query result to a combined result according to the historical data subquery request and the result of the incremental data subquery request query, and Updating the timestamp of the first historical query request to the latest recording time of the data queried according to the incremental data subquery request; adding the data query request as the second historical query request to the plurality of historical query requests The latest record time of the query data according to each of the subquery requests is used as the time stamp of the second history query request, and the merged query result is used as the history corresponding to the second history query request. Querying the result; adding the new subquery request as the third historical query request to the plurality of historical query requests, and using the latest record time of the queried data according to the new subquery request as the third historical query request a timestamp, and the query result of the brand new subquery request is a historical query result corresponding to the third historical query request.
PCT/CN2014/088343 2013-11-22 2014-10-11 Data search method and apparatus WO2015074466A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201310596903.6A CN104657387B (en) 2013-11-22 2013-11-22 A kind of data query method and device
CN201310596903.6 2013-11-22

Publications (1)

Publication Number Publication Date
WO2015074466A1 true WO2015074466A1 (en) 2015-05-28

Family

ID=53178909

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2014/088343 WO2015074466A1 (en) 2013-11-22 2014-10-11 Data search method and apparatus

Country Status (2)

Country Link
CN (1) CN104657387B (en)
WO (1) WO2015074466A1 (en)

Families Citing this family (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105095399B (en) * 2015-07-06 2019-06-28 百度在线网络技术(北京)有限公司 Search result method for pushing and device
CN107871253A (en) * 2016-09-23 2018-04-03 中兴通讯股份有限公司 A kind of big data method of commerce and system
CN108121733B (en) * 2016-11-29 2021-10-15 北京国双科技有限公司 Data query method and device
CN108737473B (en) * 2017-04-20 2019-12-20 贵州白山云科技股份有限公司 Data processing method, device and system
CN107357712B (en) * 2017-07-17 2020-09-25 顺丰科技有限公司 Order checking abnormity detection method, system and equipment
CN107391721A (en) * 2017-07-31 2017-11-24 武汉票据交易中心有限公司 A kind of data screening method and system
CN108172299B (en) * 2017-12-25 2021-04-27 华中科技大学同济医学院附属协和医院 Medical data remote computing system and method
CN112100138A (en) * 2020-09-16 2020-12-18 北京天融信网络安全技术有限公司 Log query method and device, storage medium and electronic equipment
CN113326015A (en) * 2021-06-23 2021-08-31 北京字跳网络技术有限公司 Information display method and device and electronic equipment

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20070043706A1 (en) * 2005-08-18 2007-02-22 Yahoo! Inc. Search history visual representation
CN101110074A (en) * 2007-01-30 2008-01-23 浪潮乐金信息系统有限公司 Data speedup query method based on file system caching
US20080065617A1 (en) * 2005-08-18 2008-03-13 Yahoo! Inc. Search entry system with query log autocomplete
CN102279849A (en) * 2010-06-09 2011-12-14 中兴通讯股份有限公司 Method and system for big data query

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN100442290C (en) * 2006-07-12 2008-12-10 百度在线网络技术(北京)有限公司 Accessing identification index system and accessing identification index library generation method
CN102546247B (en) * 2011-12-29 2014-08-27 华中科技大学 Massive data continuous analysis system suitable for stream processing

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20070043706A1 (en) * 2005-08-18 2007-02-22 Yahoo! Inc. Search history visual representation
US20080065617A1 (en) * 2005-08-18 2008-03-13 Yahoo! Inc. Search entry system with query log autocomplete
CN101110074A (en) * 2007-01-30 2008-01-23 浪潮乐金信息系统有限公司 Data speedup query method based on file system caching
CN102279849A (en) * 2010-06-09 2011-12-14 中兴通讯股份有限公司 Method and system for big data query

Also Published As

Publication number Publication date
CN104657387B (en) 2019-02-05
CN104657387A (en) 2015-05-27

Similar Documents

Publication Publication Date Title
WO2015074466A1 (en) Data search method and apparatus
JP7273045B2 (en) Dimensional Context Propagation Techniques for Optimizing SQL Query Plans
CN109299102B (en) HBase secondary index system and method based on Elastcissearch
KR102407510B1 (en) Method, apparatus, device and medium for storing and querying data
CN107729371B (en) Data indexing and querying method, device, equipment and storage medium of block chain
US9870382B2 (en) Data encoding and corresponding data structure
US20200201909A1 (en) Graph database and relational database mapping
CN104123374A (en) Method and device for aggregate query in distributed databases
US8924373B2 (en) Query plans with parameter markers in place of object identifiers
CN107729399B (en) Data processing method and device
EP2686764A1 (en) Data source analytics
US11030196B2 (en) Method and apparatus for processing join query
US11741084B2 (en) High frequency data management (HFDM)
WO2017088666A1 (en) Data storage method and coordinator node
CN108573026B (en) Data circulation method and device, storage medium and server
WO2017161540A1 (en) Data query method, data object storage method and data system
Zhan et al. AnalyticDB: real-time OLAP database system at Alibaba cloud
JP2020123320A (en) Method, apparatus, device and storage medium for managing index
US11226986B2 (en) Data table partitioning management method and apparatus
US9342545B2 (en) Using a partially built index in a computer database system
US11163801B2 (en) Execution of queries in relational databases
WO2016169322A1 (en) Query method and device for database, and computer storage medium
US20130006960A1 (en) Optimizing Database Queries
US9275103B2 (en) Optimization of JOIN queries for related data
CN109491988A (en) A kind of data real time correlation method for supporting full dose to update

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 14863665

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 14863665

Country of ref document: EP

Kind code of ref document: A1