CN108647357A - The method and device of data query - Google Patents

The method and device of data query Download PDF

Info

Publication number
CN108647357A
CN108647357A CN201810473920.3A CN201810473920A CN108647357A CN 108647357 A CN108647357 A CN 108647357A CN 201810473920 A CN201810473920 A CN 201810473920A CN 108647357 A CN108647357 A CN 108647357A
Authority
CN
China
Prior art keywords
data
version information
data table
tables
current data
Prior art date
Legal status (The legal status 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 status listed.)
Granted
Application number
CN201810473920.3A
Other languages
Chinese (zh)
Other versions
CN108647357B (en
Inventor
韩杰
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Advanced New Technologies Co Ltd
Advantageous New Technologies Co Ltd
Original Assignee
Alibaba Group Holding Ltd
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 Alibaba Group Holding Ltd filed Critical Alibaba Group Holding Ltd
Priority to CN201810473920.3A priority Critical patent/CN108647357B/en
Publication of CN108647357A publication Critical patent/CN108647357A/en
Application granted granted Critical
Publication of CN108647357B publication Critical patent/CN108647357B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

This specification embodiment provides a kind of method and apparatus of data query, according to this method, after receiving inquiry request, it detects and whether there is cache object corresponding with query argument included in inquiry request in buffer zone, in the case where there is cache object corresponding with above-mentioned query argument, obtain first version information and second edition information, wherein, first version information is the corresponding tables of data version information of cache object, second edition information is the version information of current data table in database, the first tables of data and the second tables of data at least stored in database, it is configured as one and is used as current data table, remaining is as Backup Data table;Then, the consistency for judging first version information and second edition information, under first version information and second edition information unanimous circumstances, using cache object as query result.In this way, the validity of data query can be improved.

Description

The method and device of data query
Technical field
This specification one or more embodiment is related to field of computer technology, more particularly to carries out data by computer The method and apparatus of inquiry.
Background technology
In big data analysis business, it will usually periodically anticipate the business datum being collected into, then pass through number It is synchronized to storage system on line according to synchronization means.It is huge in data volume, the full dose or increment synchronization of a tables of data It may need the long period (such as four or five hours) that could complete.In order to ensure that storage system is just on line in this process It often works, the method that the tables of data of storage system often uses AB tables on line is realized, i.e.,:It is right for the logical table on a line Answer two physical tables of bottom, such as logical table tb, corresponding two physical tables tb_0, tb_1.Two tables of data can alternately make With one is used as current data table, and the business such as inquiry are provided for storage system on line, another, can be with as Backup Data table The business datum anticipated is synchronized by data synchronization means.
In actual use, in the case where data volume is larger, such as in high concurrent operation system, in order to improve inquiry effect Rate improves query rate QPS and query responding time RT often through the mode for increasing caching.This just bring it is data cached with work as The problem of consistency of preceding data table data.On the one hand, Backup Data table can be switched to currently according to scheduled switching principle Tables of data, on the other hand, due to real scene that can not be on comprehensive simulated line to the verification of data, the data of current data table have There may be quality problems, in such cases it need switching back into original data temporarily, i.e., are switched to Backup Data table Current data table.In other words, can all occur the switching between Backup Data table and current data table in several cases.This When, it is data cached and by Backup Data table switch Lai the data of current data table be likely to occur inconsistent situation.
Accordingly, it would be desirable to there is improved plan, data cached and current data table data consistency are able to verify that, with true It is correct to protect the data obtained from caching, to further increase the validity of data query.
Invention content
This specification one or more embodiment describes a kind of method and apparatus, is able to verify that data cached and current number According to the consistency of table data, to ensure that the data obtained from caching are correct, to further increase having for data query Effect property.
According in a first aspect, provide a kind of method of data query, including:
Receive inquiry request, wherein the inquiry request includes query argument;
It detects and whether there is cache object corresponding with the query argument in buffer zone;
In the case where there is cache object corresponding with the query argument, first version information and the second edition are obtained This information, the first version information are the corresponding tables of data version informations of the cache object, and the second edition information is The version information of current data table in database, wherein being at least stored with the first tables of data and the second data in the database Table, first tables of data and the second tables of data are configured as the conduct current data table, remaining is as Backup Data Table;
Judge the consistency of first version information and second edition information;
Under the first version information and second edition information unanimous circumstances, tied the cache object as inquiry Fruit.
Embodiment according to one aspect, the method further include:
There is no cache object corresponding with the query argument or the first version information and the second edition In the case that information is inconsistent,
According to the query argument to current data table described in the data base querying;
According to the data returned from the database, query result is generated.
In a possible design, after generating query result, further include:
According to the cache object in the query result update buffer zone generated.
Further, in one embodiment, according to the cache object in the query result update buffer zone generated Including:
It is added to the query result of generation as cache object in the buffer zone;
The version information of the current data table is saved as to the version information of the cache object.
In one embodiment, the method further includes:
The version information of current data table is obtained from database according to first time interval;
The version information of current data table is stored in and is locally configured in table.
In one embodiment, the acquisition first version information and second edition information include:
The second edition information is obtained from described be locally configured in table.
According to a kind of possible design, the version information of current data table is stored in and table is locally configured includes:
The version information of the acquired current data table of detection and the version that the current data table preserved in table is locally configured Whether information is consistent;And
In the case of inconsistencies, it is locally configured in table according to the update of the version information of acquired current data table current The version information of tables of data.
In one embodiment, the database includes tables of data repository, and the tables of data repository is used for, when predetermined When condition meets, switch the current data table and Backup Data table status of the first tables of data and the second tables of data;
The version information for obtaining current data table from database according to first time interval includes:
The version information of current data table is obtained from the tables of data repository.
According to some embodiments, the predetermined condition includes at least one of the following:
Complete the update of Backup Data table;
Meet the second time interval of tables of data switching;
There is predetermined mistake in current data table.
In some possible designs, the version information of current data table include it is following in it is one or more:Version mark Know, timestamp.
According to second aspect, a kind of device of data query is provided, including:
Receiving unit is configured to receive inquiry request, wherein the inquiry request includes query argument;
Detection unit is configured to whether there is cache object corresponding with the query argument in detection buffer zone;
Acquiring unit is configured to, in the case where there is cache object corresponding with the query argument, obtain first Version information and second edition information, the first version information are the corresponding tables of data version information of the cache object, institute The version information that second edition information is current data table in database is stated, wherein being at least stored with the first number in the database According to table and the second tables of data, first tables of data and the second tables of data are configured as the conduct current data table, It is remaining to be used as Backup Data table;
Comparison unit is configured to judge the consistency of first version information and second edition information;
Determination unit is configured under the first version information and second edition information unanimous circumstances, will be described slow Object is deposited as query result.
According to the third aspect, a kind of computer readable storage medium is provided, computer program is stored thereon with, when described When computer program executes in a computer, enable computer execute first aspect method.
According to fourth aspect, a kind of computing device, including memory and processor are provided, which is characterized in that described to deposit It is stored with executable code in reservoir, when the processor executes the executable code, the method for realizing first aspect.
The method and apparatus provided by this specification embodiment, after receiving inquiry request, detecting in buffer zone is It is no to there is cache object corresponding with query argument included in inquiry request, it is corresponding with above-mentioned query argument existing Cache object in the case of, obtain first version information and second edition information, wherein first version information is cache object Corresponding tables of data version information, second edition information are the version informations of current data table in database, in database at least The first tables of data and the second tables of data of storage are configured as one and are used as current data table, remaining is as Backup Data table;So Afterwards, the consistency for judging first version information and second edition information, it is consistent with second edition information in first version information In the case of, using cache object as query result.In this way, data cached and current data table data consistency can be verified, To ensure that the data obtained from caching are correct, to improve the validity of data query.
Description of the drawings
In order to illustrate the technical solution of the embodiments of the present invention more clearly, required use in being described below to embodiment Attached drawing be briefly described, it should be apparent that, drawings in the following description are only some embodiments of the invention, for this For the those of ordinary skill of field, without creative efforts, others are can also be obtained according to these attached drawings Attached drawing.
Fig. 1 shows the implement scene schematic diagram of one embodiment that this specification discloses;
Fig. 2 shows the method flow diagrams according to the data query of one embodiment;
Fig. 3 shows a specific example of database;
Fig. 4 shows the schematic block diagram of the device for data query according to one embodiment.
Specific implementation mode
Below in conjunction with the accompanying drawings, the scheme provided this specification is described.
Fig. 1 is the implement scene schematic diagram of one embodiment that this specification discloses.As shown, can in searching platform The inquiry request of user is received and handled by client.Further include database in searching platform, is at least protected in database Two parts of tables of data are deposited, one is used as current data table, another has as Backup Data table, current data table as inquiry Tables of data is imitated, for providing service for the inquiry of client, Backup Data table can receive new collected data.Tables of data When data update, it can be identified by different version informations (such as renewal time etc.).In practice, database can be set In client, the server end that support is provided for client can also be located at, can also be located at storage platform (such as block chain, Cloud storage etc.), the application is not construed as limiting this.
In practical applications, inquiring client terminal is rung when handling the inquiry request of user in order to improve query rate and shorten Between seasonable, the various data (such as account balance etc. of financing account) that can inquire user are preserved as cache object In buffer zone.Wherein, it in inquiry request may include query argument, such as the inquiry nearest 5 days expenditures of Alipay, inquiry ginseng Number may include corresponding Alipay account information, time parameter " 5 days ", type parameter " expenditure " etc..Client receives In the case of inquiry request, first have to inquire data from local buffer zone.When inquiring corresponding cache object, it is Ensure that cache object is consistent with the data in database current data table, client will further carry out cache object From the version information of tables of data and the consistency of version information of current data table judged.Due to meeting when tables of data updates Update version information, as long as therefore version information it is consistent, then show the data one in cache object and database current data table It causes.In practice, client can together preserve the corresponding tables of data version information of cache object when preserving cache object. It so can be under the data unanimous circumstances in cache object and database current data table, using cache object as inquiry As a result user is fed back to, without being inquired from the current data table of database again.In this way, can verify data cached and work as The consistency of preceding data table data ensures using the cache object obtained from buffer zone as query result to be correct.
According to a kind of embodiment, respective cache object or cache object and data are not being inquired in the buffer In the case that the version information of library current data table is inconsistent, client can also from data base querying current data table, according to The data of return generate query result.In this way, can in the buffer without cache object or cache object with current data table not When consistent, from data base querying data, correct data are obtained in time.
In one embodiment, client, which can be spaced to schedule from database, obtains current data table Version information, and the version information of current data table is stored in and is locally configured in table.In this way, can grasp in database in time The release status of current data table, and in the inquiry request for receiving user, know current data table by the way that table is locally configured Version information, without temporarily again to the version information of data base querying current data table.
The specific executive mode of above procedure is described below.
Fig. 2 shows the method flow diagrams according to the data query of one embodiment.The executive agent of this method can be appointed What has calculating, the system of processing capacity, unit or platform, such as client shown in FIG. 1 etc..As shown in Fig. 2, should Method includes the following steps:Step 21, inquiry request is received, wherein above-mentioned inquiry request includes query argument;Step 22, it examines It surveys and whether there is cache object corresponding with above-mentioned query argument in buffer zone;Step 23, exist and above-mentioned inquiry ginseng In the case of the corresponding cache object of number, first version information and second edition information are obtained, first version information is caching The corresponding tables of data version information of object, second edition information are the version information of current data table in database, wherein data The first tables of data and the second tables of data are at least stored in library, the first tables of data and the second tables of data are configured as a conduct and work as Preceding tables of data, remaining is as Backup Data table;Step 24, judge the consistency of first version information and second edition information;Step Rapid 25, under first version information and second edition information unanimous circumstances, using above-mentioned cache object as query result.
First, in step 21, inquiry request is received, wherein above-mentioned inquiry request includes query argument.Inquiry request is for example It can be HTTP request etc..It is appreciated that each inquiry request has corresponding querying method or query function, this is also known as looked into Ask interface.One inquiry request can call relevant inquiring interface to transmit query argument.Each inquiry request may be called equally Query interface, but have different parameters.Therefore, may include having query argument in inquiry request.A such as inquiry Request is the amount paid in certain payment platform in user 5 days, another inquiry request is one week certain payment platform of inherence of user Amount paid, their query argument relates separately to:Time parameter " 5 days ", platform parameters " certain payment platform ", type parameter " expenditure ", target component " amount of money " and time parameter " one week ", platform parameters " certain payment platform ", type parameter " expenditure ", mesh Mark parameter " amount of money ".
By the query argument in the inquiry request, corresponding data in database can be obtained.Such as it is asked by inquiry The query argument time parameter " this month " for including, type parameter " residue is available ", target component " amount " etc. are asked, it can be from data Library acquisition this month, can use amount with full amount and this month.
In some implementations, inquiry request can also include the querying condition being defined to query result, for example, user By the amount paid of certain payment platform net purchase in 5 days, querying condition defines that the amount paid in be inquired 5 days is to be used for Net purchase is carried out by certain payment platform.
Inquiry request can be by user by being initiated with interacting for client human-computer interaction interface, can also be by it What the calling of his application program was initiated, the application is not construed as limiting this.For example, the financing analysis of certain payment platform client Module can be by calling relevant inquiring interface to initiate inquiry request, to inquire in user one month in the various of the payment platform Expenditure and income information.Certain payment platform client can receive the query statement that user is inputted by the query page of client Inquiry request is initiated, user can also be received, the click of query argument is selected to send out in the table of client human-computer interaction interface Play inquiry request.
Then, it in step 22, detects and whether there is cache object corresponding with above-mentioned query argument in buffer zone.It can To understand, caching is the buffering area of data exchange, is to carry out the memory of high-speed data exchange.It buffer zone can be by history Data temporary storage is multiple entries, and data are exchanged prior to memory and processor.Cache entries may include that table, event are retouched It states, the storage form of key-value pair (key-va l ue) etc..One cache entries or a part of of cache entries can be referred to as Cache object.
By taking key-value pair as an example, each key values can correspond to one or more va l ue values.Historical query is recorded, Can be using query argument as key values, query result is as va l ue values, when being stored in buffer zone.For example, will inquiry Parameter:Time parameter " 5 days ", platform parameters " certain payment platform ", type parameter " expenditure " etc. are used as key values, query result " 5000 yuan " are used as va l ue values.At this point it is possible to which " 5000 yuan " of va l ue values in cache entries are referred to as to look into above-mentioned Ask the corresponding cache object of parameter.In one embodiment, a version can also be added to the query result as va l ue values This attribute tags, to show the version information of the tables of data in query result source, for example, it is " 5000 that va l ue values, which preserve content, First .201805100900 ", wherein 201805100900 be the version information of the derived data table of query result, such as indicating should Derived data table version is the more new version at 9 o'clock of on May 10th, 2018.In a kind of possible design, key values can also be To the obtained vocabulary group of query argument extraction keyword, such as " certain payment platform 5 days in amount paid " etc..
After receiving inquiry request, first the query argument in inquiry request can be matched with cache entries. Still by taking cache entries are the storage forms of key-value pair as an example, it can be matched with each key values by query argument, be matched to and inquire When the consistent key values of parameter, corresponding va l ue values, i.e., cache object corresponding with query argument are obtained according to key values. Stored inside key values be crucial phrase at vocabulary group in the case of, the inquiry language that can also will include according to inquiry request Sentence carries out cutting word, removal function word processing, obtains query argument and is matched with key values.Matching said herein can be completely accurately Matching can also be the matching replaced by nearly justice, such as the time parameter in query argument is " last month ", can be according to current 2018 time of inquiry was matched to key values " 2018.4 " or " 201804 " etc. May 10.
From caching Region Matching to respective cache entry, determines in buffer zone and exist and query argument phase Otherwise cache object corresponding with query argument is not present in corresponding cache object in buffer zone.
Then, in step 23, in the case where there is cache object corresponding with above-mentioned query argument, the first edition is obtained This information and second edition information.
As previously mentioned, in order to ensure the normal work of storage system on line in this process, the number of storage system on line The method of AB tables is often used to realize according to table, i.e.,:The first tables of data and the second tables of data, the first number are at least stored in database It is configured as one according to table and the second tables of data and is used as current data table, remaining is as Backup Data table.First tables of data and Two tables of data can be used alternatingly, and be configured as that tables of data of current data table, and the business such as inquiry are provided for database, It is remaining to be used as Backup Data table.The business datum anticipated can be synchronized by data synchronization means to Backup Data table.
As previously mentioned, cache object from historical query as a result, and historical query result derive from historical query when number According to the current data table in library.For the first tables of data and the second tables of data in database, if only indicating tables of data Which table is name, then can only know from and inquire data, and it is data when that can not know inquired data.Example Such as, tables of data tb_0 and tb_1, tables of data tb_0 were used May 1, tables of data tb_1 was used May 2, in May 3 It is switched to the tables of data tb_0 after having updated 2 number in May days again to use, if saved by tables of data tb_0 May 1 Cache object, in the tables of data tb_0 that May 3 used, the corresponding data of identical query argument may have occurred that change Change, cache object may be inaccurate.Therefore, for the more new state of mark data table, after the completion of each tables of data update A version information can be added.
This version information can include but is not limited to it is following in it is one or more:Table name, version identifier, time Stamp.Version identifier can be a string of characters of mark update order, such as can be 2.1.3.5 etc., and tables of data often updates one Secondary, version identifier variation is primary, such as version number becomes 2.1.3.6 after update;Timestamp can be used to indicate that the one of time String character, such as 201805100900.Timestamp can indicate that tables of data updates the deadline, can also identify the newer number of institute According to acquisition time, indicate that the newer data of tables of data institute are 10 days 09 Mays in 2018 such as 201805100900:It is adopted before 00 The data of collection.Table name, such as tb_0;Usually, table name need to be combined with sundry item, and common unique mark goes out the currently active The version information of table.
In this way, when inquiring data from the current data table of database according to query argument, current data can also be obtained The version information of table.When query result is saved as cache object, the query result derived data table can also be preserved simultaneously Version information as the corresponding tables of data version information of cache object.Here first version information is that cache object is corresponding Tables of data version information, and second edition information, when being this inquiry, as the tables of data version of current data table in database Information.In one embodiment, first version information can be stored in buffer zone as a part for cache object.
In one embodiment, it for second edition information, can determine in the presence of corresponding with the query argument In the case of cache object, read from database.
In another embodiment, it can also be obtained from database according to scheduled first time interval (such as 10 minutes) The version information of current data table, which is stored in, to be locally configured in table.In this way, can determine in the presence of opposite with the query argument In the case of the cache object answered, acquisition second edition information is locally configured in table from described, to avoid in query process to Database causes stress.Wherein, the process of the version information of current data table is obtained from database can be and data query Flow mutually execute side by side, in other words, can by scheduled first time interval no matter either with or without data query is carried out The version information of current data table is obtained from database.Optionally, in the version letter for obtaining current data table from database After breath, it can also first detect the version information of acquired current data table and the current data table preserved in table is locally configured Whether version information is consistent;And in the case of inconsistencies, this is updated according to the version information of acquired current data table The version information of current data table in ground allocation list.Here, table, which is locally configured, can be located at buffer zone, can also be located at other Storage region, the application are not construed as limiting this.
In some possible designs, database includes tables of data repository, and tables of data repository is used for the first data Table and the second tables of data are configured to one and are used as current data table, remaining is as Backup Data table.As shown in figure 3, data configuration Library 31 can be document, can be table, can also be that a subdata base in above-mentioned database, the application do not limit. Data configuration library 31 can record the data table information of the first tables of data 32 and the second tables of data 33, such as may include tables of data Name, data table status (current data table or Backup Data table are identified with 0,1 in Fig. 3), timestamp etc..
Tables of data repository can be provided with predetermined condition, when predetermined condition meets, tables of data repository switching first The current data table and Backup Data table status of tables of data and the second tables of data.In this way, according to scheduled first time interval from The version information of acquisition current data table includes just in database:The version letter of current data table is obtained from tables of data repository Breath.Tables of data repository can indicate the configuration status of tables of data by status indicator etc., for example, the tables of data repository of Fig. 3 In 31, the status indicator position of the first tables of data is 0, indicates that the first tables of data is configured as current data table, the second tables of data Status indicator position is 1, and the second tables of data of mark is configured as Backup Data table.
In one embodiment, predetermined condition may include:Complete the update of Backup Data table.It can be in Backup Data table Backup Data table is switched to current data table when update is completed, for example, being switched to the feelings of tables of data tb_0 in current data table Under condition, start to update the data table tb_1, tables of data tb_1 updates are completed, i.e., tables of data tb_1 are switched to current data table, opened Begin to update the tables of data tb_0 for being switched to Backup Data table.In this way, the real-time higher of current data table can be made.
In another embodiment, predetermined condition may include:Meet the second time interval of tables of data switching.For example, Preliminary setting data table switching the second time interval, such as 24 hours, then each current data table using 24 hours when be switched For Backup Data table.In this way, it is noon before that day 19 that inquiry can be made, which to have certain rule, the data such as inquired every time,:00 Preceding data.
In yet another embodiment, predetermined condition may include:There is predetermined mistake in current data table.Since tables of data passes through Cross the data increment analyzed under line or full dose update, the problem of for being likely to occur during on-line checking can not full forecast, It is possible that the case where current data table corrupt data.In practice, can in current data table use client it is various Business is monitored, in the case where traffic fluctuations exceed preset range, it is believed that current data table corrupt data.At this point it is possible to It configures current data table to Backup Data table, and the Backup Data table that preceding primary switching comes is reconfigured for current data Table.
In more embodiments, can also have one that more are used to configure in the first tables of data and the second tables of data is The predetermined condition of current data table.
Then, in step 24, judge the consistency of first version information and second edition information.
Judgement to the consistency of first version information and second edition information, the purpose is to cache object and database Whether the data in middle current data table are unanimously judged.The content for including according to version information can believe first version Breath and second edition information are compared, if just the same, it is determined that first version information is consistent with second edition information , otherwise, the two is inconsistent.
Then, in step 25, under first version information and second edition information unanimous circumstances, by above-mentioned cache object As query result.
If first version information is consistent with second edition information, illustrate cache object preservation is from database The query result that the data inquired in current data table generate, even if being inquired once from the current tables of data again, generation is looked into It askes result and the cache object is also consistent, it therefore, can be directly using the cache object as query result.
In this way, can be by verifying the data cached consistency with current data table data, to ensure to obtain from caching Data be correct, to further increase the validity of data query.
According to a kind of embodiment, cache object corresponding with above-mentioned query argument is not present in buffer zone, or In the case that person's first version information and second edition information are inconsistent, the flow of the data query can also include:
Step 26:According to query argument to data base querying current data table.Can to data base querying current data table, To obtain and the relevant data of query argument, such as business record.For example, it is assumed that query argument include time parameter " most Nearly 5 days ", platform parameters " certain payment platform ", type parameter " expenditure ", target component " amount of money ", then can be according to current time On May 10th, 2018, the expenditure record on May 5th, 2018 to May 9 into data base querying current data table.
Step 27, according to the data returned from database, query result is generated.In practice, database may be provided only and be looked into Function is ask, without having computing capability, therefore the data possibility returned from database can be directly as query result, it is also possible to It needs to be further processed and could be used as query result.In the case where needing to be further processed the data returned from database, Data process method can be determined according to query argument, then generate query result according to data process method processing data. Again referring to the example above, query argument includes time parameter " nearest 5 days ", platform parameters " certain payment platform ", type parameter " branch Go out ", target component " amount of money ", database return data be on May 5th, 2018 to May 9 expenditure record, it is determined that Data process method can be the accumulative summation of the amount of money in the expenditure record by May 5th, 2018 to May 9, thus generate most The total value of nearly 5 days amounts paid in payment platform is as query result.
In this way, finding that there is no cache object corresponding with query argument or existing cachings pair for buffer zone In the case of being generated not according to the data of database current data table, then data are obtained from database in time, generates inquiry As a result, maintaining the good experience of user.
In a possible design, after generating query result, further include:
Step 28, according to the cache object in the query result update buffer zone generated.
In one embodiment, cache object corresponding with query argument is not present in buffer zone, can be by this number It is added in buffer zone as cache object according to the query result of query generation.At this point, can also be by the version of current data table This information preservation is the version information of the cache object, so that subsequent query uses.
In another embodiment, there is cache object corresponding with query argument in buffer zone, but first version is believed Breath and second edition information are inconsistent, that is, existing cache object generates not according to the data of database current data table 's.In this case it is opposite with query argument with buffer zone that the generated query result of this inquiry can further be detected Whether the cache object answered is consistent, its version information is unanimously then updated to the version information of current database, inconsistent, uses This is inquired generated query result and replaces former cache object, while replacing former caching pair with the version information of current database The version information of elephant.Alternatively, former cache object can be deleted, the query result that this data query is generated is as cache object It is added in buffer zone.
In this way, in the case where receiving the inquiry request comprising same queries parameter next time, it can be first from buffer area The updated cache object is inquired in domain, and compares database this newer version information is inquired with this next time when Whether the version information of current data table is consistent, and the updated cache object is directly taken under unanimous circumstances as inquiry As a result, forming good circulation.
Above procedure is looked back, after receiving inquiry request, detects to whether there is in buffer zone and be wrapped with inquiry request The corresponding cache object of query argument contained is sentenced in the case where there is cache object corresponding with above-mentioned query argument The consistency of the second edition information of current data table in the first version information and database of disconnected cache object, if unanimously, Using cache object as query result.In this way, data cached and current data table data consistency can be verified, with ensure from The data obtained in caching are correct, to improve the validity of data query.
According to the embodiment of another aspect, a kind of device of data query is also provided.Fig. 4 is shown according to one embodiment The schematic block diagram of device for data query.As shown in figure 4, the device 400 for data query includes:Receiving unit 41, it is configured to receive inquiry request, wherein inquiry request includes query argument;Detection unit 42 is configured to detection buffer zone It is interior to whether there is cache object corresponding with query argument;Acquiring unit 43 is configured in the presence of corresponding with query argument Cache object in the case of, obtain first version information and second edition information, wherein first version information is cache object Corresponding tables of data version information, second edition information is the version information of current data table in database, wherein in database It is at least stored with the first tables of data and the second tables of data, the first tables of data and the second tables of data are configured as one and are used as current number According to table, remaining is as Backup Data table;Comparison unit 44 is configured to judge that first version information is consistent with second edition information Property;Determination unit 45 is configured under first version information and second edition information unanimous circumstances, above-mentioned cache object is made For query result.
Embodiment according to one aspect, device 400 further include version querying unit (not shown), are configured to:According to One time interval obtains the version information of current data table from database;Using the version information of current data table as the second edition This information preservation is in being locally configured table.In this way, acquiring unit 43 directly can get the second edition from being locally configured in table Information.To avoid causing database pressure to database request data in query process.In one embodiment, current data The version information of table include it is following in it is one or more:Table name, version identifier, timestamp.
Further, in one embodiment, which is additionally configured to:
The version information of the acquired current data table of detection and the version that the current data table preserved in table is locally configured Whether information is consistent;And
In the case of inconsistencies, it is locally configured in table according to the update of the version information of acquired current data table current The version information of tables of data.
Table is locally configured in this way, can only be updated when the version information of database current data table changes.Here, Table, which is locally configured, can be located at buffer zone, can also be located at other storage regions, and the application is not construed as limiting this.
According to a kind of possible design, database may include tables of data repository, and tables of data repository is used for first Tables of data and the second tables of data are configured to one and are used as current data table, remaining is as Backup Data table.Tables of data repository can To indicate the configuration status of the first tables of data and the second tables of data by status indicator position.Tables of data repository can be stored with pre- Fixed condition switches current data table and Backup Data table-like in the first tables of data and the second tables of data when predetermined condition meets State.At this point, version querying unit is additionally configured to:The version information of current data table is obtained from tables of data repository.
In one embodiment, above-mentioned predetermined condition includes at least one of the following:Complete the update of Backup Data table; Meet the second time interval of tables of data switching;There is predetermined mistake in current data table.
In one embodiment, device 400 further include:
Query unit 46 is configured to there is no cache object corresponding with above-mentioned query argument or first versions In the case that information and second edition information are inconsistent, according to query argument to data base querying current data table, with obtain with The relevant data of query argument, such as business record.
Generation unit 47 is configured to, according to the data returned from database, generate query result.It is needing to from database In the case that the data of return are further processed, generation unit 47 can determine data process method according to query argument, then Query result is generated according to data process method processing data.
In a possible design, device 400 further includes updating unit 48, is configured to:
After generation unit 47 generates query result, according to the caching in the query result update buffer zone generated Object.Specifically:In the case that cache object corresponding with query argument is not present in buffer zone, updating unit 48 can incite somebody to action The query result of generation is added to as cache object in buffer zone, and the version information of current data table is saved as this and is delayed Deposit the version information of object;There is cache object corresponding with query argument, but first version information and second in buffer zone In the case that version information is inconsistent, updating unit 48 can further detect this and inquire generated query result and caching Whether cache object corresponding with query argument is consistent in region, its version information is then unanimously updated to current database Version information, it is inconsistent, replace former cache object with this generated query result of inquiry, while with current database Version information replaces the version information of former cache object.Alternatively, updating unit 48 can delete former cache object, by this data The query result of query generation is added to as cache object in buffer zone.
By apparatus above, data cached and current data table data consistency can be verified, to ensure from caching The data of acquisition are correct, to improve the validity of data query.
According to the embodiment of another aspect, a kind of computer readable storage medium is also provided, is stored thereon with computer journey Sequence enables computer execute method described in conjunction with Figure 2 when the computer program executes in a computer.
According to the embodiment of another further aspect, a kind of computing device, including memory and processor, the memory are also provided In be stored with executable code, when the processor executes the executable code, realize the method in conjunction with described in Fig. 2.
Those skilled in the art are it will be appreciated that in said one or multiple examples, work(described in the invention It can be realized with hardware, software, firmware or their arbitrary combination.It when implemented in software, can be by these functions Storage in computer-readable medium or as on computer-readable medium one or more instructions or code be transmitted.
Above-described specific implementation mode has carried out further the purpose of the present invention, technical solution and advantageous effect It is described in detail, it should be understood that the foregoing is merely the specific implementation mode of the present invention, is not intended to limit the present invention Protection domain, all any modification, equivalent substitution, improvement and etc. on the basis of technical scheme of the present invention, done should all Including within protection scope of the present invention.

Claims (22)

1. a kind of method of data query, including:
Receive inquiry request, wherein the inquiry request includes query argument;
It detects and whether there is cache object corresponding with the query argument in buffer zone;
In the case where there is cache object corresponding with the query argument, first version information and second edition letter are obtained Breath, the first version information is the corresponding tables of data version information of the cache object, and the second edition information is data The version information of current data table in library, wherein the first tables of data and the second tables of data are at least stored in the database, institute It states the first tables of data and the second tables of data is configured as the conduct current data table, remaining is as Backup Data table;
Judge the consistency of first version information and second edition information;
Under the first version information and second edition information unanimous circumstances, using the cache object as query result.
2. according to the method described in claim 1, the method further includes:
There is no cache object corresponding with the query argument or the first version information and second edition information In the case of inconsistent,
According to the query argument to current data table described in the data base querying;
According to the data returned from the database, query result is generated.
3. according to the method described in claim 2, wherein, after generating query result, further including:
According to the cache object in the query result update buffer zone generated.
4. according to the method described in claim 3, wherein, updating the caching pair in buffer zone according to the query result generated As including:
It is added to the query result of generation as cache object in the buffer zone;
The version information of the current data table is saved as to the version information of the cache object.
5. according to the method described in claim 1, wherein, the method further includes:
The version information of current data table is obtained from database according to first time interval;
The version information of current data table is stored in and is locally configured in table.
6. according to the method described in claim 5, wherein, the acquisition first version information and second edition information include:
The second edition information is obtained from described be locally configured in table.
7. according to the method described in claim 5, wherein, the version information of current data table being stored in be locally configured in table and is wrapped It includes:
The version information of the acquired current data table of detection and the version information that the current data table preserved in table is locally configured It is whether consistent;And
In the case of inconsistencies, current data in table is locally configured according to the update of the version information of acquired current data table The version information of table.
8. according to the method described in claim 5, wherein, the database includes tables of data repository, the tables of data configures Library is used for, and when predetermined condition meets, switches current data table and Backup Data table-like in the first tables of data and the second tables of data State;
The version information for obtaining current data table from database according to first time interval includes:
The version information of current data table is obtained from the tables of data repository.
9. according to the method described in claim 8, wherein, the predetermined condition includes at least one of the following:
Complete the update of Backup Data table;
Meet the second time interval of tables of data switching;
There is predetermined mistake in current data table.
10. according to the method described in claim 1, wherein, the version information of current data table include it is following in one or more :Version identifier, timestamp.
11. a kind of device of data query, including:
Receiving unit is configured to receive inquiry request, wherein the inquiry request includes query argument;
Detection unit is configured to whether there is cache object corresponding with the query argument in detection buffer zone;
Acquiring unit is configured to, in the case where there is cache object corresponding with the query argument, obtain first version Information and second edition information, the first version information are the corresponding tables of data version informations of the cache object, described Two version informations are the version informations of current data table in database, wherein being at least stored with the first tables of data in the database With the second tables of data, first tables of data and the second tables of data are configured as the conduct current data table, remaining work For Backup Data table;
Comparison unit is configured to judge the consistency of first version information and second edition information;
Determination unit is configured under the first version information and second edition information unanimous circumstances, by the caching pair As query result.
12. according to the devices described in claim 11, further including:
Query unit, be configured to there is no cache object corresponding with the query argument or the first version letter In the case that breath and second edition information are inconsistent,
According to the query argument to current data table described in the data base querying;
Generation unit is configured to, according to the data returned from the database, generate query result.
13. device according to claim 12, wherein further include updating unit, be configured to:
After the generation unit generates query result, according to the caching pair in the query result update buffer zone generated As.
14. device according to claim 13, wherein the updating unit is further configured to:
It is added to the query result of generation as cache object in the buffer zone;
The version information of the current data table is saved as to the version information of the cache object.
15. according to the devices described in claim 11, wherein further include version querying unit, be configured to:
The version information of current data table is obtained from database according to first time interval;
The version information of current data table is stored in and is locally configured in table.
16. device according to claim 15, wherein the acquiring unit is further configured to:
The second edition information is obtained from described be locally configured in table.
17. device according to claim 15, wherein the version querying unit is additionally configured to:
The version information of the acquired current data table of detection and the version information that the current data table preserved in table is locally configured It is whether consistent;And
In the case of inconsistencies, current data in table is locally configured according to the update of the version information of acquired current data table The version information of table.
18. device according to claim 15, wherein the database includes tables of data repository, and the tables of data is matched It sets library to be used for, when predetermined condition meets, switches current data table and Backup Data table in the first tables of data and the second tables of data State;
The version querying unit is additionally configured to:
The version information of current data table is obtained from the tables of data repository.
19. device according to claim 18, wherein the predetermined condition includes at least one of the following:
Complete the update of Backup Data table;
Meet the second time interval of tables of data switching;
There is predetermined mistake in current data table.
20. according to the devices described in claim 11, wherein the version information of current data table include it is following in one or more :Version identifier, timestamp.
21. a kind of computer readable storage medium, is stored thereon with computer program, when the computer program in a computer When execution, computer perform claim is enabled to require the method for any one of 1-10.
22. a kind of computing device, including memory and processor, which is characterized in that be stored with executable generation in the memory Code when the processor executes the executable code, realizes the method described in any one of claim 1-10.
CN201810473920.3A 2018-05-17 2018-05-17 Data query method and device Active CN108647357B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810473920.3A CN108647357B (en) 2018-05-17 2018-05-17 Data query method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810473920.3A CN108647357B (en) 2018-05-17 2018-05-17 Data query method and device

Publications (2)

Publication Number Publication Date
CN108647357A true CN108647357A (en) 2018-10-12
CN108647357B CN108647357B (en) 2023-01-31

Family

ID=63756525

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810473920.3A Active CN108647357B (en) 2018-05-17 2018-05-17 Data query method and device

Country Status (1)

Country Link
CN (1) CN108647357B (en)

Cited By (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109933585A (en) * 2019-02-22 2019-06-25 京东数字科技控股有限公司 Data query method and data query system
CN110413679A (en) * 2019-07-31 2019-11-05 深圳前海微众银行股份有限公司 Database information processing method, device, equipment and readable storage medium storing program for executing
CN111104692A (en) * 2019-12-12 2020-05-05 中国平安人寿保险股份有限公司 Data request processing method, related equipment and computer-readable storage medium
CN112084210A (en) * 2020-09-28 2020-12-15 中国建设银行股份有限公司 Data processing method and device, electronic equipment and storage medium
CN112883307A (en) * 2021-02-03 2021-06-01 深圳市大成天下信息技术有限公司 Cache updating method and device and social network system
CN113377874A (en) * 2021-06-28 2021-09-10 上海浦东发展银行股份有限公司 Data synchronization processing method and device, electronic equipment and storage medium
CN113377811A (en) * 2020-03-09 2021-09-10 阿里巴巴集团控股有限公司 Database query method and system
CN113407639A (en) * 2021-07-16 2021-09-17 广州市百果园信息技术有限公司 Data processing method, device, system and storage medium
CN114490781A (en) * 2022-04-01 2022-05-13 中国信息通信研究院 Block chain data processing method and device
CN114676165A (en) * 2022-03-30 2022-06-28 北京达佳互联信息技术有限公司 Data query method and device, electronic equipment and computer readable medium

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1324075A (en) * 2000-04-14 2001-11-28 索尼公司 Method and device for data reproducing, method and device for data recording
US20080307408A1 (en) * 2007-06-11 2008-12-11 Anil Saldhana Update system to synchronize changes from external sources for a java virtual machine
CN105095313A (en) * 2014-05-22 2015-11-25 阿里巴巴集团控股有限公司 Data access method and equipment
WO2016117007A1 (en) * 2015-01-19 2016-07-28 株式会社日立製作所 Database system and database management method
CN106294461A (en) * 2015-06-01 2017-01-04 阿里巴巴集团控股有限公司 Data lead-in method and device
CN107122410A (en) * 2017-03-29 2017-09-01 武汉斗鱼网络科技有限公司 A kind of buffering updating method and device
CN107133234A (en) * 2016-02-29 2017-09-05 阿里巴巴集团控股有限公司 The method of data cached renewal, apparatus and system
CN107153683A (en) * 2017-04-24 2017-09-12 泰康保险集团股份有限公司 The method and apparatus for realizing data query

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1324075A (en) * 2000-04-14 2001-11-28 索尼公司 Method and device for data reproducing, method and device for data recording
US20080307408A1 (en) * 2007-06-11 2008-12-11 Anil Saldhana Update system to synchronize changes from external sources for a java virtual machine
CN105095313A (en) * 2014-05-22 2015-11-25 阿里巴巴集团控股有限公司 Data access method and equipment
WO2016117007A1 (en) * 2015-01-19 2016-07-28 株式会社日立製作所 Database system and database management method
CN106294461A (en) * 2015-06-01 2017-01-04 阿里巴巴集团控股有限公司 Data lead-in method and device
CN107133234A (en) * 2016-02-29 2017-09-05 阿里巴巴集团控股有限公司 The method of data cached renewal, apparatus and system
CN107122410A (en) * 2017-03-29 2017-09-01 武汉斗鱼网络科技有限公司 A kind of buffering updating method and device
CN107153683A (en) * 2017-04-24 2017-09-12 泰康保险集团股份有限公司 The method and apparatus for realizing data query

Cited By (16)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109933585B (en) * 2019-02-22 2021-11-02 京东数字科技控股有限公司 Data query method and data query system
CN109933585A (en) * 2019-02-22 2019-06-25 京东数字科技控股有限公司 Data query method and data query system
CN110413679B (en) * 2019-07-31 2023-01-24 深圳前海微众银行股份有限公司 Database information processing method, device, equipment and readable storage medium
CN110413679A (en) * 2019-07-31 2019-11-05 深圳前海微众银行股份有限公司 Database information processing method, device, equipment and readable storage medium storing program for executing
CN111104692A (en) * 2019-12-12 2020-05-05 中国平安人寿保险股份有限公司 Data request processing method, related equipment and computer-readable storage medium
CN113377811A (en) * 2020-03-09 2021-09-10 阿里巴巴集团控股有限公司 Database query method and system
CN112084210A (en) * 2020-09-28 2020-12-15 中国建设银行股份有限公司 Data processing method and device, electronic equipment and storage medium
CN112084210B (en) * 2020-09-28 2024-08-20 中国建设银行股份有限公司 Data processing method, device, electronic equipment and storage medium
CN112883307A (en) * 2021-02-03 2021-06-01 深圳市大成天下信息技术有限公司 Cache updating method and device and social network system
CN112883307B (en) * 2021-02-03 2023-10-20 深圳市大成天下信息技术有限公司 Cache updating method and device and social network system
CN113377874A (en) * 2021-06-28 2021-09-10 上海浦东发展银行股份有限公司 Data synchronization processing method and device, electronic equipment and storage medium
CN113407639A (en) * 2021-07-16 2021-09-17 广州市百果园信息技术有限公司 Data processing method, device, system and storage medium
CN113407639B (en) * 2021-07-16 2024-05-14 广州市百果园信息技术有限公司 Data processing method, device, system and storage medium
CN114676165A (en) * 2022-03-30 2022-06-28 北京达佳互联信息技术有限公司 Data query method and device, electronic equipment and computer readable medium
CN114490781A (en) * 2022-04-01 2022-05-13 中国信息通信研究院 Block chain data processing method and device
CN114490781B (en) * 2022-04-01 2022-07-22 中国信息通信研究院 Block chain data processing method and device

Also Published As

Publication number Publication date
CN108647357B (en) 2023-01-31

Similar Documents

Publication Publication Date Title
CN108647357A (en) The method and device of data query
US10339038B1 (en) Method and system for generating production data pattern driven test data
CN107220142B (en) Method and device for executing data recovery operation
US10089334B2 (en) Grouping of database objects
CN108595563A (en) A kind of data quality management method and device
US8478797B2 (en) Atomic deletion of database data categories
US20060093113A1 (en) Collecting and delivering call data associated with court ordered traps
CN113420026B (en) Database table structure changing method, device, equipment and storage medium
CN107798037A (en) The acquisition methods and server of user characteristic data
GB2574282A (en) Data consistency verification method and system minimizing load of original database
CN110188103A (en) Data account checking method, device, equipment and storage medium
CN110245145A (en) Structure synchronization method and apparatus of the relevant database to Hadoop database
CA3167981C (en) Offloading statistics collection
CN114328566A (en) Relationship graph updating method, device, medium, equipment and generating method
KR101737578B1 (en) Method and device for automatically tuning for sql sentences generated automatically
WO2022057525A1 (en) Method and device for data retrieval, electronic device, and storage medium
CN108549714B (en) Data processing method and device
CN111523921B (en) Funnel analysis method, analysis device, electronic device, and readable storage medium
CN110502529B (en) Data processing method, device, server and storage medium
US20160125026A1 (en) Proactive query migration to prevent failures
CN115809304A (en) Method and device for analyzing field-level blood margin, computer equipment and storage medium
JP6748474B2 (en) Decision support system and decision support method
CN112800127B (en) Data mining analysis method and device based on transaction bill
US20210342319A1 (en) Duplicate table identification in enterprise database systems for data storage optimization
CN116703184B (en) Data processing method, data processing device, electronic equipment and readable storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
TA01 Transfer of patent application right
TA01 Transfer of patent application right

Effective date of registration: 20201022

Address after: Cayman Enterprise Centre, 27 Hospital Road, George Town, Grand Cayman Islands

Applicant after: Innovative advanced technology Co.,Ltd.

Address before: Cayman Enterprise Centre, 27 Hospital Road, George Town, Grand Cayman Islands

Applicant before: Advanced innovation technology Co.,Ltd.

Effective date of registration: 20201022

Address after: Cayman Enterprise Centre, 27 Hospital Road, George Town, Grand Cayman Islands

Applicant after: Advanced innovation technology Co.,Ltd.

Address before: A four-storey 847 mailbox in Grand Cayman Capital Building, British Cayman Islands

Applicant before: Alibaba Group Holding Ltd.

GR01 Patent grant
GR01 Patent grant