CN104035923A - Data inquiry method and device - Google Patents

Data inquiry method and device Download PDF

Info

Publication number
CN104035923A
CN104035923A CN201310067958.8A CN201310067958A CN104035923A CN 104035923 A CN104035923 A CN 104035923A CN 201310067958 A CN201310067958 A CN 201310067958A CN 104035923 A CN104035923 A CN 104035923A
Authority
CN
China
Prior art keywords
inquiry request
query
request
database
current
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
CN201310067958.8A
Other languages
Chinese (zh)
Other versions
CN104035923B (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.)
Alibaba Group Holding 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 CN201310067958.8A priority Critical patent/CN104035923B/en
Publication of CN104035923A publication Critical patent/CN104035923A/en
Application granted granted Critical
Publication of CN104035923B publication Critical patent/CN104035923B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2455Query execution

Abstract

The invention discloses a data inquiry method and device. The data inquiry method comprises the steps of intercepting a current inquiry request; judging whether a historical inquiry request the same as the current inquiry request executes database inquiry operation or not; blocking the current inquiry request if historical inquiry request executes the database inquiry operation; utilizing and returning an inquiry result to the current inquiry request after the execution of the historical inquiry request is finished. In the achieving process, the situation that the same inquiry requests are repeatedly submitted to a database while one-time database inquiry operation is executed does not occur, the visiting burden of the database is effectively relieved, and the inquiry efficiency is improved.

Description

The method of data query and device
Technical field
The application relates to data query technique field, particularly relates to method and the device of data query.
Background technology
Under high concurrent environment, be easy to occur following situation: in section, a large number of users causes database pressure to increase to the concurrent inquiry of Database Systems at one time, and response is slow, and then affects the normal operation of whole system.But find in practice, it is all same in a large amount of inquiry request, having a lot.For example, user clicks website homepage, if need the part or all of data of showing to come from database above homepage, most contents is duplicate for user, for background server, it is also the same needing the database query operations of carrying out.
Based on this feature, in order to improve the effect of data query, in prior art, generally can adopt buffer memory to deal with, also be, if two inquiries that client is submitted to are duplicate, the previous Query Result of server end meeting buffer memory, and directly the Query Result of buffer memory is returned to next identical inquiry, thus reduce the access to database.Because internal memory is higher than the read-write efficiency of database, so for the client of initiating same request, the response time can shorten greatly.
But, although in prior art, use buffering scheme,, within the still unfounded time period of buffer memory, all inquiry request all can indistinguishably be submitted to lane database.If query time is longer, the interior concurrent request producing is also enough to make database performance rapid drawdown so during this period of time, therefore, the problem that database burden is overweight still can often occur.
Summary of the invention
The application provides method and the device of data query, can avoid database to cause unnecessary burden, is conducive to improve search efficiency.
The application provides following scheme:
A method for data query, comprising:
Tackle current inquiry request;
Judge whether to exist the historical query request identical with this current inquiry request carrying out the operation of Query Database;
If so, block described current inquiry request;
After described historical query request is complete, utilize its Query Result to return to Query Result to described current inquiry request.
A device for data query, comprising:
Request interception unit, for tackling current inquiry request;
Judging unit, exists the historical query request identical with this current inquiry request carrying out the operation of Query Database for judging whether;
Unit is blocked in request, if be yes for the judged result of judging unit, blocks described current inquiry request;
Query Result returns to unit, for after described historical query request is complete, utilizes its Query Result to return to Query Result to described current inquiry request.
The specific embodiment providing according to the application, the application discloses following technique effect:
Pass through the application, after intercepting a data base querying request, can first judge whether to exist identical inquiry request carrying out the operation of Query Database, if existed, this current inquiry request can be blocked, no longer be submitted to database and inquired about, after carrying out the inquiry request acquisition Query Result of Query Database operation by the time, recycle this Query Result and return to Query Result to current inquiry request.Therefore, in implementation procedure, there will not be in the process of carrying out at one query database manipulation, have again identical inquiry request to repeat to be submitted to the situation of database, therefore, alleviated the access burden of database, be conducive to improve search efficiency.
Certainly, arbitrary product of enforcement the application might not need to reach above-described all advantages simultaneously.
Brief description of the drawings
In order to be illustrated more clearly in the embodiment of the present application or technical scheme of the prior art, to the accompanying drawing of required use in embodiment be briefly described below, apparently, accompanying drawing in the following describes is only some embodiment of the application, for those of ordinary skill in the art, do not paying under the prerequisite of creative work, can also obtain according to these accompanying drawings other accompanying drawing.
Fig. 1 is the process flow diagram of the method that provides of the embodiment of the present application;
Fig. 2 is the process flow diagram of the other method that provides of the embodiment of the present application;
Fig. 3 is the schematic diagram of the device that provides of the embodiment of the present application.
Embodiment
Below in conjunction with the accompanying drawing in the embodiment of the present application, the technical scheme in the embodiment of the present application is clearly and completely described, obviously, described embodiment is only some embodiments of the present application, instead of whole embodiment.Based on the embodiment in the application, the every other embodiment that those of ordinary skill in the art obtain, belongs to the scope that the application protects.
Present inventor finds in the process that realizes the application, in the buffering scheme of prior art, why still database loads can be produced overweight, the not high problem of inquiry effect, reason is in prior art, often to have following situation on the one hand: if data base querying request A is in the time carrying out, finding does not have corresponding Query Result in buffer memory, it can be carried out by database immediately, also carries out the operation of Query Database, obtains Query Result; But, if there is new inquiry A1 submitted in implementation, no matter whether the content of A1 request is identical with the content of A request, A1 equally also can be carried out immediately, so just cause at A and A1 and ask when identical, two requests all can be performed, and until A has inquired about and buffered results, follow-up new request could utilize cache contents.That is to say by the time to have at least an inquiry return to Query Result and deposit in buffer memory, just can make follow-up inquiry can utilize buffer memory improving performance; And if before first Query Result returns, there are other same inquiries simultaneously, owing to can using without buffer memory, all inquiries all can start anew carry out, and in fact inquiry content be the same, this has obviously increased the burden of Database Systems.
For this reason, the embodiment of the present application provides a kind of method of data query, and referring to Fig. 1, the method can comprise the following steps:
S101: tackle current inquiry request;
In the embodiment of the present application, can tackle operation to inquiry request at server end, also be, after receiving a data base querying request, directly be submitted to database to inquire about, process operation but first carry out some judgements, determine whether again that afterwards need to be submitted to database inquires about.
S102: judge whether to exist the historical query request identical with this current inquiry request carrying out the operation of Query Database;
Specifically, in the time carrying out decision operation, can first judge in buffer memory whether had the Query Result relevant to this inquiry request, if existed, directly from buffer memory, take out Query Result and return.If also there is no Query Result in buffer memory, the embodiment of the present application is not directly inquiry request to be submitted to database to carry out query manipulation, but further judge the operation that whether exists the historical query request identical with this current inquiry request carrying out Query Database, if existed, no longer this request being submitted to database inquires about, the Query Result of directly waiting for the current inquiry request of carrying out, can reduce the access to database like this, alleviates the burden of database.
Particularly, for in the time intercepting an inquiry request, judge the operation that whether exists the historical query request identical with this current inquiry request carrying out Query Database, the embodiment of the present application can be preserved the information of the inquiry request of carrying out in buffer memory, for example check information, this check information can be corresponding query statement signing messages (for example, MD5 value etc.), like this after receiving new inquiry request, just can first calculate the signing messages of the query statement of current inquiry request, obtain the check information of current inquiry request, and judge in buffer memory, whether there is the content of mating with the check information of current inquiry request, if existed, determine and exist the historical query request identical with this current inquiry request to carry out.
That is to say, after intercepting an inquiry request, can first do MD5 signature according to the query statement of this inquiry request, (diges is character string t) to calculate informative abstract, then judge the content whether existing in buffer memory with this diges t string matching, if there is no, proving does not have identical inquiry request to carry out, and then, just digest character string corresponding this inquiry request can be kept in buffer memory, for example, the mapping that JAVA the inside specifically can utilize concurrent Hash table (ConcurrentHashMap) to preserve diges t and query statement, so just this inquiry request can be submitted to database and carry out query manipulation.If have again identical inquiry request to be blocked then follow-up, just can utilize the digest character string of calculating the inquiry request making new advances, then by with buffer memory in the content of preserving compare, just can judge and exist identical inquiry request just at performing database query manipulation.
It should be noted that, for each identical inquiry request, only need to be in the time that first inquiry request be submitted to database and carries out query manipulation, to the check information that writes inquiry request in buffer memory, follow-up inquiry request is blocked then again, if there is the content identical with its check information in buffer memory, do not need to re-write again buffer memory, do not need performing database query manipulation yet.
It should be noted that in addition, the query statement of inquiry request is generally certain text with ad hoc rules combination, and also having minority is binary data.Therefore, can do MD5 signature based on whole query statement, calculate digest character string.According to the principle of MD5, can ensure in the situation that query statement is identical, the digest character string obtaining is identical, therefore, if find that digest character string corresponding to two inquiry request is identical, just can prove that two inquiry request have identical query statement, that is to say, these two inquiry request are identical.
Certainly, in actual applications, can also there be other two implementations whether inquiry request is identical that judge, for example, directly in buffer memory, preserve query statement, or, query statement is carried out to other summary processing, the summary info that preservation obtains, etc., describe in detail no longer one by one here.
S103: if block described current inquiry request;
If find to exist the inquiry request identical with current inquiry inquiry request carrying out the operation of Query Database, can, by current inquiry request obstruction, be no longer submitted to database and be inquired about, but waited for the Query Result of other same queries requests.That is to say, for identical inquiry request, the database query operations of execution is all identical, therefore, as long as one of them carries out the operation of concrete Query Database, does not need to repeat to submit to.Wherein, so-called current inquiry request is blocked, be equivalent to corresponding program jump to the Query Result of waiting for the inquiry request of carrying out on another object.Certainly, carry out in the process of inquiry an inquiry request, multiple identical inquiry request with it may be intercepted, now these inquiry request all can be blocked, until after this inquiry request obtains Query Result, reinform initiator corresponding to each identical inquiry request and arrive and extract corresponding Query Result.
Certainly,, if judge the operation that does not exist the inquiry request identical with current inquiry request carrying out Query Database, this current inquiry request can be submitted to database and carry out concrete query manipulation.Simultaneously, can also in buffer memory, preserve the check information of this current inquiry request, like this, if in the process of this current inquiry request performing database query manipulation, intercept again new inquiry request, just can, by the information in check information and the buffer memory of the new inquiry request of comparison, judge that whether new inquiry request is identical with current inquiry request, by that analogy.
S104: after described historical query request is complete, utilize its Query Result to return to Query Result to described current inquiry request.
After carrying out the inquiry request acquisition Query Result of Query Database operation, just can first Query Result be kept in buffer memory, in the time preserving, can be using the check information of this inquiry request as key assignments.And notify the initiator of other each same queries requests to extract Query Result in buffer memory.Therefore,, for the inquiry request getting clogged, after notified message, the inquiry request of carrying out Query Database operation before just meaning has completed inquiry, therefore, just can arrive the Query Result that finds corresponding key-value pair to answer in buffer memory.
Visible, in the embodiment of the present application, after intercepting a data base querying request, can first judge whether to exist identical inquiry request carrying out the operation of Query Database, if existed, this current inquiry request can be blocked, be no longer submitted to database and inquired about, by the time, after carrying out the inquiry request acquisition Query Result of Query Database operation, recycle this Query Result and return to Query Result to current inquiry request.Therefore, in implementation procedure, there will not be in the process of carrying out at one query database manipulation, have again identical inquiry request to repeat to be submitted to the situation of database, therefore, alleviated the access burden of database, be conducive to improve search efficiency.
As mentioned before, whether identical in order to judge two inquiry request, can be in the time that first inquiry request be submitted to database and inquires about, in buffer memory, preserve corresponding check information, then after second inquiry request is blocked, just can pass through Inspection information, judge that whether both are identical.But, in actual applications, check information is write to buffer memory and also need the regular hour, and the situation that often exists multiple kernels to coexist in present hardware environment, make multiple instructions can parallel processing, two inquiry request may parallel processing in two kernels, therefore, realizing according to the application's said method in the process of data query, may there is following situation: the time interval of two inquiry request arrival may be Millisecond, even shorter, like this, when an inquiry request A is written to its check information in the process of buffer memory (writing not yet completely), another inquiry request B may just be blocked, now, inquiry request B is in the time of access cache, will find, in buffer memory, there is not the inquiry request identical with this inquiry request B, therefore, just may can carry out for this inquiry request B the operation that check information is write to buffer memory more yet, and this inquiry request B is also submitted to database inquires about, like this, just still may occur, in process that an inquiry request just inquiring about in database, having again an identical inquiry request to be submitted to the phenomenon that database is inquired about.
For fear of the generation of above-mentioned situation, further reduce the burden of database, improve the efficiency of data query, in unit situation, can ensure that each inquiry request writing the clerical atomicity of buffer memory by certain mechanism.So-called atomicity, just refers to affairs or is performed completely, or not being performed completely, there will not be in the process being not yet fully implemented affairs, is inserted into the phenomenon of another affairs.When specific implementation, in JAVA program, can utilize certain JAVA object locking, after only obtaining this lock, could carry out subsequent step.The lock of speech level can ensure by operating system, and two inquiry request A of sufficient to guarantee and B can not get lock simultaneously, thereby arranged sequencing just to inquiry request A, B, prevented from submitting to simultaneously.After inquiry request A completes certain operation, then release.After inquiry request B completes certain operation, also release, if there is more inquiry request, all does similar processing.Certainly,, if database is deployed under distributed environment, can use the distributed lock of zookeeper and so on to solve.
When specific implementation, often intercept an inquiry request, can first attempt locking the counter object of an appointment, only in the successful situation of locking, ability access cache, in the time of access cache, if find to have the content matching with the check information of oneself in buffer memory, can block self notice to wait for that historical query request completes; If there is not the content matching with the check information of oneself in discovery buffer memory, can carry out the operation that the check information of oneself is write to buffer memory, after all having write, then remove the locking to counter object.Only, after an inquiry request unlocks, other inquiry request could lock successfully, only could access cache after locking successfully.Like this, for follow-up inquiry request, even if not yet complete when check information is written to the operation of buffer memory in previous inquiry request, be just blocked, also can be because of cannot successfully locking cannot access cache, and then can be submitted to database yet and be inquired about.Therefore, even if also just ensured to have received multiple identical inquiry request within the very short time, also only have an inquiry request can be submitted to database and carry out query manipulation, other inquiry request all only needs to wait for its Query Result.
For example, first intercepted inquiry request A, if not yet receive before this identical with it inquiry request, necessarily successfully locked by meeting, the MD5 signature calculating is digest, now, query caching also can be found, does not have the content matching with this digest in buffer memory, therefore, just can in buffer memory, preserve following content: <digest, SQL_A>, and this inquiry request A is submitted to database carries out query manipulation.If in the very short time after intercepting inquiry request A, intercept again inquiry request B, and inquiry request B=inquiry request A, still, inquiry request B is blocked rear, in the time attempting the counter object of locking execution, can find to lock successfully, because be queried request A locking, until after the contents such as the digest of inquiry request A are written in buffer memory completely, just can unlock, now, inquiry request B just can lock successfully.After inquiry request B locks successfully, just can calculate the MD5 signature of inquiry request B, and can query caching, due to inquiry request B=inquiry request A, so the MD5 of inquiry request B signature is also diges t, so can seeing buffer memory the inside, inquiry request B has <digest, this record of SQL_A> exists, therefore, just can again inquiry request B be submitted to database.Although the database query operations that now inquiry request A is corresponding is not yet finished, in buffer memory, not yet have corresponding Query Result, inquiry request B knows has same inquiry to carry out, therefore, it can abandon carrying out itself, directly waits for the Query Result of inquiry request A.
In actual applications, the different data base querying quantity occurring in a period of time may be thousands of, all Query Result is cached to cost for a long time very high, therefore, after having applied the such scheme that the application provides, in the time that Query Result is carried out to buffer memory, can adopt following optimal way: if after inquiry request A is submitted to database, in the process of carrying out inquiry, receive again the inquiry request B identical with this inquiry request A, C, D, Query Result is being returned to inquiry request A, B, C, after D, just can be by <digest, this record of SQL_A> is deleted from buffer memory, and corresponding Query Result is also deleted.Like this, receive again new inquiry request E if follow-up, and also identical with inquiry request A,, owing to no longer preserving the Query Result of inquiry request A in buffer memory, therefore, still inquiry request E is submitted to database and inquires about.If receive again identical inquiry request F, G in the process of inquiry, just the Query Result of inquiry request E can be returned to the initiator of inquiry request F, G.
Certainly, in actual applications, under afore-mentioned, about the Query Result of inquiry request A, also can select to retain a period of time for follow-up same query calls.But the Data Update speed in database is generally than very fast, for the data that ensure to inquire are followed the renewal of database as much as possible, can adopt aforementioned manner, also be that inquiry request A is after obtaining Query Result, as long as after the new same queries request receiving in Query Database process at this inquiry request A all obtains Query Result, just Query Result can be deleted from buffer memory, follow-up while having again identical inquiry request, also again in database, inquire about the Query Result before not re-using.Can reduce to greatest extent like this error, promote data accuracy.If really need buffer memory a period of time, can come the independent buffer memory of Query Result with conventional buffering scheme.
According to scheme in the embodiment of the present application, if in the process of inquiry request A executing data library inquiry, receive again inquiry request B, C, D, need to, after Query Result is returned to inquiry request A, B, C, D, just this Query Result can have been deleted.In order to ensure before Delete query result, inquiry request A, B, C, D have obtained Query Result, the embodiment of the present application can be in the time that an inquiry request be submitted to database execution query manipulation, for the associated counter of this inquiry request, in the process of this inquiry request executing data library inquiry, intercept identical with it inquiry request at every turn, all the value of this counter is increased to a digit, until get Query Result; Getting after Query Result, every initiator to an inquiry request returns to Query Result, all the value of this counter is reduced to a Ge Ji digit, for example, in the time that the value of counter is reduced to preset value (being 0), determine that each inquiry request with identical check information has all obtained Query Result, now, just this Query Result can have been deleted.
For example, suppose that A, B, tri-identical inquiry request of C arrive application system, based on above-mentioned mechanism, the submitted database of inquiry request A is carried out actual queries, and inquiry request B, C wait for the Query Result of inquiry request A.Can safeguard an independent counter count for these inquiry request, inquiry request A obtains after synchrolock, and count adds 1, and after inquiry request B, C obtain synchrolock, count also adds 1 separately.So final count=3.
After inquiry request A Query Database, first Query Result a is kept in memory variable, then starts successively to return to this Query Result a to the initiator of inquiry request A, B, C.When the initiator of inquiry request A receives that after Query Result a, count subtracts 1, the initiator of inquiry request B subtracts 1 after receiving Query Result a again, and inquiry request C too.In the time of count=0, Query Result a just finishes mission, can delete.In the process of whole operation, count keeps atomicity, avoids makeing mistakes.
Finally it should be noted that, the embodiment of the present application is equivalent to pack one deck on common user function basis, mechanism such as having added interception to inquiry request, sentence weight, buffer memory, counting, Query Result buffer memory, notice return, finally reaches the object that improves search efficiency, reduces database burden.
The such scheme providing in order to understand better the embodiment of the present application, carries out more detailed introduction below by the example in a practical application.Referring to Fig. 2, the method can comprise the following steps:
S201: intercept inquiry request A;
S202: the query statement that obtains inquiry request A;
S203: attempt the object that locking is specified; If lock unsuccessfully, turn back to this step every the preset time interval and newly attempt, or, also can utilize the characteristic of program language itself first to block, then wait for operating system scheduling;
S204: if locked successfully, calculate the uniqueness mark a of the query statement of inquiry request A, such as MD5 signing messages etc.;
S205: read buffer memory, judge whether mark a exists in buffer memory; If so, enter step S206, otherwise enter step S211;
S206: take out and identify the associated counter countA of a, and by the value atomicity of countA add 1;
S207: wait for the notification message relevant to countA;
S208: after receiving notification message, from buffer memory, take out mark Query Result corresponding to a, and by the value atomicity of countA subtract 1;
S209: whether the value that judges countA is 0, if so, enters step S210, otherwise enters step S217;
S210: delete the Query Result relevant to mark a;
S211: atomicity mark a is kept in buffer memory, and an associated counter countA that value is 0;
S212: judge whether to preserve successfully, if so, enter step S213, otherwise enter step S206;
S213: inquiry request A is submitted to database and inquires about;
S214: Query Result is kept in buffer memory as key assignments to identify a;
S215: notify the inquiry request initiator of all a of being designated to extract Query Result in buffer memory;
S216: the mark a in buffer memory is deleted on atomicity ground, but does not reclaim counter countA;
S217: the initiator to inquiry request returns to Query Result.
The data enquire method providing with the embodiment of the present application is corresponding, and the embodiment of the present application also provides a kind of data query device referring to Fig. 3, and this device can comprise:
Request interception unit 301, for tackling current inquiry request;
Judging unit 302, exists the historical query request identical with this current inquiry request carrying out the operation of Query Database for judging whether;
Unit 303 is blocked in request, if be yes for the judged result of judging unit, blocks described current inquiry request;
Query Result returns to unit 304, for after described historical query request is complete, utilizes its Query Result to return to Query Result to described current inquiry request.
When specific implementation, this device can also comprise:
Request commit unit, is carrying out the operation of Query Database for if there is no identical with this current inquiry request historical query request, current inquiry request is submitted to database and carries out query manipulation.
Whether identical in order to judge two inquiry request, this device can also comprise:
Check information buffer unit, for preserving the check information of the inquiry request of carrying out, the signing messages that described check information is corresponding query statement at buffer memory;
Accordingly, described judging unit 302 can comprise:
Check information obtains subelement, for calculating the signing messages of query statement of current inquiry request, obtains the check information of current inquiry request;
Coupling subelement, for judging whether buffer memory exists the content of mating with the check information of current inquiry request, if existed, determines the operation that exists the historical query request identical with this current inquiry request carrying out Query Database.
When specific implementation, this device can also comprise:
Query Result buffer unit for when carrying out after the inquiry request of Query Database operation gets Query Result, using described check information as key assignments, is preserved Query Result in buffer memory;
Notification unit, the inquiry request initiator for notifying with identical check information extracts corresponding Query Result to buffer memory.
For in the time that multiple identical inquiry request successively arrive within the very short time, to avoid multiple queries request to be all submitted to database, this device can also comprise:
Atomicity holding unit, in query caching process, keeps the atomicity between each inquiry request.
When specific implementation, described atomicity holding unit can comprise:
Subelement is attempted in locking, for intercepting after described current inquiry request, attempts the counter object that locking is specified;
Whether caching query subelement, if for locking successfully, there is the content of mating with the check information of the inquiry request of intercepting in query caching;
Occluder unit, if for existing, determines and exists the historical query request identical with this current inquiry request to carry out, and blocks self notice to wait for that historical query request completes;
Latch-release subelement, for if there is no, the check information of this current inquiry request is written in buffer memory, after completing the operation that writes buffer memory, remove the locking to described appointment counter object, and this current inquiry request is submitted to database execution query manipulation.
In order to reduce to greatest extent error, promote data accuracy, this device can also comprise:
Delete cells for when having after the inquiry request of identical check information all obtains Query Result, is deleted this Query Result from buffer memory; The described inquiry request with identical check information is that an inquiry request is submitted in the process that database inquires about, the inquiry request identical with this inquiry request receiving.
In order whether effectively to judge each inquiry request all to obtain Query Result, this device can also comprise:
Counter associative cell, while carrying out query manipulation for be submitted to database when an inquiry request, is the associated counter object of this inquiry request;
Counter, from adding unit, for the process at this inquiry request executing data library inquiry, intercepts identical with it inquiry request at every turn, all the value of this counter is increased to a digit, until get Query Result;
Counter is from subtracting unit, and for getting after Query Result, every initiator to an inquiry request returns to Query Result, all the value of this counter is reduced to a digit;
Determining unit, in the time that the value of described counter is reduced to preset value, determines that each inquiry request with identical check information has all obtained Query Result.
In a word, in the said apparatus providing in the embodiment of the present application, after intercepting a data base querying request, can first judge whether to exist identical inquiry request carrying out the operation of Query Database, if existed, this current inquiry request can be blocked, be no longer submitted to database and inquired about, by the time, after carrying out the inquiry request acquisition Query Result of Query Database operation, recycle this Query Result and return to Query Result to current inquiry request.Therefore, in implementation procedure, there will not be in the process of carrying out at one query database manipulation, have again identical inquiry request to repeat to be submitted to the situation of database, therefore, avoid database to cause unnecessary burden, be conducive to improve search efficiency.
As seen through the above description of the embodiments, those skilled in the art can be well understood to the mode that the application can add essential general hardware platform by software and realizes.Based on such understanding, the part that the application's technical scheme contributes to prior art in essence in other words can embody with the form of software product, this computer software product can be stored in storage medium, as ROM/RAM, magnetic disc, CD etc., comprise that some instructions (can be personal computers in order to make a computer equipment, server, or the network equipment etc.) carry out the method described in some part of each embodiment of the application or embodiment.
Each embodiment in this instructions all adopts the mode of going forward one by one to describe, between each embodiment identical similar part mutually referring to, what each embodiment stressed is and the difference of other embodiment.Especially,, for system or system embodiment, because it is substantially similar in appearance to embodiment of the method, so describe fairly simplely, relevant part is referring to the part explanation of embodiment of the method.System described above and system embodiment are only schematic, the wherein said unit as separating component explanation can or can not be also physically to separate, the parts that show as unit can be or can not be also physical locations, can be positioned at a place, or also can be distributed in multiple network element.Can select according to the actual needs some or all of module wherein to realize the object of the present embodiment scheme.Those of ordinary skill in the art, in the situation that not paying creative work, are appreciated that and implement.
The method of the data query above the application being provided and device, be described in detail, applied principle and the embodiment of specific case to the application herein and set forth, the explanation of above embodiment is just for helping to understand the application's method and core concept thereof; Meanwhile, for one of ordinary skill in the art, according to the application's thought, all will change in specific embodiments and applications.In sum, this description should not be construed as the restriction to the application.

Claims (10)

1. a method for data query, is characterized in that, comprising:
Tackle current inquiry request;
Judge whether to exist the historical query request identical with this current inquiry request carrying out the operation of Query Database;
If so, block described current inquiry request;
After described historical query request is complete, utilize its Query Result to return to Query Result to described current inquiry request.
2. method according to claim 1, is characterized in that, also comprises:
If there is no the operation of Query Database is being carried out in the historical query request identical with this current inquiry request, current inquiry request is submitted to database and carries out query manipulation.
3. method according to claim 1, is characterized in that, also comprises:
In buffer memory, preserve the check information of the inquiry request of carrying out, the signing messages that described check information is corresponding query statement;
Describedly judge whether that the operation that exists the historical query request identical with this current inquiry request carrying out Query Database comprises:
Calculate the signing messages of the query statement of current inquiry request, obtain the check information of current inquiry request;
Judge in buffer memory whether have the content of mating with the check information of current inquiry request, if existed, determine the operation that exists the historical query request identical with this current inquiry request carrying out Query Database.
4. method according to claim 3, is characterized in that, also comprises:
When carrying out after the inquiry request of Query Database operation gets Query Result, using described check information as key assignments, in buffer memory, preserve Query Result;
The inquiry request initiator that notice has identical check information extracts corresponding Query Result in buffer memory.
5. according to the method described in claim 3 or 4, it is characterized in that, also comprise:
In query caching process, keep the atomicity between each inquiry request.
6. method according to claim 5, is characterized in that, described in query caching process, keeps the atomicity between each inquiry request to comprise:
Intercept after described current inquiry request, attempt the counter object that locking is specified;
If locked successfully, in query caching, whether there is the content of mating with the check information of the inquiry request of intercepting;
If existed, determine and exist the historical query request identical with this current inquiry request to carry out, and block self notice to wait for that historical query request completes;
If there is no, the check information of this current inquiry request is written in buffer memory, after completing the operation that writes buffer memory, removes the locking to described counter object, and this current inquiry request is submitted to database execution query manipulation.
7. method according to claim 1, is characterized in that, also comprises:
When having after the inquiry request of identical check information all obtains Query Result, from buffer memory, delete this Query Result; The described inquiry request with identical check information is that an inquiry request is submitted in the process that database inquires about, the inquiry request identical with this inquiry request receiving.
8. method according to claim 7, is characterized in that, also comprises:
In the time that an inquiry request is submitted to database execution query manipulation, it is the associated counter object of this inquiry request;
In the process of this inquiry request executing data library inquiry, intercept identical with it inquiry request at every turn, all the value of this counter is increased to a digit, until get Query Result;
Getting after Query Result, every initiator to an inquiry request returns to Query Result, all the value of this counter is reduced to a digit;
In the time that the value of described counter is reduced to preset value, determine that each inquiry request with identical check information has all obtained Query Result.
9. a device for data query, is characterized in that, comprising:
Request interception unit, for tackling current inquiry request;
Judging unit, exists the historical query request identical with this current inquiry request carrying out the operation of Query Database for judging whether;
Unit is blocked in request, if be yes for the judged result of judging unit, blocks described current inquiry request;
Query Result returns to unit, for after described historical query request is complete, utilizes its Query Result to return to Query Result to described current inquiry request.
10. device according to claim 9, is characterized in that, also comprises:
Request commit unit, is carrying out the operation of Query Database for if there is no identical with this current inquiry request historical query request, current inquiry request is submitted to database and carries out query manipulation.
CN201310067958.8A 2013-03-04 2013-03-04 Inquire about the method and device of data Active CN104035923B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201310067958.8A CN104035923B (en) 2013-03-04 2013-03-04 Inquire about the method and device of data

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201310067958.8A CN104035923B (en) 2013-03-04 2013-03-04 Inquire about the method and device of data

Publications (2)

Publication Number Publication Date
CN104035923A true CN104035923A (en) 2014-09-10
CN104035923B CN104035923B (en) 2017-09-01

Family

ID=51466694

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201310067958.8A Active CN104035923B (en) 2013-03-04 2013-03-04 Inquire about the method and device of data

Country Status (1)

Country Link
CN (1) CN104035923B (en)

Cited By (23)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104731877A (en) * 2015-03-06 2015-06-24 小米科技有限责任公司 Method and device for requesting data
CN105608197A (en) * 2015-12-25 2016-05-25 Tcl集团股份有限公司 Method and system for obtaining Memcache data under high concurrency
CN106603613A (en) * 2015-10-20 2017-04-26 阿里巴巴集团控股有限公司 Request processing method and apparatus
CN106776666A (en) * 2015-11-25 2017-05-31 北大方正集团有限公司 Data cache method and device based on moodle websites
CN107045480A (en) * 2016-02-05 2017-08-15 北京京东尚科信息技术有限公司 The method and apparatus that buffer memory is read and write based on Spring expression languages
CN107133304A (en) * 2017-04-28 2017-09-05 努比亚技术有限公司 A kind of data manipulation method, device and computer-readable recording medium
CN107203613A (en) * 2017-05-23 2017-09-26 北京微影时代科技有限公司 A kind of method and device of high concurrent request processing
CN107317855A (en) * 2017-06-21 2017-11-03 努比亚技术有限公司 A kind of data cache method, data request method and server
CN108089849A (en) * 2017-12-19 2018-05-29 国云科技股份有限公司 A kind of method for preventing cheating program from quickly submitting
CN108132948A (en) * 2016-11-30 2018-06-08 北京国双科技有限公司 Handle the method and apparatus for crawling webpage
CN108874806A (en) * 2017-05-09 2018-11-23 广东神马搜索科技有限公司 Data query method, apparatus and data-storage system
CN109299117A (en) * 2017-07-25 2019-02-01 北京国双科技有限公司 The treating method and apparatus of request of data, storage medium, processor
CN109471872A (en) * 2017-08-30 2019-03-15 北京国双科技有限公司 Handle the method and device of high concurrent inquiry request
CN109976896A (en) * 2019-04-09 2019-07-05 中国联合网络通信集团有限公司 Business re-scheduling treating method and apparatus
CN110019289A (en) * 2017-08-25 2019-07-16 阿里巴巴集团控股有限公司 A kind of data query method, apparatus and electronic equipment
CN110311986A (en) * 2019-07-10 2019-10-08 中国民航信息网络股份有限公司 The treating method and apparatus of mobile terminal request
CN110502530A (en) * 2019-07-03 2019-11-26 平安科技(深圳)有限公司 Database functions call method, system, computer equipment and storage medium
CN110543349A (en) * 2019-09-09 2019-12-06 Oppo(重庆)智能科技有限公司 Application starting acceleration method and device and computer readable storage medium
CN110765160A (en) * 2019-12-26 2020-02-07 深圳微品致远信息科技有限公司 Zookeeper-based distributed data caching method and system
CN111639241A (en) * 2020-05-20 2020-09-08 中国工商银行股份有限公司 Processing method and device for screening name tickets
CN111897838A (en) * 2020-06-28 2020-11-06 中国建设银行股份有限公司 Transaction query method and device, electronic equipment and readable storage medium thereof
CN111949857A (en) * 2020-08-13 2020-11-17 中国民航信息网络股份有限公司 Flight query request processing method and device and electronic equipment
CN112003947A (en) * 2020-08-26 2020-11-27 山东恒远智能科技有限公司 System and verification method for preventing repeated requests from client to server

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1543092A (en) * 2003-11-07 2004-11-03 清华大学 SCSI instruction optimization method based on FC-SAN storage device
CN101751399A (en) * 2008-12-12 2010-06-23 中国移动通信集团河北有限公司 Decision tree optimization method and optimization system
US20110282836A1 (en) * 2010-05-17 2011-11-17 Invensys Systems, Inc. Replicating time-series data values for retrieved supervisory control and manufacturing parameter values in a multi-tiered historian server environment
CN102521405A (en) * 2011-12-26 2012-06-27 中国科学院计算技术研究所 Massive structured data storage and query methods and systems supporting high-speed loading
CN102542034A (en) * 2011-12-23 2012-07-04 北京人大金仓信息技术股份有限公司 Database interface-based result set cache method

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1543092A (en) * 2003-11-07 2004-11-03 清华大学 SCSI instruction optimization method based on FC-SAN storage device
CN101751399A (en) * 2008-12-12 2010-06-23 中国移动通信集团河北有限公司 Decision tree optimization method and optimization system
US20110282836A1 (en) * 2010-05-17 2011-11-17 Invensys Systems, Inc. Replicating time-series data values for retrieved supervisory control and manufacturing parameter values in a multi-tiered historian server environment
CN102542034A (en) * 2011-12-23 2012-07-04 北京人大金仓信息技术股份有限公司 Database interface-based result set cache method
CN102521405A (en) * 2011-12-26 2012-06-27 中国科学院计算技术研究所 Massive structured data storage and query methods and systems supporting high-speed loading

Cited By (30)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104731877A (en) * 2015-03-06 2015-06-24 小米科技有限责任公司 Method and device for requesting data
CN106603613A (en) * 2015-10-20 2017-04-26 阿里巴巴集团控股有限公司 Request processing method and apparatus
CN106776666A (en) * 2015-11-25 2017-05-31 北大方正集团有限公司 Data cache method and device based on moodle websites
CN106776666B (en) * 2015-11-25 2020-07-14 北大方正集团有限公司 Data caching method and device based on mobile website
CN105608197A (en) * 2015-12-25 2016-05-25 Tcl集团股份有限公司 Method and system for obtaining Memcache data under high concurrency
CN105608197B (en) * 2015-12-25 2019-09-10 Tcl集团股份有限公司 The acquisition methods and system of Memcache data under a kind of high concurrent
CN107045480A (en) * 2016-02-05 2017-08-15 北京京东尚科信息技术有限公司 The method and apparatus that buffer memory is read and write based on Spring expression languages
CN108132948A (en) * 2016-11-30 2018-06-08 北京国双科技有限公司 Handle the method and apparatus for crawling webpage
CN108132948B (en) * 2016-11-30 2021-02-26 北京国双科技有限公司 Method and device for processing crawled webpage
CN107133304A (en) * 2017-04-28 2017-09-05 努比亚技术有限公司 A kind of data manipulation method, device and computer-readable recording medium
CN108874806A (en) * 2017-05-09 2018-11-23 广东神马搜索科技有限公司 Data query method, apparatus and data-storage system
CN107203613A (en) * 2017-05-23 2017-09-26 北京微影时代科技有限公司 A kind of method and device of high concurrent request processing
CN107317855A (en) * 2017-06-21 2017-11-03 努比亚技术有限公司 A kind of data cache method, data request method and server
CN109299117A (en) * 2017-07-25 2019-02-01 北京国双科技有限公司 The treating method and apparatus of request of data, storage medium, processor
CN110019289A (en) * 2017-08-25 2019-07-16 阿里巴巴集团控股有限公司 A kind of data query method, apparatus and electronic equipment
CN110019289B (en) * 2017-08-25 2023-10-03 阿里巴巴集团控股有限公司 Data query method and device and electronic equipment
CN109471872A (en) * 2017-08-30 2019-03-15 北京国双科技有限公司 Handle the method and device of high concurrent inquiry request
CN108089849A (en) * 2017-12-19 2018-05-29 国云科技股份有限公司 A kind of method for preventing cheating program from quickly submitting
CN108089849B (en) * 2017-12-19 2021-04-27 国云科技股份有限公司 Method for preventing cheating program from being rapidly submitted
CN109976896A (en) * 2019-04-09 2019-07-05 中国联合网络通信集团有限公司 Business re-scheduling treating method and apparatus
CN110502530A (en) * 2019-07-03 2019-11-26 平安科技(深圳)有限公司 Database functions call method, system, computer equipment and storage medium
CN110311986A (en) * 2019-07-10 2019-10-08 中国民航信息网络股份有限公司 The treating method and apparatus of mobile terminal request
CN110543349A (en) * 2019-09-09 2019-12-06 Oppo(重庆)智能科技有限公司 Application starting acceleration method and device and computer readable storage medium
CN110543349B (en) * 2019-09-09 2023-02-28 Oppo(重庆)智能科技有限公司 Application starting acceleration method and device and computer readable storage medium
CN110765160A (en) * 2019-12-26 2020-02-07 深圳微品致远信息科技有限公司 Zookeeper-based distributed data caching method and system
CN111639241A (en) * 2020-05-20 2020-09-08 中国工商银行股份有限公司 Processing method and device for screening name tickets
CN111639241B (en) * 2020-05-20 2024-04-16 中国工商银行股份有限公司 Processing method and device for list screening
CN111897838A (en) * 2020-06-28 2020-11-06 中国建设银行股份有限公司 Transaction query method and device, electronic equipment and readable storage medium thereof
CN111949857A (en) * 2020-08-13 2020-11-17 中国民航信息网络股份有限公司 Flight query request processing method and device and electronic equipment
CN112003947A (en) * 2020-08-26 2020-11-27 山东恒远智能科技有限公司 System and verification method for preventing repeated requests from client to server

Also Published As

Publication number Publication date
CN104035923B (en) 2017-09-01

Similar Documents

Publication Publication Date Title
CN104035923A (en) Data inquiry method and device
CN107977376B (en) Distributed database system and transaction processing method
CN107577678B (en) Method, client and server for processing database transaction
CN110909025A (en) Database query method, query device and terminal
US11709803B2 (en) Data transaction processing method, apparatus, and electronic device
US20120166447A1 (en) Filtering queried data on data stores
US8732143B2 (en) Reducing locking during database transactions
US10176205B2 (en) Using parallel insert sub-ranges to insert into a column store
CN108108486B (en) Data table query method and device, terminal equipment and storage medium
US20190332770A1 (en) Malware scanning for network-attached storage systems
US20100153346A1 (en) Data integrity in a database environment through background synchronization
CN112867999A (en) Version-based table locking
KR101806394B1 (en) A data processing method having a structure of the cache index specified to the transaction in a mobile environment dbms
KR102253841B1 (en) Apparatus for Processing Transaction with Modification of Data in Large-Scale Distributed File System and Computer-Readable Recording Medium with Program
CN109992708B (en) Method, device, equipment and storage medium for metadata query
CN111680069B (en) Database access method and device
US20200081925A1 (en) Method and system for cached early-binding document search
US10303680B2 (en) Data processing apparatus and data processing method
CN117076147B (en) Deadlock detection method, device, equipment and storage medium
US20190057126A1 (en) Low latency constraint enforcement in hybrid dbms
US10313438B1 (en) Partitioned key-value store with one-sided communications for secondary global key lookup by range-knowledgeable clients
US20230214373A1 (en) Access management of data objects in databases, including massively parallel database processing systems
US20240054113A1 (en) Automatic computer data deduplication process for application whitelisting system
WO2022156647A1 (en) Database management method and apparatus
CN108011908B (en) Resource operation method and device

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant