CN103678408B - A kind of method and device of inquiry data - Google Patents

A kind of method and device of inquiry data Download PDF

Info

Publication number
CN103678408B
CN103678408B CN201210359116.5A CN201210359116A CN103678408B CN 103678408 B CN103678408 B CN 103678408B CN 201210359116 A CN201210359116 A CN 201210359116A CN 103678408 B CN103678408 B CN 103678408B
Authority
CN
China
Prior art keywords
data
page number
described
interval
condition
Prior art date
Application number
CN201210359116.5A
Other languages
Chinese (zh)
Other versions
CN103678408A (en
Inventor
陈锐发
Original Assignee
阿里巴巴集团控股有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 阿里巴巴集团控股有限公司 filed Critical 阿里巴巴集团控股有限公司
Priority to CN201210359116.5A priority Critical patent/CN103678408B/en
Publication of CN103678408A publication Critical patent/CN103678408A/en
Application granted granted Critical
Publication of CN103678408B publication Critical patent/CN103678408B/en

Links

Abstract

This application discloses a kind of method and device of inquiry data, in order to solve the problems, such as that paging query method of the prior art can increase the pressure of network.The method client is according to the quantity inquiring about the data comprising in the page number and every page of input, quantity N of the data that determination will obtain from each point of storehouse, condition interval further according to input and ordering rule, obtain from each point of storehouse in this condition interval according to the front N data after the sequence of this ordering rule, finally according to this ordering rule to the data sorting getting, and provide corresponding data according to the inquiry page number.By said method, client point storehouse divide carry out paging query under the scene of table when, the all data in condition interval need not be obtained from each point of storehouse, and only need to obtain a part of data in condition interval from each point of storehouse, such that it is able to reduce produced network service when client obtains data, effectively alleviate the pressure of network.

Description

A kind of method and device of inquiry data

Technical field

The application is related to Internet technical field, more particularly, to a kind of method and device of inquiry data.

Background technology

At present, when inquiring about data in data base, inquired about through the method frequently with paging query.Looked into using paging When the method ask carries out data query, user needs input condition interval, ordering rule, the inquiry page number, and data base then first extracts Go out all data in condition interval, further according to ordering rule, the data extracting is ranked up, finally the number after sequence According in, determine that the data of the corresponding page number returns to user.

For example, the condition of input is interval is the most in a couple of days, and ordering rule is the sequencing of time, and the inquiry page number is the 2nd Page, then data base first extracts all data interior, according still further to time order and function order, the data extracting is carried out It is assumed that every one page includes 10 data, then the data that page 2 includes is the 11st ~ 20 article for sequence, thus after data base will sort The 11st ~ 20 data return to user.

The method of above-mentioned paging query is the querying method applied in single database.

In the prior art, in order to solve the problems, such as the finite capacity of single database, to access pressure big, generally using point The method data storage of table is divided in storehouse.Specifically, data is carried out level fractionation, data according to certain regular discrete to multiple Method in point storehouse carries out the storage of data.

For example, two points of storehouses are disposed:A storehouse, B storehouse.For a data to be stored, if the serial number of this data It is odd number, is then stored in A storehouse, if the serial number of this data is even number, be stored in B storehouse.

During using A storehouse and B library storage data, if being still to inquire about interior the 2nd using the method for paging query Page data, then needed to be obtained all data interior being stored in A storehouse and B storehouse respectively by client, then will obtain The data interior storing respectively in the A storehouse taking and B storehouse is ranked up according to time order and function order, after finally sorting Page 2 data be supplied to user.

It can be seen that, in the prior art, point storehouse divide carry out paging query under the scene of table when, client needs to obtain each point All data in the condition interval of storage in storehouse, because the data in the condition interval of storage in each point of storehouse is often a large amount of , therefore this will necessarily produce substantial amounts of network service, thus increasing the pressure of network.

Content of the invention

The application provides a kind of method and device of inquiry data, in order to solve paging query method meeting of the prior art Increase the problem of the pressure of network.

The embodiment of the present application provides a kind of method of inquiry data, including:

, according to the quantity inquiring about the data comprising in the page number and default every page of input, determination will be from each for client Divide quantity N of the data obtaining in storehouse;And

Condition interval according to input and ordering rule, obtain in described condition interval according to described from each point of storehouse Front N data after ordering rule sequence;And

According to described ordering rule, the data getting is ranked up, and is provided according to the described inquiry page number corresponding Data.

The embodiment of the present application provides a kind of device of inquiry data, including:

Determining module, the quantity of the data for comprising in the inquiry page number according to input and default every page, determine Quantity N of the data to obtain from each point of storehouse;

Acquisition module, for the condition interval according to input and ordering rule, obtains described condition from each point of storehouse According to the front N data after the sequence of described ordering rule in interval;

There is provided module, for according to described ordering rule, being ranked up to the data getting, and according to described query page Code provides corresponding data.

The embodiment of the present application provides a kind of method and device of inquiry data, and the method client is according to the query page of input The quantity of data comprising in code and every page, determines quantity N of the data that will obtain from each point of storehouse, further according to input Condition interval and ordering rule, obtain in this condition interval according to the front N bar number after the sequence of this ordering rule from each point of storehouse According to finally according to this ordering rule to the data sorting getting, and according to the inquiry page number corresponding data of offer.By upper State method, client point storehouse divide carry out paging query under the scene of table when, need not obtain from each point of storehouse condition interval in All data, and only need to obtain a part of data in condition interval from each point of storehouse, obtain such that it is able to reduce client Produced network service when fetching data, effectively alleviates the pressure of network.

Brief description

The process of the inquiry data that Fig. 1 provides for the embodiment of the present application;

The apparatus structure schematic diagram of the inquiry data that Fig. 2 provides for the embodiment of the present application.

Specific embodiment

When carrying out paging query due to dividing in point storehouse in prior art under the scene of table, client needs to obtain from each point of storehouse Take all data in condition interval, and all data in the condition interval of storage in each point of storehouse are often substantial amounts of, therefore Client obtains these substantial amounts of data and will necessarily produce substantial amounts of network service, causes the increase of network pressure.The application is real The core concept applying example is:Under conditions of disclosure satisfy that and providing a user with its data to be inquired about, reduce from each as far as possible The quantity of the data obtaining in individual point of storehouse, thus reach reduce the purpose obtaining network service produced by data, to mitigate net The pressure of network.

With reference to Figure of description, the embodiment of the present application is described in detail.

The process of the inquiry data that Fig. 1 provides for the embodiment of the present application, comprises the following steps:

S101:, according to the quantity inquiring about the data comprising in the page number and default every page of input, determining will for client Quantity N of the data obtaining from each point of storehouse.

In the embodiment of the present application, inquired about using the method for paging query certain one page data when, user remains a need for visitor Family end input condition interval [S, E] to be inquired about, ordering rule, inquiry page number p, wherein, S is that this condition of input is interval Interval starting point, E is the interval end point in this condition interval of input.This condition interval [S, E] of input, ordering rule, look into Ask page number p then to represent:Data to be inquired about is the pth number of pages after being ranked up according to this ordering rule in condition interval [S, E] According to.

The quantity of the data being comprised by every one page is fixing, therefore can wrap in presetting every page in the client The quantity of the data containing, for example, be set to n, that is, represent that every page comprises n data.The client first query page according to user input Quantity n of data comprising in code p and default every page, determines quantity N of the data that will obtain from each point of storehouse.Its In, the product p × n of quantity n of the data comprising in the inquiry page number p of user input and default every page can be defined as Quantity N of the data to obtain from each point of storehouse, namely N be p × n.

S102:Condition according to input is interval and ordering rule, obtain from each point of storehouse in this condition interval according to Front N data after the sequence of this ordering rule.

After determining quantity N of data that will obtain from each point of storehouse, client then obtains from each point of storehouse should According to the front N data after the sequence of this ordering rule in condition interval [S, E].Specifically, client can be interval by this condition [S, E], ordering rule, and quantity N determined is sent to each point of storehouse, in order to notify each point of storehouse respectively itself to be stored The all data in this condition interval [S, E] sort according to this ordering rule, and the front N data after sequence is returned to Client.Client then receives the N data that each point of storehouse returns respectively.

S103:According to this ordering rule, the data getting is ranked up, and is provided according to this inquiry page number corresponding Data.

After client gets N data from each point of storehouse, then collect all data getting, defeated according to user The all data getting are ranked up by the ordering rule entering, and the inquiry page number according to user input, provide a user with phase The data answered.

In above process, client only need to obtain N data from each point of storehouse, and need not obtain interval in condition All data in [S, E], therefore decrease the quantity of the data of acquisition, thus produced network when decreasing acquisition data Communication, effectively alleviates the pressure of network.

Below taking specific application scenarios as a example, the inquiry data side that point three kinds of situations provide to the embodiment of the present application Method is described in detail.

For example, it is assumed that having two points of storehouses:A storehouse and B storehouse.For a data to be stored, if this data Serial number is odd number, then be stored in A storehouse, if the serial number of this data is even number, is stored in B storehouse.Deposit in current A storehouse The serial number of data interior of storage according to time order and function order is respectively:1、3、5、7、……、99.In current B storehouse The serial number of data interior of storage according to time order and function order is respectively:2、4、6、8、……、100.That is, Data interior in a couple of days has 100, A library storage wherein serial number is 50 of odd number, and B library storage wherein serial number is 50 of even number.

Under above-mentioned application scenarios, if user's data to be inquired about is data interior(Namely this 100 numbers According to)In, certain page of data after being ranked up according to time order and function order, then it is divided into following three kinds of situations.

After situation one, user input condition interval [S, E], ordering rule, the inquiry page number, if client determines be based on This condition interval [S, E] of input and ordering rule did not inquired about any data, then, in above-mentioned steps S101, client will Product p × the n of quantity n of data comprising in the inquiry page number p of input and default every page, being defined as will be from each point of storehouse Quantity N of the data obtaining.

Then, client executes above-mentioned steps S102 again, i.e. client is advised according to the condition interval of input and sequence Then, obtain from each point of storehouse in this condition interval [S, E] according to the front N data after the sequence of this ordering rule.

Finally, client executing above-mentioned steps S103, i.e. client, according to this ordering rule, is entered to the data getting Row sequence, the inquiry page number p according to user input provides corresponding data.Wherein, client is according to the query page of user input Code p provides the method for corresponding data to be specially:According to quantity n of the data comprising in inquiry page number p and default every page, Determine inquiry page number p corresponding sequence number interval [(p-1) n+1, pn], and in the data after sequence, provide sequence number in query page Data in code p corresponding sequence number interval [(p-1) n+1, pn].

Continue to illustrate it is assumed that user's data to be inquired about is data interior taking above-mentioned application scenarios as a example In, it is ranked up the data of rear page 2 according to time order and function order, then:

User input condition interval [S, E] to be inquired about, this condition interval [S, E] is time interval the most in a couple of days. Assume to be September 1 day and September 2 days the most in a couple of days, then S is the interval interval starting point of this condition, namely 0 point of September 1 day, E is The interval interval end point of this condition, namely 24 points of September 2 days(0 point of September 3 days in other words);

User input ordering rule is in chronological sequence sequentially;

The user input query page number is 2, namely p=2.

The quantity of the data comprising in default every page is 10, namely n=10, that is, every page includes 10 data, then such as Fruit client determines now condition interval [S, E] not yet based on this user input and ordering rule (in chronological sequence order) Inquired about any data, that is, determining that this inquiry is this condition interval [S, E] based on user input and ordering rule (is pressed Time order and function order) the first time inquiry that carries out, then will user input the inquiry page number 2 with default every page in the data that comprises Quantity 10 product 20, be defined as quantity N of data that will obtain from each point of storehouse, namely N be 20.

Client obtain in A storehouse condition interval [S, E] according to time order and function order sequence after before 20 data, 20 data before obtaining in B storehouse after sorting according to time order and function order in condition interval [S, E].

Wherein, due to the data interior of storage in A storehouse serial number according to time order and function order be 1 respectively, 3rd, 5,7 ..., 99, that is, the serial number of the data in condition interval [S, E] of storage is according to time order and function order in A storehouse 1 respectively, 3,5,7 ..., 99, therefore, according to time order and function order in condition interval [S, E] that client obtains from A storehouse The serial number of front 20 data after sequence according to time order and function order is respectively:1、3、5、7、……、39.Similar, client End from B storehouse obtain condition interval [S, E] according to time order and function order sequence after before 20 data serial number according to Time order and function order be respectively:2、4、6、8、……40.It can be seen that, client obtains 40 that serial number is respectively 1~40 altogether Data.

After client all obtains 20 data from A storehouse and B storehouse, then according to the ordering rule of user input, namely press According to time order and function order, all data getting are ranked up.

Assume that 40 data of the serial number respectively 1~40 that client gets are respectively according to time order and function order: 1st, 2,3,4 ... 40, then client is according to the number of the data comprising in the inquiry page number 2 of user input and default every page Amount 10, determines this inquiry page number 2 corresponding sequence number interval [(2-1) × 10+1,2 × 10]=[11,20].

Because 40 data that the serial number that client gets is respectively 1~40 are respectively according to time order and function order: 1st, 2,3,4 ... 40, therefore, after to this 40 data according to the sequence of time order and function order, sequence number is right in this inquiry page number 2 Data in sequence number interval [11,20] answered is:Serial number be respectively 11,12,13 ... 20 data.Thus, client Provide a user with serial number be respectively 11,12,13 ... 20 data, as this user to be inquired about interior, according to Page 2 data after time order and function order sequence.

As can be seen here, in situation one, namely condition interval and the sequence rule based on user input are determined when client Then do not inquired about during any data it is only necessary to obtain totally 40 data from A storehouse and B storehouse (to obtain 20 respectively from A storehouse and B storehouse Data), you can provide a user with it to be inquired about interior, according to the page 2 number after the sequence of time order and function order According to.For needing in prior art to obtain 100 data in condition interval [S, E] from A storehouse and B storehouse altogether, this Shen The method of inquiry data that there is provided of embodiment please decrease the quantity of the data that client obtains from each point of storehouse, therefore decrease Produced network service when client obtains data, effectively alleviates network pressure.

Further, in order to mitigate network pressure further during subsequent query data, in the embodiment of the present application Client, in condition interval [S, E] based on user input, ordering rule, inquiry page number p, has provided a user with corresponding data Afterwards, also will for being not more than the page number p-i of this inquiry page number p, determine the corresponding sequence number of page number p-i interval [(p-i-1) n+1, (p-i) n], wherein, i is 0 positive integer arriving p-1;According to the data after sequence and page number p-i corresponding sequence number interval [(p- I-1) n+1, (p-i) n], page number p-i corresponding condition subinterval is determined using designation method and records;Wherein, this designation method Including:In the data after sequence, the condition of the data of serial number (p-i-1) n+1 is defined as page number p-i corresponding condition Interval interval starting point, the condition of the data of serial number (p-i) n is defined as the area in page number p-i corresponding condition subinterval Between end point.

Continue to use the example above, client has provided a user with to be inquired about interior, according to time order and function of this user After page 2 data after order sequence, determine that the page number being not more than this inquiry page number p=2 includes page number p-i=2-1=1, Accordingly, it is determined that this page number 1 corresponding sequence number interval [(p-i-1) n+1, (p-i) n]=[1,10].

Because 40 data that the serial number that client gets is respectively 1~40 are respectively according to time order and function order: 1st, 2,3,4 ... 40, therefore, after to this 40 data according to the sequence of time order and function order, serial number (p-i-1) n+1=1 Data be the data that serial number is 1, the data of serial number (p-i) n=10 is the data that serial number is 10 it is assumed that this stream Water number be 1 the data corresponding time be R1S, serial number be 10 the data corresponding time be R1E, then this page number 1 is corresponding Condition subinterval is [R1S, R1E], and this corresponding condition subinterval [R1S, R1E] of page number 1 represents:By condition interval [S, E] Interior(Interior)All data according to time order and function order sequence after, the data in condition subinterval [R1S, R1E] is just It is page 1 data.

Similar it is assumed that the data corresponding time that serial number is 11 is R2S, serial number is 20 data corresponding time For R2E, then the inquiry corresponding condition subinterval of the page number 2 is [R2S, R2E].

After have recorded the page number corresponding condition subinterval that each is not more than this inquiry page number, if this user follow-up continues Using the interval data inquiring about other page numbers with ordering rule of identical condition, then can be according to the corresponding bar of each page number of record Part subinterval is inquired about, the situation two stated specific as follows and situation three.

After situation two, user input condition interval [S, E], ordering rule, inquiry page number p, if client determines base Inquired about the data that the page number is less than this inquiry page number in this condition interval [S, E] of input and ordering rule, then in above-mentioned step In rapid S101, the method for quantity N of data that client determination will obtain from each point of storehouse is:Inquiring about and be less than In each page number p-i of inquiry page number p, determine maximum page number max (p-i), wherein, i is 0 positive integer arriving p-1;Determine input Inquiry page number p and difference p-max (p-i) of maximum page number max (p-i), difference p-max (p-i) determining is every with default Product (p-max (p-i)) × n of quantity n of data comprising in page, is defined as the number of data that will obtain from each point of storehouse Amount N.

Then, client is when executing above-mentioned steps S102, according to condition interval [S, E] and ordering rule of input, Obtain from each point of storehouse in condition interval [S, E] and be specially according to the method for the front N data after the sequence of this ordering rule:Really Surely be based on this condition interval [S, E] and this ordering rule inquire about this maximum page number max (p-i) data when recorded this The big corresponding condition subinterval of page number max (p-i);According to the corresponding condition subinterval of this maximum page number max (p-i), will input The interval starting point of condition interval [S, E] be adjusted to the interval in the corresponding condition subinterval of this maximum page number max (p-i) and terminate Point;Obtain from each point of storehouse in the condition interval after adjustment according to the front N data after the sequence of this ordering rule.

Finally, client executing above-mentioned steps S103, i.e. client, according to this ordering rule, is entered to the data getting Row sequence, the inquiry page number p according to user input provides corresponding data.Wherein, client is according to the query page of user input Code p provides the method for corresponding data to be specially:Comprise according in inquiry page number p, maximum page number max (p-i), default every page Data quantity n, determine this inquiry page number p corresponding sequence number interval [(p-max (p-i) -1) n+1, (p-max (p-i)) n], And in the data after sequence, provide sequence number in this inquiry page number p corresponding sequence number interval [(p-max (p-i) -1) n+1, (p- Max (p-i)) n] in data.

Continue to illustrate it is assumed that user queried in data interior taking above-mentioned application scenarios as a example, Be ranked up the data of rear page 2 according to time order and function order, be now to continue in the interior data of inquiry, according to when Between sequencing be ranked up after page 5 data, then:

User input condition interval to be inquired about is still [S, E], and this condition interval [S, E] is time zone the most in a couple of days Between;

User input ordering rule is still in chronological sequence sequentially;

The user input query page number is 5, namely p=5.

Now, client determines condition interval [S, E] and ordering rule based on this user input(In chronological sequence suitable Sequence)Inquired about the data that the page number is less than the current queries page number 5, the page number less than the current queries page number 5 inquired about is the page number 2.Therefore, in each page number that inquired about and less than the current queries page number 5, the maximum page number of determination is the page number to client 2, namely max (p-i)=2.The inquiry page number 5 of current input is p-max (p-i)=3 with the difference of the maximum page number 2.This difference 3 With default every page in the product of the quantity 10 of data that comprises be (p-max (p-i)) × n=30.Therefore, client determines Quantity N of the data to obtain from each point of storehouse is 30.

Because, in above-mentioned situation one, client had inquired about the data of the page number 2, and therefore now client is recorded This corresponding condition subinterval [R2S, R2E] of page number 2, thus, the interval of condition interval [S, E] that client will input initiates Point S is adjusted to interval end point R2E in this corresponding condition subinterval of page number 2, condition after adjustment is interval to be (R2E, E]. After have adjusted condition interval, client then obtain from A storehouse the condition after adjustment interval (R2E, E] in suitable according to time order and function Front 30 data after sequence sequence, the condition that obtains from B storehouse interval (R2E, E] according to before after the sequence of time order and function order 30 Data.

Wherein, due in A storehouse, by all data in condition interval [S, E](Serial number is respectively 1,3,5,7 ... 99 data)After the sequence of time order and function order, the data in the corresponding condition subinterval [R1S, R1E] of the page number 1 is flowing water Number be respectively 1,3,5,7,9 data, the data in the corresponding condition subinterval [R2S, R2E] of the page number 2 is that serial number is respectively 11st, 13,15,17,19 data, therefore, condition after the adjustment that client obtains from A storehouse interval (R2E, E] according to when Between sequencing sequence after front 30 data be:Serial number be respectively 21,23,25,27 ..., 79 data.Similar , condition after the adjustment that client obtains from B storehouse interval (R2E, E] according to first 30 after the sequence of time order and function order Data is:Serial number be respectively 22,24,26,28 ... 80 data.It can be seen that, client obtains serial number altogether and is respectively 21 ~ 80 60 data.

After client all obtains 30 data from A storehouse and B storehouse, then according to the ordering rule of user input, namely press According to time order and function order, all data getting are ranked up.

Assume that 60 data of the serial number respectively 21 ~ 80 that client gets are respectively according to time order and function order: 21st, 22,23,24 ... 80, then client is according to the number comprising in the current inquiry page number 5, the maximum page number 2, default every page According to quantity 10, determine this inquiry page number 5 corresponding sequence number interval [(p-max (p-i) -1) n+1, (p-max (p-i)) n] current =[21,30].

60 data due to the serial number obtaining being respectively 21 ~ 80 are respectively according to time order and function order:21、22、 23rd, 24 ..., 80, therefore, after to this 60 data according to the sequence of time order and function order, sequence number is in this inquiry page number 5 current Data in corresponding sequence number interval [21,30] is:Serial number be respectively 41,42,43 ..., 50 data.Thus, visitor Family end provide a user with serial number be respectively 41,42,43 ..., 50 data.

As can be seen here, in situation two, user, in the case of having inquired about page 2 data, continues to be based on identical During the interval inquiry page 5 data with identical ordering rule of condition, if inquired about according to the method for situation one, client Need all to obtain 50 data in A storehouse and B storehouse, namely obtain 100 data altogether, and if carried out according to the method for situation two Inquire about, then client can reduce and will look into according to inquiring about the corresponding condition subinterval of the page number 2 being recorded during page 2 data The interval scope of the condition ask, and reduce the quantity of the data obtaining from A storehouse and B storehouse further it is only necessary to from A storehouse and B storehouse Middle obtain 30 respectively, obtain 60 data altogether, you can provide a user with it to be inquired about interior, according to the time Page 5 data after sequencing sequence, thus produced network service when further reducing acquisition data, subtracts further The light pressure of network.

Certainly, in above-mentioned situation two, after client has provided a user with page 5 data, also to determine no more than respectively Current each page number corresponding condition subinterval of the inquiry page number 5 simultaneously records, namely determine the page number 1 ~ 5 corresponding condition respectively Interval simultaneously record, and actually client has determined and have recorded the page number 1 and the corresponding condition subinterval of the page number 2, therefore to After user provides page 5 data, as long as determining and recording the corresponding condition subinterval of the page number 3 ~ 5, just not another here One repeats.

After situation three, user input condition interval [S, E], ordering rule, inquiry page number p, if client determines base Inquired about the data that the page number is more than this inquiry page number in this condition interval [S, E] of input and ordering rule, then in above-mentioned step In rapid S101, the method for quantity N of data that client determination will obtain from each point of storehouse is:To comprise in default every page Data quantity n, be defined as quantity N of data that will obtain from each point of storehouse.

Then, client is when executing above-mentioned steps S102, according to condition interval [S, E] and ordering rule of input, Obtain from each point of storehouse in condition interval [S, E] and be specially according to the method for the front N data after the sequence of this ordering rule:Really Surely it is based on when this condition interval [S, E] and this ordering rule are inquired about more than the data of this inquiry page number to the page number and recorded This inquiry page number corresponding condition subinterval;This condition interval [S, E] of input is adjusted to this corresponding bar of inquiry page number Part subinterval;Obtain from each point of storehouse in the condition interval after adjustment according to the front N data after the sequence of this ordering rule.

Finally, client executing above-mentioned steps S103, i.e. client, according to this ordering rule, is entered to the data getting Row sequence, the inquiry page number p according to user input provides corresponding data.Wherein, client is according to this inquiry of user input Page number p provides the method for corresponding data to be specially:In the data after sequence, provide front n data.

Continue to illustrate it is assumed that user queried in data interior taking above-mentioned application scenarios as a example, Be ranked up the data of rear page 2 according to time order and function order, be now to continue in the interior data of inquiry, according to when Between sequencing be ranked up after page 1 data, then:

User input condition interval to be inquired about is still [S, E], and this condition interval [S, E] is time zone the most in a couple of days Between;

User input ordering rule is still in chronological sequence sequentially;

The user input query page number is 1, namely p=1.

Now, client determines condition interval [S, E] and ordering rule based on this user input(In chronological sequence suitable Sequence)Inquired about the data that the page number is more than the current queries page number 1, the page number more than the current queries page number 1 inquired about is the page number 2.Therefore, client is directly by the quantity 10 of the data comprising in default every page, is defined as will obtaining from each point of storehouse Quantity N of data, namely N be 10.

Because, in above-mentioned situation one, client had inquired about the data of the page number 2, and therefore now client is recorded The page number 1(The current inquiry page number)Corresponding condition subinterval [R1S, R1E], thus, client is directly by the condition of input Interval [S, E] is adjusted to current this inquiry page number corresponding condition subinterval, and the interval page number 1 that is of the condition after adjustment corresponds to Condition subinterval [R1S, R1E].

After have adjusted condition interval, client obtains in condition interval [R1S, R1E] after adjustment according to this row from A storehouse Front 10 data after sequence rule compositor, obtain in condition interval [R1S, R1E] after adjustment according to this ordering rule from B storehouse Front 10 data after sequence.

Wherein, due in A storehouse, by all data in condition interval [S, E](Serial number is respectively 1,3,5,7 ... 99 data)After the sequence of time order and function order, the data in the corresponding condition subinterval [R1S, R1E] of the page number 1 is flowing water Number it is respectively 1,3,5,7,9 data, therefore, press in condition after the adjustment that client obtains from A storehouse interval [R1S, R1E] Before after sorting according to this ordering rule, 10 data are:Serial number is respectively 1,3,5,7,9 data.Similar, client Before after sorting according to this ordering rule in condition interval [R1S, R1E] after the adjustment obtaining from B storehouse, 10 data are: Serial number is respectively 2,4,6,8,10 data.

It should be noted that condition after the adjustment that actually client gets from a point of storehouse interval [R1S, R1E] in data can not can exceed that 10, as above in example, client has actually only got 5 numbers from A storehouse According to also only having got 5 data from B storehouse.It can be seen that, client obtains 10 data that serial number is respectively 1 ~ 10 altogether.

After client all obtains 5 data from A storehouse and B storehouse, then according to the ordering rule of user input, namely according to The all data getting are ranked up by time order and function order.

Assume that 10 data of the serial number respectively 1 ~ 10 that client gets are respectively according to time order and function order:1、 2nd, 3,4 ... 10, then client front 10 data after sequence are directly provided, namely the data providing be exactly serial number respectively 10 data for 1 ~ 10.

As can be seen here, in situation three, user, in the case of having inquired about page 2 data, continues to be based on identical During the interval inquiry page 1 data with identical ordering rule of condition, if inquired about according to the method for situation one, client Need all to obtain 10 data in A storehouse and B storehouse, namely obtain 20 data altogether, and if carried out according to the method for situation three Inquire about, then client directly will be able to be used according to inquiring about the corresponding condition subinterval of the page number 1 being recorded during page 2 data The range shorter in the condition interval of family input is to the scope in the corresponding condition subinterval of the page number 1, and reduces further from A storehouse and B The quantity of the data obtaining in storehouse, client reality obtains 10 data from A storehouse and B storehouse altogether, you can provide a user with it To be inquired about is interior, according to the page 1 data after the sequence of time order and function order, thus further reducing acquisition number According to when produced network service, further mitigate the pressure of network.

It is more than the detailed description that the method for the inquiry data that points of three kinds situations provide to the embodiment of the present application is carried out, be based on Same thinking, the embodiment of the present application also provides a kind of device of inquiry data, as shown in Figure 2.

The apparatus structure schematic diagram of the inquiry data that Fig. 2 provides for the embodiment of the present application, specifically includes:

Determining module 201, the quantity of the data for comprising in the inquiry page number according to input and default every page, really Quantity N of the data that surely will obtain from each point of storehouse;

Acquisition module 202, for the condition interval according to input and ordering rule, obtains described bar from each point of storehouse According to the front N data after the sequence of described ordering rule in part is interval;

Module 203 is provided, for according to described ordering rule, being ranked up to the data getting, and is looked into according to described Asking the page number provides corresponding data.

Described determining module 201 was not specifically for being inquired about based on the condition interval inputting and ordering rule when determining During any data, by the described inquiry page number p of input with default every page in the product p × n of quantity n of data that comprises, really It is set to quantity N of the data that will obtain from each point of storehouse;

Described offer module 203 is specifically for according to the data comprising in described inquiry page number p and default every page Quantity n, determines described inquiry page number p corresponding sequence number interval [(p-1) n+1, pn], and in the data after sequence, provides sequence Number described inquiry page number p corresponding sequence number interval [(p-1) n+1, pn] in data.

Described device also includes:

Logging modle 204, for the page number p-i for no more than described inquiry page number p, determines the corresponding sequence of page number p-i Number interval [(p-i-1) n+1, (p-i) n], wherein, i is 0 positive integer arriving p-1;According to the data after sequence and page number p-i Corresponding sequence number interval [(p-i-1) n+1, (p-i) n], determines page number p-i corresponding condition subinterval using designation method and remembers Record;Wherein, described designation method includes:In the data after sequence, the condition of the data of serial number (p-i-1) n+1 is determined For the interval starting point in page number p-i corresponding condition subinterval, the condition of the data of serial number (p-i) n is defined as page number p-i The interval end point in corresponding condition subinterval.

Described determining module 201 was specifically for inquiring about page when determining based on the condition interval inputting and ordering rule When code is less than the described data inquiring about the page number, in each page number p-i that inquired about and less than described inquiry page number p, determine Big page number max (p-i), wherein, i is 0 positive integer arriving p-1;Determine the described inquiry page number p of input and the described maximum page number Difference p-max (p-i) of max (p-i), by the data comprising in described difference p-max (p-i) determining and default every page Product (p-max (p-i)) × n of quantity n, is defined as quantity N of data that will obtain from each point of storehouse;

Described acquisition module 202 is specifically for determining interval and the inquiry of described ordering rule is described based on described condition The corresponding condition subinterval of described maximum page number max (p-i) being recorded during the data of maximum page number max (p-i);According to described The corresponding condition subinterval of maximum page number max (p-i), by interval starting point interval for the described condition of input be adjusted to described in The interval end point in the big corresponding condition subinterval of page number max (p-i);Obtain from each point of storehouse in the condition interval after adjustment According to the front N data after the sequence of described ordering rule;

Described offer module 203 is specifically for according to described inquiry page number p, described maximum page number max (p-i), default Quantity n of the data comprising in every page, determines described inquiry page number p corresponding sequence number interval [(p-max (p-i) -1) n+1, (p- Max (p-i)) n], and in the data after sequence, provide sequence number in described inquiry page number p corresponding sequence number interval [(p-max (p-i) -1) n+1, (p-max (p-i)) n] in data.

Described determining module 201 was specifically for inquiring about page when determining based on the condition interval inputting and ordering rule When code is more than the described data inquiring about the page number, by quantity n of the data comprising in default every page, being defined as will be from each point of storehouse Quantity N of the data of middle acquisition;

Described acquisition module 202 is specifically for determining interval and described ordering rule is big to the page number based on described condition The corresponding condition subinterval of the described inquiry page number being recorded when the data of the described inquiry page number is inquired about;Institute by input The condition interval of stating is adjusted to the described inquiry page number corresponding condition subinterval;The condition obtaining from each point of storehouse after adjustment is interval Front N data after the interior sequence according to described ordering rule;

Described offer module 203 is specifically for, in the data after sequence, providing front n data.

Specifically the device of above-mentioned inquiry data may be located in client.

The embodiment of the present application provides a kind of method and device of inquiry data, and the method client is according to the query page of input The quantity of data comprising in code and every page, determines quantity N of the data that will obtain from each point of storehouse, further according to input Condition interval and ordering rule, obtain in this condition interval according to the front N bar number after the sequence of this ordering rule from each point of storehouse According to finally according to this ordering rule to the data sorting getting, and according to the inquiry page number corresponding data of offer.By above-mentioned Method, client point storehouse divide carry out paging query under the scene of table when, need not obtain from each point of storehouse condition interval in institute There is data, and only need to obtain a part of data in condition interval from each point of storehouse, obtain such that it is able to reduce client Produced network service during data, effectively alleviates the pressure of network.

Those skilled in the art are it should be appreciated that embodiments herein can be provided as method, system or computer program Product.Therefore, the application can be using complete hardware embodiment, complete software embodiment or the reality combining software and hardware aspect Apply the form of example.And, the application can be using in one or more computers wherein including computer usable program code Usable storage medium(Including but not limited to disk memory, CD-ROM, optical memory etc.)The computer program of upper enforcement produces The form of product.

The application is with reference to according to the method for the embodiment of the present application, equipment(System), and computer program flow process Figure and/or block diagram are describing.It should be understood that can be by each stream in computer program instructions flowchart and/or block diagram Flow process in journey and/or square frame and flow chart and/or block diagram and/or the combination of square frame.These computer programs can be provided The processor instructing general purpose computer, special-purpose computer, Embedded Processor or other programmable data processing device is to produce A raw machine is so that produced for reality by the instruction of computer or the computing device of other programmable data processing device The device of the function of specifying in present one flow process of flow chart or multiple flow process and/or one square frame of block diagram or multiple square frame.

These computer program instructions may be alternatively stored in and can guide computer or other programmable data processing device with spy Determine in the computer-readable memory that mode works so that the instruction generation inclusion being stored in this computer-readable memory refers to Make the manufacture of device, this command device realize in one flow process of flow chart or multiple flow process and/or one square frame of block diagram or The function of specifying in multiple square frames.

These computer program instructions also can be loaded in computer or other programmable data processing device so that counting On calculation machine or other programmable devices, execution series of operation steps to be to produce computer implemented process, thus in computer or On other programmable devices, the instruction of execution is provided for realizing in one flow process of flow chart or multiple flow process and/or block diagram one The step of the function of specifying in individual square frame or multiple square frame.

Although having been described for the preferred embodiment of the application, those skilled in the art once know basic creation Property concept, then can make other change and modification to these embodiments.So, claims are intended to be construed to including excellent Select embodiment and fall into being had altered and changing of the application scope.

Obviously, those skilled in the art can carry out the various changes and modification essence without deviating from the application to the application God and scope.So, if these modifications of the application and modification belong to the scope of the application claim and its equivalent technologies Within, then the application is also intended to comprise these changes and modification.

Claims (8)

1. a kind of method of inquiry data is it is characterised in that include:
Client when determining that the condition based on input is interval and ordering rule did not inquired about any data, by described in input Inquiry page number p with default every page in the product p × n of quantity n of data that comprises, be defined as will obtaining from each point of storehouse Quantity N of data;
Condition interval according to input and ordering rule, obtain in described condition interval according to described sequence from each point of storehouse Front N data after rule compositor;And
According to described ordering rule, the data getting is ranked up, and according to described inquiry page number p and default every page In quantity n of data that comprises, determine described inquiry page number p corresponding sequence number interval [(p-1) n+1, pn], and after sequence In data, provide data in described inquiry page number p corresponding sequence number interval [(p-1) n+1, pn] for the sequence number.
2. the method for claim 1 is it is characterised in that methods described also includes:
For the page number p-i of no more than described inquiry page number p, determine page number p-i corresponding sequence number interval [(p-i-1) n+1, (p- I) n], wherein, i is 0 positive integer arriving p-1;
According to the data after sequence and page number p-i corresponding sequence number interval [(p-i-1) n+1, (p-i) n], using designation method Determine page number p-i corresponding condition subinterval and record;
Wherein, described designation method includes:In the data after sequence, the condition of the data of serial number (p-i-1) n+1 is determined For the interval starting point in page number p-i corresponding condition subinterval, the condition of the data of serial number (p-i) n is defined as page number p-i The interval end point in corresponding condition subinterval.
3. a kind of method of inquiry data is it is characterised in that include:
The condition based on input is interval and ordering rule inquired about the number that the page number is less than the described inquiry page number when determination for client According to when, inquiring about and less than described inquiry page number p each page number p-i in, determine maximum page number max (p-i), wherein, i For 0 positive integer arriving p-1;
Determine the described inquiry page number p of input and difference p-max (p-i) of described maximum page number max (p-i), the institute that will determine State product (p-max (p-i)) × n of quantity n of data comprising in difference p-max (p-i) and default every page, being defined as will Quantity N of the data obtaining from each point of storehouse;
Remembered during the data determining and described ordering rule inquiry described maximum page number max (p-i) interval based on described condition The corresponding condition subinterval of described maximum page number max (p-i) of record;
According to the corresponding condition subinterval of described maximum page number max (p-i), by interval starting point interval for the described condition of input It is adjusted to the interval end point in the corresponding condition subinterval of described maximum page number max (p-i);
Obtain from each point of storehouse in the condition interval after adjustment according to the front N data after the sequence of described ordering rule;
According to described ordering rule, the data getting is ranked up, and according to described inquiry page number p, the described maximum page number Max (p-i), quantity n of the data comprising in default every page, determine described inquiry page number p corresponding sequence number interval [(p-max (p-i) -1) n+1, (p-max (p-i)) n], and in the data after sequence, provide sequence number in the described inquiry corresponding sequence of page number p Data in number interval [(p-max (p-i) -1) n+1, (p-max (p-i)) n].
4. a kind of method of inquiry data is it is characterised in that include:
The condition based on input is interval and ordering rule inquired about the number that the page number is more than the described inquiry page number when determination for client According to when, quantity n of the data comprising in default every page is defined as quantity N of data that will obtain from each point of storehouse;
Determine based on described condition is interval and described ordering rule is more than the data of the described inquiry page number and inquires about to the page number When the corresponding condition subinterval of the described inquiry page number that recorded;
The described condition interval of input is adjusted to the described inquiry page number corresponding condition subinterval;
Obtain from each point of storehouse in the condition interval after adjustment according to the front N data after the sequence of described ordering rule;
According to described ordering rule, the data getting is ranked up, and in the data after sequence, provides front n data.
5. a kind of device of inquiry data is it is characterised in that include:
Determining module, for when determining that the condition based on input is interval and ordering rule did not inquired about any data, will be defeated The described inquiry page number p entering with default every page in the product p × n of quantity n of data that comprises, being defined as will be from each point of storehouse Quantity N of the data of middle acquisition;
Acquisition module, for the condition interval according to input and ordering rule, obtains described condition interval from each point of storehouse Front N data after the interior sequence according to described ordering rule;
There is provided module, for according to described ordering rule, being ranked up to the data getting, and according to described inquiry page number p And quantity n of the data comprising in default every page, determine the described inquiry corresponding sequence number of page number p interval [(p-1) n+1, Pn], and in the data after sequence, provide sequence number in described inquiry page number p corresponding sequence number interval [(p-1) n+1, pn] Data.
6. device as claimed in claim 5 is it is characterised in that described device also includes:
Logging modle, for the page number p-i for no more than described inquiry page number p, determines that the corresponding sequence number of page number p-i is interval [(p-i-1) n+1, (p-i) n], wherein, i is 0 positive integer arriving p-1;Corresponding according to the data after sequence and page number p-i Sequence number interval [(p-i-1) n+1, (p-i) n], determines page number p-i corresponding condition subinterval using designation method and records;Its In, described designation method includes:In the data after sequence, the condition of the data of serial number (p-i-1) n+1 is defined as the page number The interval starting point in p-i corresponding condition subinterval, the condition of the data of serial number (p-i) n is defined as page number p-i corresponding The interval end point in condition subinterval.
7. a kind of device of inquiry data is it is characterised in that include:
Determining module, was less than described query page for inquiring about the page number when determination based on the condition interval inputting and ordering rule During the data of code, in each page number p-i that inquired about and less than described inquiry page number p, determine maximum page number max (p-i), Wherein, i is 0 positive integer arriving p-1;Determine the described inquiry page number p of input and difference p- of described maximum page number max (p-i) Max (p-i), by the product (p- of quantity n of the data comprising in described difference p-max (p-i) determining and default every page Max (p-i)) × n, it is defined as quantity N of data that will obtain from each point of storehouse;
Acquisition module, for determining based on described condition is interval and described ordering rule inquiry described maximum page number max (p-i) Data when described maximum page number max (p-i) the corresponding condition subinterval that recorded;According to described maximum page number max (p-i) Corresponding condition subinterval, interval starting point interval for the described condition of input is adjusted to described maximum page number max (p-i) right The interval end point in the condition subinterval answered;Obtain from each point of storehouse in the condition interval after adjustment according to described ordering rule Front N data after sequence;
There is provided module, for according to described ordering rule, being ranked up to the data getting, and according to described inquiry page number p, Described maximum page number max (p-i), quantity n of the data comprising in default every page, determine the described inquiry corresponding sequence of page number p Number interval [(p-max (p-i) -1) n+1, (p-max (p-i)) n], and in the data after sequence, provide sequence number in described inquiry Data in page number p corresponding sequence number interval [(p-max (p-i) -1) n+1, (p-max (p-i)) n].
8. a kind of device of inquiry data is it is characterised in that include:
Determining module, was more than described query page for inquiring about the page number when determination based on the condition interval inputting and ordering rule During the data of code, by quantity n of the data comprising in default every page, it is defined as the number of data that will obtain from each point of storehouse Amount N;
Acquisition module, interval and described ordering rule is more than the described inquiry page number to the page number based on described condition for determining The corresponding condition subinterval of the described inquiry page number being recorded when data is inquired about;The described condition interval of input is adjusted to The described inquiry page number corresponding condition subinterval;Obtain from each point of storehouse in the condition interval after adjustment according to described sequence rule Front N data after then sorting;
There is provided module, in the data after sequence, providing front n data.
CN201210359116.5A 2012-09-21 2012-09-21 A kind of method and device of inquiry data CN103678408B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201210359116.5A CN103678408B (en) 2012-09-21 2012-09-21 A kind of method and device of inquiry data

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201210359116.5A CN103678408B (en) 2012-09-21 2012-09-21 A kind of method and device of inquiry data

Publications (2)

Publication Number Publication Date
CN103678408A CN103678408A (en) 2014-03-26
CN103678408B true CN103678408B (en) 2017-03-01

Family

ID=50315989

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201210359116.5A CN103678408B (en) 2012-09-21 2012-09-21 A kind of method and device of inquiry data

Country Status (1)

Country Link
CN (1) CN103678408B (en)

Families Citing this family (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103984549A (en) * 2014-05-14 2014-08-13 上海上讯信息技术股份有限公司 General paging query method and system based on SSH framework
CN104123340B (en) * 2014-06-25 2018-04-20 世纪禾光科技发展(北京)有限公司 A kind of database divides table paging query method and system
CN105468644B (en) * 2014-09-10 2018-11-23 菜鸟智能物流控股有限公司 A kind of method and apparatus for being inquired in the database
CN104657446B (en) * 2015-02-04 2018-10-30 深圳市汇朗科技有限公司 Divide table joint statistical query method, device and system
CN104778258B (en) * 2015-04-21 2018-04-24 华中科技大学 A kind of data pick-up method of Protocol-oriented data flow
CN104850627B (en) * 2015-05-21 2018-06-15 北京京东尚科信息技术有限公司 Carry out the method and device of paging displaying
CN105183764B (en) * 2015-07-29 2017-03-15 广州神马移动信息科技有限公司 A kind of data paging method and device
CN105138676B (en) * 2015-09-08 2017-11-24 浙江维融电子科技股份有限公司 Table merge querying methods are divided in point storehouse for concurrently polymerizeing calculating based on high-level language
CN106844397A (en) * 2015-12-07 2017-06-13 阿里巴巴集团控股有限公司 Multiplexed transport method, apparatus and system based on point storehouse point table
CN106021357B (en) * 2016-05-09 2019-05-03 泰华智慧产业集团股份有限公司 Based on distributed big data paging query method and system

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1866251A (en) * 2005-12-08 2006-11-22 华为技术有限公司 Method and apparatus for reducing paging data retrieve time
CN102289473A (en) * 2011-07-27 2011-12-21 迈普通信技术股份有限公司 Apparatus and method for a multi-server paging queries

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8996486B2 (en) * 2004-12-15 2015-03-31 Applied Invention, Llc Data store with lock-free stateless paging capability
US8320667B2 (en) * 2009-02-25 2012-11-27 Hewlett-Packard Development Company, L.P. Automatic and scalable image selection

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1866251A (en) * 2005-12-08 2006-11-22 华为技术有限公司 Method and apparatus for reducing paging data retrieve time
CN102289473A (en) * 2011-07-27 2011-12-21 迈普通信技术股份有限公司 Apparatus and method for a multi-server paging queries

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
关于数据库水平切分中分页查询问题的解决方案;william001zs;《database.51cto.com/art/201108/282891.htm》;20110811;第1-2页 *
基于ASP.NET的Web数据分页实现与性能优化;张素智等;《郑州轻工业学院学报(自然科学版)》;20100630;第25卷(第3期);第39-42页 *

Also Published As

Publication number Publication date
CN103678408A (en) 2014-03-26

Similar Documents

Publication Publication Date Title
JP2014531092A (en) Distributed data stream processing method and system
CN107463641A (en) System and method for improving the access to search result
CN105359144B (en) Natural Language Search result for intent query
JP3510042B2 (en) Database management method and system
JP5729466B2 (en) Virtual machine management apparatus, virtual machine management method, and program
US9135370B2 (en) Method and apparatus of generating update parameters and displaying correlated keywords
Silberstein et al. Efficient bulk insertion into a distributed ordered table
US20090187588A1 (en) Distributed indexing of file content
JP2013545189A (en) Determining category information using multistage
TWI613555B (en) Search method and device
CN103873507A (en) Data block uploading and storing system and method
US9141667B2 (en) Efficient join with one or more large dimension tables
US7974981B2 (en) Multi-value property storage and query support
CN100458784C (en) Researching system and method used in digital labrary
CN102307206B (en) Caching system and caching method for rapidly accessing virtual machine images based on cloud storage
US8321476B2 (en) Method and system for determining boundary values dynamically defining key value bounds of two or more disjoint subsets of sort run-based parallel processing of data from databases
US8051058B2 (en) System for estimating cardinality in a database system
CN102456031B (en) A kind of Map Reduce system and the method processing data stream
CN102375837A (en) Data acquiring system and method
US8166203B1 (en) Server selection based upon time and query dependent hashing
CN103297297B (en) Group processing method and group processing system
JP6306187B2 (en) Dynamic telephone number assignment
CN103729471A (en) Method and device for database query
CN104850640A (en) HBase based storage and query method and system for power equipment status monitoring data
US8843632B2 (en) Allocation of resources between web services in a composite service

Legal Events

Date Code Title Description
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
REG Reference to a national code

Ref country code: HK

Ref legal event code: DE

Ref document number: 1193484

Country of ref document: HK

GR01 Patent grant
GR01 Patent grant
REG Reference to a national code

Ref country code: HK

Ref legal event code: GR

Ref document number: 1193484

Country of ref document: HK

TR01 Transfer of patent right

Effective date of registration: 20191209

Address after: P.O. Box 31119, grand exhibition hall, hibiscus street, 802 West Bay Road, Grand Cayman, Cayman Islands

Patentee after: Innovative advanced technology Co., Ltd

Address before: Cayman Islands Grand Cayman capital building, a four storey No. 847 mailbox

Patentee before: Alibaba Group Holding Co., Ltd.