CN105468644A - Method and device for performing query in database - Google Patents

Method and device for performing query in database Download PDF

Info

Publication number
CN105468644A
CN105468644A CN201410457620.8A CN201410457620A CN105468644A CN 105468644 A CN105468644 A CN 105468644A CN 201410457620 A CN201410457620 A CN 201410457620A CN 105468644 A CN105468644 A CN 105468644A
Authority
CN
China
Prior art keywords
page
query
information
record
sublist
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
CN201410457620.8A
Other languages
Chinese (zh)
Other versions
CN105468644B (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.)
Cainiao Smart Logistics 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 CN201410457620.8A priority Critical patent/CN105468644B/en
Publication of CN105468644A publication Critical patent/CN105468644A/en
Application granted granted Critical
Publication of CN105468644B publication Critical patent/CN105468644B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

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

Abstract

The application intends to provide a method and device for performing a query in a database. The method comprises: acquiring query records, in a plurality of sub-tables obtained by dividing a table in a database, of first query information; determining page record location information corresponding to a request page, wherein the page record location information comprises the record location information, in the plurality of sub-tables, of each query record in the request page; according to the page record location information, acquiring corresponding records from the plurality of sub-tables to generate the request page; and according to a mapping relationship between the first query information and the page record location information, updating a corresponding cache. Compared with the prior art, according to the method and device, the page record location information corresponding to the request page is acquired, and a corresponding database record in each corresponding table is read quickly, thereby avoiding resource consumption caused by joint query of the data of each table; and moreover, the query information and the corresponding page record location information are cached, thereby further improving database operation efficiency.

Description

A kind of for carrying out the method and apparatus inquired about in a database
Technical field
The application relates to database technical field, particularly relates to a kind of for carrying out the technology of inquiring about in a database.
Background technology
When operating database, if the data volume in database one table is excessive, executable operations rate will reduce, if a table is divided into several sublists, then pressure when carrying out executable operations to database will share reduction.
At present, the scheme that adopts of this field for: utilize several sublists described in database technology conjunctive query: first obtained the summation meeting and look into record number in multiple sublists of condition by conjunctive query; Then utilize database technology, paging and sorting query go out to meet the data record of querying condition.But when the data volume of each Zhang Zibiao is still very large, multilist conjunctive query will take DataBase combining for a long time, causes the wait of other threads, thus greatly consumes database resource, badly influence the performance of executable operations to database and database.
Summary of the invention
The object of the application is to provide a kind of for carrying out the method and apparatus inquired about in a database.
According to an aspect of the application, providing a kind of for carrying out the method for inquiring about in a database, comprising:
Obtain the first Query Information table in by database and divide the query note in multiple sublists of gained;
Determine the page record position information corresponding to requested page, wherein, described page record position information comprises the record position information of each query note in described multiple sublist in described request page;
Corresponding record is obtained to generate described request page from described multiple sublist according to described page record position information;
Corresponding buffer memory is upgraded with the mapping relations of described page record position information according to described first Query Information.
According to the another aspect of the application, additionally providing a kind of for carrying out the equipment inquired about in a database, comprising:
First device, divides the query note in multiple sublists of gained for obtaining the first Query Information table in by database;
Second device, for determining the page record position information corresponding to requested page, wherein, described page record position information comprises the record position information of each query note in described multiple sublist in described request page;
3rd device, for obtaining corresponding record to generate described request page according to described page record position information from described multiple sublist;
4th device, for upgrading corresponding buffer memory according to described first Query Information with the mapping relations of described page record position information.
Compared with prior art, the application is by the page record position information corresponding to obtaining request page, and then read the associated databases record on corresponding each table fast by described page record position information, avoid time consumption and resource cost that the database manipulation of the mass data that data are brought respectively is shown in conjunctive query; Simultaneously, described Query Information is carried out buffer memory with corresponding described page record position information, when again carrying out same operation to described database, can directly by data cached quick reading associated databases record, further increase the efficiency of database manipulation, thus optimize database performance.
Accompanying drawing explanation
By reading the detailed description done non-limiting example done with reference to the following drawings, the other features, objects and advantages of the application will become more obvious:
It is a kind of for carrying out the equipment schematic diagram inquired about in a database that Fig. 1 illustrates according to the application aspect;
It is a kind of for carrying out the method flow diagram inquired about in a database that Fig. 2 illustrates according to another aspect of the application.
In accompanying drawing, same or analogous Reference numeral represents same or analogous parts.
Embodiment
Below in conjunction with accompanying drawing, the application is described in further detail.
In the application one typically configuration, the equipment of terminal, service network and trusted party include one or more processor (CPU), input/output interface, network interface and internal memory.
Internal memory may comprise the volatile memory in computer-readable medium, and the forms such as random access memory (RAM) and/or Nonvolatile memory, as ROM (read-only memory) (ROM) or flash memory (flashRAM).Internal memory is the example of computer-readable medium.
Computer-readable medium comprises permanent and impermanency, removable and non-removable media can be stored to realize information by any method or technology.Information can be computer-readable instruction, data structure, the module of program or other data.The example of the storage medium of computing machine comprises, but be not limited to phase transition internal memory (PRAM), static RAM (SRAM), dynamic RAM (DRAM), the random access memory (RAM) of other types, ROM (read-only memory) (ROM), Electrically Erasable Read Only Memory (EEPROM), fast flash memory bank or other memory techniques, read-only optical disc ROM (read-only memory) (CD-ROM), digital versatile disc (DVD) or other optical memory, magnetic magnetic tape cassette, magnetic disk stores or other magnetic storage apparatus or any other non-transmitting medium, can be used for storing the information can accessed by computing equipment.According to defining herein, computer-readable medium does not comprise non-temporary computer readable media (transitorymedia), as data-signal and the carrier wave of modulation.
It is a kind of for carrying out the equipment schematic diagram inquired about in a database that Fig. 1 illustrates according to the application aspect.The described equipment 1 for carrying out in a database inquiring about comprises first device 101, second device 102, the 3rd device 103 and the 4th device 104.
Wherein, first device 101 obtains the first Query Information table in by database and divides the query note in multiple sublists of gained; Page record position information corresponding to second device determination requested page, wherein, described page record position information comprises the record position information of each query note in described multiple sublist in described request page; 3rd device obtains corresponding record to generate described request page according to described page record position information from described multiple sublist; 4th device upgrades corresponding buffer memory according to described first Query Information with the mapping relations of described page record position information.
Particularly, the first device 101 for carrying out the equipment 1 inquired about in a database obtains the first Query Information table in by database and divides the query note in multiple sublists of gained.Described first Query Information comprise inquiry described database in record corresponding querying condition, preferably also can comprise the sequence number of described request page and/or the record number information of described request page.Wherein, described querying condition, as multiple sublist alternative condition, as described in the requested page sequence number of paging query, such as, according to a table in condition A partition database, then the table in a certain scope of condition A is carried out inquiring about and just belongs to described querying condition; And for example, described querying condition also comprises the sequence number of the requested page of setting, as the 3rd requested page sequence number.
At this, according to the partial condition in described first Query Information, the submeter such as alternative condition as multiple sublist inquires the query note often opened and sublist meets corresponding conditions, and obtains corresponding record number.Such as, each sublist described is t201301, t201302, t201303, t201304, t201305 ... multiple menologies, described first Query Information is: creation-time is between 2013.01.08-2013.04.08; Age is greater than 50; 3rd page; Page record 10.Can calculate will inquire about t_201301 according to time range, t_201302, t_201303, t_201304 tetra-sublists, at this moment submeter inquire often open sublist conditional be greater than at the age 50 record number,
Those skilled in the art will be understood that; first Query Information described above comprise inquiry described database in record corresponding querying condition; the record number information of the sequence number and/or described request page that preferably also can comprise described request page is only citing; other first Query Informations carrying out inquiring about are as applicable the application; also within should being included in the protection domain of the application, and this is contained at this with way of reference.
Then, the second device 102 for carrying out the equipment 1 inquired about in a database determines the page record position information corresponding to requested page, wherein, described page record position information comprises the record position information of each query note in described multiple sublist in described request page.Can determine by the page record position information corresponding to described request page the query note position in a database that described first Query Information is corresponding, thus just can find corresponding query note based on described query note position in a database.At this, according to described first Query Information, e.g., the requested page of described paging query and the record number of described request page, can determine a page record position information, as query note in described request page as described in record position information in multiple sublist.
Such as, the requested page that described first Query Information comprises described paging query is the 3rd page, the record number of described request page is 10, when then submeter inquiry being carried out for described multiple sublist, first the record number often opening sublist is inquired, as, there are 3 sublists that will inquire about, 1st sublist records 1 to 20 article of record, second sublist records 21 to 40 records, 3rd sublist have recorded 41 to 70 articles of records, now, requested page according to described paging query is the 3rd page, the record number of described request page is 10, data on known 3rd page are recorded as upper 21 to the 30 articles of records of table, record number again by often opening sublist is known, described query note is in chapter 2 sublist, and position is at record 21 to 30 place.Therefore, just obtain the record position information of query note in described multiple sublist, then obtain described query note further.
Those skilled in the art will be understood that; above-mentioned page record position information comprises the record position information of each query note in described multiple sublist in described request page and is only citing; other page of record position information is as applicable the application; also within should being included in the protection domain of the application, and this is contained at this with way of reference.
Then, the 3rd device 103 for carrying out the equipment 1 inquired about in a database obtains corresponding record to generate described request page according to described page record position information from described multiple sublist.According to the page record position information of the described request page correspondence determined, as query note each in described request page as described in record position information in multiple sublist, just can the corresponding Query Information of reading in the one or more sublists determined, recorded information corresponding on query note in described sublist i.e. described request page, can determine or record corresponding recorded information in described request page by inquiry, if have needs in actual applications, the respective record information of described request page correspondence conveniently can be called.
Then, the 4th device 104 for carrying out the equipment 1 inquired about in a database upgrades corresponding buffer memory according to described first Query Information with the mapping relations of described page record position information.At this, described first Query Information comprise inquiry described database in record corresponding querying condition, preferably also can comprise the sequence number of described request page and/or the record number information of described request page.A corresponding page record position information can be obtained by described first Query Information, a kind of mapping relations between the two, be cached corresponding with described page record position information for the first Query Information, and then, when carrying out new inquiry, if the Query Information of described inquiry newly can match with certain Query Information in institute buffer memory, the query note of described inquiry correspondence newly then directly can be found according to page record position information described in buffer memory corresponding to the Query Information of described institute buffer memory, thus do not need again to redefine corresponding page record position information through multilist paging query by the Query Information of new inquiry.
At this, this programme is by carrying out paging to each sublist described, and based on the relevant information of described request page, determine page record position information corresponding to described inquiry request, thus obtain query note of telling, avoid time consumption and resource cost that the database manipulation of the mass data that data are brought respectively is shown in conjunctive query; Simultaneously, described Query Information is carried out buffer memory with corresponding described page record position information, when again carrying out same operation to described database, directly can find the described page record position information corresponding with described query note in the buffer by the coupling of respective queries information, thus read the inquiry shortcut of described database fast, further increase the efficiency of database manipulation, optimize database performance.
In a preferred embodiment, be set forth in the equipment 1 carrying out in a database inquiring about and also comprise the 5th device (not shown), described 5th device according to described first Query Information matching inquiry in described buffer memory, to determine whether comprise the second Query Information matched with described first Query Information in described buffer memory; Wherein, described first device is used for when not comprising described second Query Information in described buffer memory, obtains described first Query Information table in by database and divides query note in multiple sublists of gained.
Particularly, by the 4th device of equipment 1, be updated in the buffer memory corresponding with database by described first Query Information to corresponding described page record position information, now, described first Query Information in buffer memory is the second Query Information.When again to described database data inquiry, according to described first Query Information, judge in the buffer memory corresponding with database, whether there is the second Query Information matched with described first Query Information.When not comprising described second Query Information matched with described first Query Information in described buffer memory, then by the first device 101 of described equipment 1, obtain and corresponding with described first Query Information one show to divide the query note in multiple sublists of gained in by database.
More preferably, the described equipment 1 for carrying out in a database inquiring about also comprises the 6th device (not shown), described 6th device is worked as described buffer memory and is comprised described second Query Information, according to the page record position information corresponding to described second Query Information, obtain corresponding record to generate described request page from described multiple sublist.
Particularly, according to described first Query Information, when there is the second Query Information matched with described first Query Information in the described buffer memory corresponding with database, then included by described first Query Information as, inquire about in described database and record corresponding querying condition, the record number information of described multiple sublist, the information such as the record number information of described request page all match with the second Query Information of the determination in described buffer memory, simultaneously, the page record position information corresponding with described the second Query Information determined also is had in described buffer memory, and then, described first Query Information directly can mate the page record position information corresponding with described second Query Information, now, the position of the query note searched by described first Query Information in table can directly be determined by the record position information of page described in buffer memory.Further, recorded information corresponding on the query note on the described correspondence table determined by the record position information of page described in buffer memory i.e. described request page, can determine or record corresponding recorded information in described request page by inquiry.
More preferably, described for carrying out in a database in the equipment 1 inquired about, described second Query Information has identical searching keyword information with described first Query Information.When finding the second Query Information matched with described first Query Information in described buffer memory, described coupling comprises described first Query Information and described second Query Information has identical searching keyword information.At this, described first Query Information and described second Query Information all comprise inquiry described database in record the information such as corresponding querying condition, the record number information of described multiple sublist, the record number information of described request page.These information are all carry out data query, determine the key word information of query note, it is n-th page that such as the first Query Information comprises requested page, the record number of described request page is m, then same, described second Query Information only meets that to comprise requested page be n-th page, when the record number of described request page is the searching keyword information of m, can mate with described first Query Information.
Preferably, for carrying out in the equipment 1 inquired about in a database, when described buffer memory comprises described second Query Information, the page record position information of described 6th device corresponding to described second Query Information, obtains corresponding record from described multiple sublist; According to described corresponding record, and in conjunction with the page record number information corresponding to described first Query Information, generate described request page.
Particularly, when described first Query Information finds second Query Information with it with same queries key word information in described buffer memory, then based on the determined page record position information of described second Query Information, as, the sublist at the described query note place determined by the record number of described request page and the requested page of described paging query and position, just can obtain the query note of described first Query Information in corresponding sublist.Further, in conjunction with described in page record number information corresponding to Query Information, described request page can be determined.At this, described page record number information comprise the sequence number of described request page, described request page record number, often open the record number etc. of table.Such as, the sequence number of described request page is i-th page, the record number of described request page is j, the record number often opening table is k (t), (t=1,2 ...) individual, simultaneously, the query note of described request page correspondence is v1, v2 ... vn, (n is not more than j), and described all multi information give of described request page and comparatively comprehensively state, if have needs in actual applications, the respective record information of described request page correspondence conveniently can be called according to the relevant information of described request page.
Those skilled in the art will be understood that; above-mentioned page record number information comprises the sequence number sequence number of described request page, the record number of described request page, the record number of often opening table are only citing; other page record number information are as applicable the application; also within should being included in the protection domain of the application, and this is contained at this with way of reference.
Preferably, described for carrying out in the equipment 1 inquired about in a database, described first device screens preferred sublist according to described first Query Information from being divided in multiple sublists of gained by a table database, and in described preferred sublist, inquires about acquisition query note according to described first Query Information.
Particularly, when the data volume in a table in database is excessive, can according to certain rule, preferably, submeter is carried out according to certain order, such as, according to time interval, a table is divided, thus the data on an original table have been stored in multiple multiple sublists come to the same thing, and then, according to given described first Query Information, from multiple sublist, filter out the sublist meeting querying condition, as the inquiry sublist that following paging query is corresponding.Such as, according to days, the data in a table are divided, obtain table201401, table201402, table201403, table201404 tetra-sublists, if comprising a querying condition in described first Query Information is data message in inquiry 201401 to 201402 time, from described four sublists, then optimize the sublist that table201401 and table201402 two meets the first Query Information, and then, inquired about in the obtained sublist optimized by described first Query Information and obtain described query note.
At this, this programme is applicable to the situation of a lot of fields big data quantity submeter paging query, the inquiry of the data messages such as the model of such as forum, the blog article of blog microblogging, the sequence information of form ordering system, the Transaction Information of transaction system.
Preferably, described for carrying out in the equipment 1 inquired about in a database, the page record position information of described second device corresponding to the page record number information determination described request page of corresponding requests page, wherein, described page record position information comprises the record position information of each query note in described multiple sublist in described request page.
Particularly, at this, described page record number information comprise the sequence number of described request page, described request page record number, often open the record number etc. of table.The corresponding position in table of record satisfied condition in described request page can be determined by the sequence number of described request page and the record number of described request page, sequence number as described request page is x page, the record number of described request page is y, what then satisfy condition in described request page is recorded in the individual position being recorded to xth y record of (x-1) y in described multiple sublist, simultaneously, in conjunction with the described record number often opening table, just can determine that (x-1) y to be recorded to xth y and to be recorded in described which or multiple sublist, the i.e. page record position information of described request page correspondence, described page record position information comprises the record position information of each query note in described multiple sublist in described request page.
Those skilled in the art will be understood that; above-mentioned page record number information comprise the sequence number of described request page, described request page record number, often open the record number showing to satisfy condition and be only citing; other page record number information are as applicable the application; also within should being included in the protection domain of the application, and this is contained at this with way of reference.
Preferably, the described equipment 1 for carrying out in a database inquiring about is also for detecting whether meet trigger condition; If meet described trigger condition, delete mapping relations corresponding with described trigger condition in described buffer memory.Described trigger condition comprises carries out certain data manipulation to described database, when after the described data manipulation of execution, namely described trigger condition meets, then in database there is corresponding change based on certain data manipulation in original data, such as data reduce, data record in table now corresponding to trigger condition disappears, then these data are recorded as query note, and the existence of described second Query Information corresponding to the described query note stored in the buffer and described page record position information just no longer includes meaning, therefore mapping relations corresponding with described trigger condition in described buffer memory are deleted based on met trigger condition, thus the fail data removed in time in buffer memory, release respective cache space.
More preferably, described for carrying out in a database in the equipment 1 inquired about, it is data inserting record in described sublist that described trigger condition comprises following at least any one one; Two is delete data record in described sublist; Three is Update Table records in described sublist; Four is delete described sublist.At this, described trigger condition comprises carries out certain operation for the data in sublist or sublist, and the satisfied of trigger condition means that the data in the sublist corresponding with trigger condition change, based on the corresponding inefficacy of data of the data message buffer memory of corresponding sublist.Therefore, determine the sublist corresponding to trigger condition, and then each cache object judging in described buffer memory, the second Query Information as described in each, and whether relate to table corresponding to described trigger condition in page record position information described in each corresponding with it, if in table cache object described in certain that described trigger condition is corresponding, then described cache object is removed.
Those skilled in the art will be understood that above-mentioned trigger condition is only citing, and other trigger conditions, as applicable the application, within also should being included in the protection domain of the application, and are contained in this at this with way of reference.
It is a kind of for carrying out the method flow diagram inquired about in a database that Fig. 2 illustrates according to another aspect of the application.
Wherein, in step s 201, described equipment 1 obtains the first Query Information table in by database and divides the query note in multiple sublists of gained; In step S202, described equipment 1 determines the page record position information corresponding to requested page, and wherein, described page record position information comprises the record position information of each query note in described multiple sublist in described request page; In step S203, described equipment 1 obtains corresponding record to generate described request page according to described page record position information from described multiple sublist; In step S204, described equipment 1 upgrades corresponding buffer memory according to described first Query Information with the mapping relations of described page record position information.
Particularly, in step s 201, the equipment 1 for carrying out in a database inquiring about obtains the first Query Information table in by database and divides the query note in multiple sublists of gained.Described first Query Information comprise inquiry described database in record corresponding querying condition, preferably also can comprise the sequence number of described request page and/or the record number information of described request page.Wherein, described querying condition, as multiple sublist alternative condition, as described in the requested page sequence number of paging query, such as, according to a table in condition A partition database, then the table in a certain scope of condition A is carried out inquiring about and just belongs to described querying condition; And for example, described querying condition also comprises the sequence number of the requested page of setting, as the 3rd requested page sequence number.
At this, according to the partial condition in described first Query Information, as the alternative condition etc. of multiple sublist, submeter inquires the query note often opened and sublist meets corresponding conditions, obtains corresponding record number.Such as, each sublist described is t201301, t201302, t201303, t201304, t201305 ... multiple menologies, described first Query Information is: creation-time is between 2013.01.08-2013.04.08; Age is greater than 50; 3rd page; Page record 10.Can calculate will inquire about t_201301 according to time range, t_201302, t_201303, t_201304 tetra-sublists, at this moment submeter inquire often open sublist conditional be greater than at the age 50 record number,
Those skilled in the art will be understood that; first Query Information described above comprise inquiry described database in record corresponding querying condition; the record number information of the sequence number and/or described request page that preferably also can comprise described request page is only citing; other first Query Informations carrying out inquiring about are as applicable the application; also within should being included in the protection domain of the application, and this is contained at this with way of reference.
Then, in step S202, equipment 1 for carrying out in a database inquiring about determines the page record position information corresponding to requested page, and wherein, described page record position information comprises the record position information of each query note in described multiple sublist in described request page.Can determine by the page record position information corresponding to described request page the query note position in a database that described first Query Information is corresponding, thus just can find corresponding query note based on described query note position in a database.At this, according to described first Query Information, e.g., the requested page of described paging query and the record number of described request page, can determine a page record position information, as query note in described request page as described in record position information in multiple sublist.
Such as, the requested page that described first Query Information comprises described paging query is the 3rd page, the record number of described request page is 10, when then submeter inquiry being carried out for described multiple sublist, first the record number often opening sublist is inquired, as, there are 3 sublists that will inquire about, 1st sublist records 1 to 20 article of record, second sublist records 21 to 40 records, 3rd sublist have recorded 41 to 70 articles of records, now, requested page according to described paging query is the 3rd page, the record number of described request page is 10, data on known 3rd page are recorded as upper 21 to the 30 articles of records of table, record number again by often opening sublist is known, described query note is in chapter 2 sublist, and position is at record 21 to 30 place.Therefore, just obtain the record position information of query note in described multiple sublist, then obtain described query note further.
Those skilled in the art will be understood that; above-mentioned page record position information comprises the record position information of each query note in described multiple sublist in described request page and is only citing; other page of record position information is as applicable the application; also within should being included in the protection domain of the application, and this is contained at this with way of reference.
Then, in step S203, corresponding record is obtained to generate described request page according to described page record position information from described multiple sublist for the equipment 1 carrying out in a database inquiring about.According to the page record position information of the described request page correspondence determined, as query note each in described request page as described in record position information in multiple sublist, just can the corresponding Query Information of reading in the one or more sublists determined, recorded information corresponding on query note in described sublist i.e. described request page, can determine or record corresponding recorded information in described request page by inquiry, if have needs in actual applications, the respective record information of described request page correspondence conveniently can be called.
Then, in step S204, corresponding buffer memory is upgraded according to described first Query Information with the mapping relations of described page record position information for the equipment 1 carrying out in a database inquiring about.At this, described first Query Information comprise inquiry described database in record corresponding querying condition, preferably also can comprise the sequence number of described request page and/or the record number information of described request page.A corresponding page record position information can be obtained by described first Query Information, a kind of mapping relations between the two, be cached corresponding with described page record position information for the first Query Information, and then, when carrying out new inquiry, if the Query Information of described inquiry newly can match with certain Query Information in institute buffer memory, the query note of described inquiry correspondence newly then directly can be found according to page record position information described in buffer memory corresponding to the Query Information of described institute buffer memory, thus do not need again to redefine corresponding page record position information through multilist paging query by the Query Information of new inquiry.
At this, this programme is by carrying out paging to each sublist described, and based on the relevant information of described request page, determine page record position information corresponding to described inquiry request, thus obtain query note of telling, avoid time consumption and resource cost that the database manipulation of the mass data that data are brought respectively is shown in conjunctive query; Simultaneously, described Query Information is carried out buffer memory with corresponding described page record position information, when again carrying out same operation to described database, directly can find the described page record position information corresponding with described query note in the buffer by the coupling of respective queries information, thus read the inquiry shortcut of described database fast, further increase the efficiency of database manipulation, optimize database performance.
In a preferred embodiment, this method also comprises step S205 (not shown), in step S205, equipment 1 according to described first Query Information matching inquiry in described buffer memory, to determine whether comprise the second Query Information matched with described first Query Information in described buffer memory; Wherein, in step s 201, when not comprising described second Query Information in described buffer memory, obtaining described first Query Information table in by database and dividing the query note in multiple sublists of gained.
Particularly, be updated in the buffer memory corresponding with database by equipment 1 by described first Query Information to corresponding described page record position information, now, described first Query Information in buffer memory is the second Query Information.When again to described database data inquiry, according to described first Query Information, judge in the buffer memory corresponding with database, whether there is the second Query Information matched with described first Query Information.When not comprising described second Query Information matched with described first Query Information in described buffer memory, then by described step S201, obtaining and corresponding with described first Query Information one showing to divide the query note in multiple sublists of gained in by database.
More preferably, described method also comprises step S206 (not shown), in step S206, when described buffer memory comprises described second Query Information, according to the page record position information corresponding to described second Query Information, obtain corresponding record to generate described request page from described multiple sublist.
Particularly, according to described first Query Information, when there is the second Query Information matched with described first Query Information in the described buffer memory corresponding with database, then included by described first Query Information as, inquire about in described database and record corresponding querying condition, the record number information of described multiple sublist, the information such as the record number information of described request page all match with the second Query Information of the determination in described buffer memory, simultaneously, the page record position information corresponding with described the second Query Information determined also is had in described buffer memory, and then, described first Query Information directly can mate the page record position information corresponding with described second Query Information, now, the position of the query note searched by described first Query Information in table can directly be determined by the record position information of page described in buffer memory.Further, recorded information corresponding on the query note on the described correspondence table determined by the record position information of page described in buffer memory i.e. described request page, can determine or record corresponding recorded information in described request page by inquiry.
More preferably, in described method, described second Query Information has identical searching keyword information with described first Query Information.When finding the second Query Information matched with described first Query Information in described buffer memory, described coupling comprises described first Query Information and described second Query Information has identical searching keyword information.At this, described first Query Information and described second Query Information all comprise inquiry described database in record the information such as corresponding querying condition, the record number information of described multiple sublist, the record number information of described request page.These information are all carry out data query, determine the key word information of query note, it is n-th page that such as the first Query Information comprises requested page, the record number of described request page is m, then same, described second Query Information only meets that to comprise requested page be n-th page, when the record number of described request page is the searching keyword information of m, can mate with described first Query Information.
Preferably, in step S206, when described buffer memory comprises described second Query Information, according to the page record position information corresponding to described second Query Information, obtain corresponding record from described multiple sublist; According to described corresponding record, and in conjunction with the page record number information corresponding to described first Query Information, generate described request page.
Particularly, when described first Query Information finds second Query Information with it with same queries key word information in described buffer memory, then based on the determined page record position information of described second Query Information, as, the sublist at the described query note place determined by the record number of described request page and the requested page of described paging query and position, just can obtain the query note of described first Query Information in corresponding sublist.Further, in conjunction with described in page record number information corresponding to Query Information, described request page can be determined.At this, described page record number information comprise the sequence number of described request page, described request page record number, often open the record number etc. of table.Such as, the sequence number of described request page is i-th page, the record number of described request page is j, the record number often opening table is k (t), (t=1,2 ...) individual, simultaneously, the query note of described request page correspondence is v1, v2 ... vn, (n is not more than j), and described all multi information give of described request page and comparatively comprehensively state, if have needs in actual applications, the respective record information of described request page correspondence conveniently can be called according to the relevant information of described request page.
Those skilled in the art will be understood that; above-mentioned page record number information comprises the sequence number sequence number of described request page, the record number of described request page, the record number of often opening table are only citing; other page record number information are as applicable the application; also within should being included in the protection domain of the application, and this is contained at this with way of reference.
Preferably, in described method, described equipment 1 screens preferred sublist according to described first Query Information from being divided in multiple sublists of gained by a table database, and in described preferred sublist, inquires about acquisition query note according to described first Query Information.
Particularly, when the data volume in a table in database is excessive, can according to certain rule, preferably, submeter is carried out according to certain order, such as, according to time interval, a table is divided, thus the data on an original table have been stored in multiple multiple sublists come to the same thing, and then, according to given described first Query Information, from multiple sublist, filter out the sublist meeting querying condition, as the inquiry sublist that following paging query is corresponding.Such as, according to days, the data in a table are divided, obtain table201401, table201402, table201403, table201404 tetra-sublists, if comprising a querying condition in described first Query Information is data message in inquiry 201401 to 201402 time, from described four sublists, then optimize the sublist that table201401 and table201402 two meets the first Query Information, and then, inquired about in the obtained sublist optimized by described first Query Information and obtain described query note.
At this, this programme is applicable to the situation of a lot of fields big data quantity submeter paging query, the inquiry of the data messages such as the model of such as forum, the blog article of blog microblogging, the sequence information of form ordering system, the Transaction Information of transaction system.
Preferably, in step S202, the page record position information of described equipment 1 corresponding to the page record number information determination described request page of corresponding requests page, wherein, described page record position information comprises the record position information of each query note in described multiple sublist in described request page.
Particularly, at this, described page record number information comprise the sequence number of described request page, described request page record number, often open the record number etc. of table.The corresponding position in table of record satisfied condition in described request page can be determined by the sequence number of described request page and the record number of described request page, sequence number as described request page is x page, the record number of described request page is y, what then satisfy condition in described request page is recorded in the individual position being recorded to xth y record of (x-1) y in described multiple sublist, simultaneously, in conjunction with the described record number often opening table, just can determine that (x-1) y to be recorded to xth y and to be recorded in described which or multiple sublist, the i.e. page record position information of described request page correspondence, described page record position information comprises the record position information of each query note in described multiple sublist in described request page.
Those skilled in the art will be understood that; above-mentioned page record number information comprise the sequence number of described request page, described request page record number, often open the record number showing to satisfy condition and be only citing; other page record number information are as applicable the application; also within should being included in the protection domain of the application, and this is contained at this with way of reference.
Preferably, in the process, the described equipment 1 for carrying out in a database inquiring about is also for detecting whether meet trigger condition; If meet described trigger condition, delete mapping relations corresponding with described trigger condition in described buffer memory.Described trigger condition comprises carries out certain data manipulation to described database, when after the described data manipulation of execution, namely described trigger condition meets, then in database there is corresponding change based on certain data manipulation in original data, such as data reduce, data record in table now corresponding to trigger condition disappears, then these data are recorded as query note, and the existence of described second Query Information corresponding to the described query note stored in the buffer and described page record position information just no longer includes meaning, therefore mapping relations corresponding with described trigger condition in described buffer memory are deleted based on met trigger condition, thus the fail data removed in time in buffer memory, release respective cache space.
More preferably, in the process, described trigger condition comprises following at least any one one is data inserting record in described sublist; Two is delete data record in described sublist; Three is Update Table records in described sublist; Four is delete described sublist.At this, described trigger condition comprises carries out certain operation for the data in sublist or sublist, and the satisfied of trigger condition means that the data in the sublist corresponding with trigger condition change, based on the corresponding inefficacy of data of the data message buffer memory of corresponding sublist.Therefore, determine the sublist corresponding to trigger condition, and then each cache object judging in described buffer memory, the second Query Information as described in each, and whether relate to table corresponding to described trigger condition in page record position information described in each corresponding with it, if in table cache object described in certain that described trigger condition is corresponding, then described cache object is removed.
Those skilled in the art will be understood that above-mentioned trigger condition is only citing, and other trigger conditions, as applicable the application, within also should being included in the protection domain of the application, and are contained in this at this with way of reference.
To those skilled in the art, obvious the application is not limited to the details of above-mentioned one exemplary embodiment, and when not deviating from spirit or the essential characteristic of the application, can realize the application in other specific forms.Therefore, no matter from which point, all should embodiment be regarded as exemplary, and be nonrestrictive, the scope of the application is limited by claims instead of above-mentioned explanation, and all changes be therefore intended in the implication of the equivalency by dropping on claim and scope are included in the application.Any Reference numeral in claim should be considered as the claim involved by limiting.In addition, obviously " comprising " one word do not get rid of other unit or step, odd number does not get rid of plural number.Multiple unit of stating in device claim or device also can be realized by software or hardware by a unit or device.First, second word such as grade is used for representing title, and does not represent any specific order.

Claims (18)

1., for carrying out a method of inquiring about in a database, wherein, described method comprises:
Obtain the first Query Information table in by database and divide the query note in multiple sublists of gained;
Determine the page record position information corresponding to requested page, wherein, described page record position information comprises the record position information of each query note in described multiple sublist in described request page;
Corresponding record is obtained to generate described request page from described multiple sublist according to described page record position information;
Corresponding buffer memory is upgraded with the mapping relations of described page record position information according to described first Query Information.
2. method according to claim 1, wherein, described method also comprises:
According to described first Query Information matching inquiry in described buffer memory, to determine whether comprise the second Query Information matched with described first Query Information in described buffer memory;
Wherein, the described acquisition first Query Information query note that a table divides in multiple sublists of gained in by database comprises:
When not comprising described second Query Information in described buffer memory, obtaining described first Query Information table in by database and dividing the query note in multiple sublists of gained.
3. method according to claim 2, wherein, described method also comprises:
When described buffer memory comprises described second Query Information, according to the page record position information corresponding to described second Query Information, obtain corresponding record to generate described request page from described multiple sublist.
4. method according to claim 3, wherein, described second Query Information has identical searching keyword information with described first Query Information.
5. the method according to claim 3 or 4, wherein, describedly comprise described second Query Information when described buffer memory, according to the page record position information corresponding to described second Query Information, obtain corresponding record from described multiple sublist and comprise to generate described request page:
When described buffer memory comprises described second Query Information, according to the page record position information corresponding to described second Query Information, obtain corresponding record from described multiple sublist;
According to described corresponding record, and in conjunction with the page record number information corresponding to described first Query Information, generate described request page.
6. method according to any one of claim 1 to 5, wherein, the described acquisition first Query Information query note that a table divides in multiple sublists of gained in by database comprises:
Screen preferred sublist according to described first Query Information from being divided in multiple sublists of gained by a table database, and in described preferred sublist, inquire about acquisition query note according to described first Query Information.
7. method according to any one of claim 1 to 6, wherein, the described page record position information determined corresponding to requested page, wherein, described page record position information comprises the record position information of each query note in described multiple sublist in described request page and comprises:
According to the page record position information corresponding to the page record number information determination described request page of corresponding requests page, wherein, described page record position information comprises the record position information of each query note in described multiple sublist in described request page.
8. method according to any one of claim 1 to 7, wherein, described method also comprises:
Detect and whether meet trigger condition; If meet described trigger condition, delete mapping relations corresponding with described trigger condition in described buffer memory.
9. method according to claim 8, wherein, described trigger condition comprises following at least any one:
Data inserting record in described sublist;
Delete data record in described sublist;
Update Table record in described sublist;
Delete described sublist.
10., for carrying out the equipment inquired about in a database, wherein, described equipment comprises:
First device, divides the query note in multiple sublists of gained for obtaining the first Query Information table in by database;
Second device, for determining the page record position information corresponding to requested page, wherein, described page record position information comprises the record position information of each query note in described multiple sublist in described request page;
3rd device, for obtaining corresponding record to generate described request page according to described page record position information from described multiple sublist;
4th device, for upgrading corresponding buffer memory according to described first Query Information with the mapping relations of described page record position information.
11. equipment according to claim 10, wherein, described equipment also comprises:
5th device, for according to described first Query Information matching inquiry in described buffer memory, to determine whether comprise the second Query Information matched with described first Query Information in described buffer memory;
Wherein, described first device is used for:
When not comprising described second Query Information in described buffer memory, obtaining described first Query Information table in by database and dividing the query note in multiple sublists of gained.
12. equipment according to claim 11, wherein, described equipment also comprises:
6th device, for comprising described second Query Information when described buffer memory, according to the page record position information corresponding to described second Query Information, obtains corresponding record to generate described request page from described multiple sublist.
13. equipment according to claim 12, wherein, described second Query Information has identical searching keyword information with described first Query Information.
14. equipment according to claim 12 or 13, wherein, described 6th device is used for:
When described buffer memory comprises described second Query Information, according to the page record position information corresponding to described second Query Information, obtain corresponding record from described multiple sublist;
According to described corresponding record, and in conjunction with the page record number information corresponding to described first Query Information, generate described request page.
15. according to claim 10 to the equipment according to any one of 14, and wherein, described first device is used for:
Screen preferred sublist according to described first Query Information from being divided in multiple sublists of gained by a table database, and in described preferred sublist, inquire about acquisition query note according to described first Query Information.
16. according to claim 10 to the equipment according to any one of 15, and wherein, described second device is used for:
According to the page record position information corresponding to the page record number information determination described request page of corresponding requests page, wherein, described page record position information comprises the record position information of each query note in described multiple sublist in described request page.
17. according to claim 10 to the equipment according to any one of 16, wherein, described equipment also for:
Detect and whether meet trigger condition; If meet described trigger condition, delete mapping relations corresponding with described trigger condition in described buffer memory.
18. equipment according to claim 17, wherein, described trigger condition comprises following at least any one:
Data inserting record in described sublist;
Delete data record in described sublist;
Update Table record in described sublist;
Delete described sublist.
CN201410457620.8A 2014-09-10 2014-09-10 Method and equipment for querying in database Active CN105468644B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201410457620.8A CN105468644B (en) 2014-09-10 2014-09-10 Method and equipment for querying in database

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201410457620.8A CN105468644B (en) 2014-09-10 2014-09-10 Method and equipment for querying in database

Publications (2)

Publication Number Publication Date
CN105468644A true CN105468644A (en) 2016-04-06
CN105468644B CN105468644B (en) 2018-11-23

Family

ID=55606349

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201410457620.8A Active CN105468644B (en) 2014-09-10 2014-09-10 Method and equipment for querying in database

Country Status (1)

Country Link
CN (1) CN105468644B (en)

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107315753A (en) * 2016-04-27 2017-11-03 北京京东尚科信息技术有限公司 Across the paging method and device of multiple database
CN108874753A (en) * 2018-06-13 2018-11-23 百度在线网络技术(北京)有限公司 Lookup method, device and the computer equipment that topic post is replied
CN109313642A (en) * 2018-09-07 2019-02-05 威富通科技有限公司 Bill information caching method, bill information querying method and terminal device
CN110928900A (en) * 2018-09-17 2020-03-27 马上消费金融股份有限公司 Multi-table data query method, device, terminal and computer storage medium
CN111488370A (en) * 2020-04-02 2020-08-04 杭州迪普科技股份有限公司 List paging quick response system and method
CN112069207A (en) * 2020-08-27 2020-12-11 重庆攸亮科技股份有限公司 Multi-table combined query efficiency improving method

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6631366B1 (en) * 1998-10-20 2003-10-07 Sybase, Inc. Database system providing methodology for optimizing latching/copying costs in index scans on data-only locked tables
CN1556482A (en) * 2003-12-31 2004-12-22 中兴通讯股份有限公司 Data processing method for realizing data base multitable inguiry
CN103678408A (en) * 2012-09-21 2014-03-26 阿里巴巴集团控股有限公司 Method and device for inquiring data
CN103778135A (en) * 2012-10-18 2014-05-07 厦门雅迅网络股份有限公司 Method for distribution storage and paging querying of real-time data
CN104123340A (en) * 2014-06-25 2014-10-29 世纪禾光科技发展(北京)有限公司 Table-by-table and page-by-page query method and system for database

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6631366B1 (en) * 1998-10-20 2003-10-07 Sybase, Inc. Database system providing methodology for optimizing latching/copying costs in index scans on data-only locked tables
CN1556482A (en) * 2003-12-31 2004-12-22 中兴通讯股份有限公司 Data processing method for realizing data base multitable inguiry
CN103678408A (en) * 2012-09-21 2014-03-26 阿里巴巴集团控股有限公司 Method and device for inquiring data
CN103778135A (en) * 2012-10-18 2014-05-07 厦门雅迅网络股份有限公司 Method for distribution storage and paging querying of real-time data
CN104123340A (en) * 2014-06-25 2014-10-29 世纪禾光科技发展(北京)有限公司 Table-by-table and page-by-page query method and system for database

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
段翰聪 等: "分布式结构化数据分页查询中的动态归并算法", 《小型微型计算机系统》 *
祝衍军: "一种支持多条件过滤查询的分页组件设计与实现", 《电脑知识与技术》 *

Cited By (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107315753A (en) * 2016-04-27 2017-11-03 北京京东尚科信息技术有限公司 Across the paging method and device of multiple database
CN107315753B (en) * 2016-04-27 2020-11-03 北京京东尚科信息技术有限公司 Paging method and device across multiple databases
CN108874753A (en) * 2018-06-13 2018-11-23 百度在线网络技术(北京)有限公司 Lookup method, device and the computer equipment that topic post is replied
CN108874753B (en) * 2018-06-13 2022-05-10 百度在线网络技术(北京)有限公司 Method and device for searching response of subject post and computer equipment
CN109313642A (en) * 2018-09-07 2019-02-05 威富通科技有限公司 Bill information caching method, bill information querying method and terminal device
CN110928900A (en) * 2018-09-17 2020-03-27 马上消费金融股份有限公司 Multi-table data query method, device, terminal and computer storage medium
CN110928900B (en) * 2018-09-17 2021-02-19 马上消费金融股份有限公司 Multi-table data query method, device, terminal and computer storage medium
CN111488370A (en) * 2020-04-02 2020-08-04 杭州迪普科技股份有限公司 List paging quick response system and method
CN111488370B (en) * 2020-04-02 2023-09-12 杭州迪普科技股份有限公司 List paging quick response system and method
CN112069207A (en) * 2020-08-27 2020-12-11 重庆攸亮科技股份有限公司 Multi-table combined query efficiency improving method
CN112069207B (en) * 2020-08-27 2023-10-03 重庆攸亮科技股份有限公司 Multi-table joint query efficiency improving method

Also Published As

Publication number Publication date
CN105468644B (en) 2018-11-23

Similar Documents

Publication Publication Date Title
CN105468644A (en) Method and device for performing query in database
US10282439B2 (en) Storing and querying multidimensional data using first and second indicies
JP6356675B2 (en) Aggregation / grouping operation: Hardware implementation of hash table method
KR101467589B1 (en) Dynamic fragment mapping
CN105354151B (en) Cache management method and equipment
US8862566B2 (en) Systems and methods for intelligent parallel searching
CN110019540B (en) Implementation method, display method, device and equipment of enterprise atlas
CN108932257B (en) Multi-dimensional data query method and device
US11288287B2 (en) Methods and apparatus to partition a database
US20190121901A1 (en) Database Sharding
CN105488050A (en) Database multi-index method, apparatus and system
CN107704202B (en) Method and device for quickly reading and writing data
US9128944B2 (en) File system enabling fast purges and file access
US9235613B2 (en) Flexible partitioning of data
CN105447030A (en) Index processing method and equipment
CN105373376A (en) Method and apparatus for configuring a software application
CN104281535A (en) Method and device for processing mapping tables in memory
US20170083537A1 (en) Mapping logical identifiers using multiple identifier spaces
CN104598652B (en) A kind of data base query method and device
CN109388644B (en) Data updating method and device
CN107239568B (en) Distributed index implementation method and device
CN111125216B (en) Method and device for importing data into Phoenix
US8775342B2 (en) Incremental context accumulating systems with information co-location for high performance and real-time decisioning systems
CN109271097A (en) Data processing method, data processing equipment and server
CN103810114A (en) Method and device for distributing storage space

Legal Events

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

Effective date of registration: 20180508

Address after: Cayman Islands, Grand Cayman Island capital building, four level 847 box

Applicant after: CAINIAO SMART LOGISTICS HOLDING Ltd.

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

Applicant before: ALIBABA GROUP HOLDING Ltd.

TA01 Transfer of patent application right
GR01 Patent grant
GR01 Patent grant