Embodiment
For making goal of the invention of the present invention, feature, advantage can be more obvious and understandable, below in conjunction with the accompanying drawing in the embodiment of the present invention, technical scheme in the embodiment of the present invention is clearly and completely described, obviously, described embodiment is only the present invention's part embodiment, but not whole embodiment.Embodiment based in the present invention, those of ordinary skills, not making the every other embodiment obtaining under creative work prerequisite, belong to the scope of protection of the invention.
First explanation is, a kind of multilist data correlation enquiring and optimizing method in the embodiment of the present invention and data query application of installation are in Database Systems, these Database Systems comprise two above databases, user can be according to data type, data frequency of utilization, data are used distribution situation, the factors such as the size of data volume are carried out flexible distributed deployment to depositing of data, for example, tentation data storehouse system comprises database A and database B, the handling capacity of database A is higher than the handling capacity of database B, the larger tables of data of data volume can be left in database A, the less tables of data of data volume is left in database B, again for example, hot spot data (as the data of nearest 2 years) can be stored in database A, non-hot spot data (as the data before 2 years) is stored in database B, by rational deposit data, configure further Optimized Database System.
Below a kind of multilist data correlation enquiring and optimizing method in the embodiment of the present invention is described, refers to Fig. 1, the multilist data correlation enquiring and optimizing method in the embodiment of the present invention, comprising:
If the data of 101 requesting queries relate to two above tables of data,, the data of requesting query are divided into groups, the data that belong to same tables of data are divided in same inquiry group, wherein, belong to the data of different pieces of information table in different inquiry groups;
In the embodiment of the present invention, data query device is according to the tables of data under data, data to requesting query are divided into groups, the data that belong to same tables of data are divided in same inquiry group, and the data that belong to different pieces of information table are divided in different inquiry groups, to multi-table query is split as to a plurality of single table inquiries.
The embodiment of the present invention, data query device can be according to the tables of data under the allocation list data query in Database Systems and the stored database of each tables of data, concrete, the corresponding relation that allocation list comprises data rows sign and tables of data sign, the data rows of each data is designated known, therefore, data query device can be known the data rows under each data according to the data rows sign of the data of requesting query, further, according to the corresponding relation of the data rows sign comprising in allocation list and tables of data sign, know the tables of data that each data are affiliated, the data that belong to same tables of data are divided in same inquiry group, the data that belong to different pieces of information table are divided in different inquiry groups.It should be noted that, for some data, it may only belong to a tables of data, or, also may belong to a plurality of tables of data.
102,, for each inquiry group, the corresponding database using while determining the data of inquiring about this inquiry group, from the data of this inquiry group of this data base querying;
In the embodiment of the present invention, the different pieces of information of same tables of data can leave in disparate databases, for example, the data that in certain tables of data, frequency of utilization is high or recent data (as the data of nearest 1 month) can be left in memory database, by other deposit data for example, in other database (relevant database), therefore, after step 101, data query device is the corresponding database using while further determining the data of inquiring about this inquiry group, inquires about the data of this inquiry group from associated databases.
Alternatively, in one implementation, data query device is according to the enquiry frequency of the data of inquiry group, the corresponding database using while determining the data of the above-mentioned inquiry group of inquiry.Illustrate, tentation data storehouse system by enquiry frequency higher than the deposit data of certain predetermined frequency value in database A, by enquiry frequency not higher than the deposit data of this predetermined frequency value in database B, for enquiry frequency in inquiry group higher than the data of this predetermined frequency value, when data query device is determined these data of inquiry, the database of corresponding use is database A, for enquiry frequency in inquiry group, lower than the data of this predetermined frequency value, when data query device is determined these data of inquiry, the database of corresponding use is database B.
Alternatively, in another kind of implementation, data query device is according to the time interval scope of the data of inquiry group, the corresponding database using while determining the data of the above-mentioned inquiry group of inquiry.Illustrate, tentation data storehouse system by the deposit data before 2000 in certain tables of data in database A, by the deposit data of 2000 to 2010 in this tables of data in database B, by later deposit data in 2010 in database C, for the data of time interval scope before 2000 in inquiry group, when data query device is determined these data of inquiry, the database of corresponding use is database A, for the data of time interval scope between 2000 to 2010 in inquiry group, when data query device is determined these data of inquiry, the database of corresponding use is database B, for the data of time interval scope after 2010 in inquiry group, when data query device is determined these data of inquiry, the database of corresponding use is database C.It should be noted that, the time interval scope of data was determined according to the time of these data that record in Database Systems.
Alternatively, in another implementation, data query device is according to preset tables of data and the corresponding relation of database, the corresponding database using while determining the data of the above-mentioned inquiry group of inquiry.Illustrate, tentation data storehouse system leaves the larger tables of data (being assumed to be table 1) of data volume in database A in, the less tables of data of data volume (being assumed to be table 2) is left in database B, and at the preset table 1 of Database Systems and the corresponding relation of database A and the corresponding relation of table 2 and database B, for example, in the allocation list that can mention in step 101, configure 1 with the corresponding relation of database A and the corresponding relation of table 2 and database B, data query device is according to the corresponding relation of table 1 and database A, in the time of can determining the data in question blank 1, the corresponding database using is database B, according to the corresponding relation of table 2 and database B, while determining the data in question blank 2, the corresponding database using is database B.
When determine with the corresponding use of inquiry group database time, data query device can be according to the type of database, for example, after the assembled good query statement of data query algorithm (Oracle or SQL Server) that uses this database to support, send to this database, to inquire about the data of this inquiry group from this database, database, when receiving query statement, returns to the Query Result of this inquiry group to data query device according to this query statement.
In the embodiment of the present invention, can enable multithreading to the parallel processing of multiple queries group, multiple queries group is performed step to the operation in 102 simultaneously.
103, the data that inquire all inquiry groups are merged to generated query result;
Alternatively, in one implementation, the data rows that data query device contains according to the packet of requesting query generates ranks matrix bitmap, and wherein, the data rows that the row of above line column matrix bitmap contain with the packet of above-mentioned requesting query is corresponding one by one; According to default major key, by the data stuffing of each inquiry group inquiring, in above line column matrix bitmap, wherein, the row of above line column matrix bitmap is corresponding one by one with the data of above-mentioned default major key; Ranks matrix bitmap after padding data is defined as to above-mentioned Query Result.In the embodiment of the present invention, above-mentioned major key is also primary key, the one or more fields in tables of data, the value of major key is used for a certain record of identification data table uniquely, above-mentioned major key can be the major key of Database Systems acquiescence, or, also can be configured by User Defined, be not construed as limiting herein.
In above-mentioned implementation, the content pointers of data of each record of ranks matrix bitmap, optionally, for each position of ranks matrix bitmap arranges Data Identification position, for example, when certain Data Identification position of ranks matrix bitmap is invalid value (being 0), show that this position does not have padding data, for example, when certain Data Identification position of ranks matrix bitmap is effective value (being 1), show this position padding data.Data query device is according to default major key, the data stuffing of each inquiry group inquiring is in above line column matrix bitmap, concrete, in merging process, when the value of major key does not appear in ranks matrix bitmap, it in this ranks matrix bitmap, is newly-built a line of value of this major key.
In embodiments of the present invention, data query device also can merge the data that inquire all inquiry groups by alternate manner, for example, obstructed space column matrix bitmap and directly according to default major key, the data that inquire all inquiry groups being merged does not limit herein.
Further, after step 103, data query device outputs to display interface by the Query Result of generation and shows, or, if being upper layer application, data query initiates, data query device sends to this upper layer application by the Query Result of generation, so that this upper layer application utilizes Query Result to carry out data analysis or other operation.
It should be noted that, the type of database that the Database Systems in the embodiment of the present invention comprise includes but not limited to hierarchical data storehouse, reticular pattern database and relevant database.
Therefore, Database Systems in the present invention comprise plural database, when data query, the data of requesting query are divided into groups and determined the corresponding database using of each inquiry group, from established data storehouse, inquire about respectively the data of respective queries group, finally the data of all inquiry groups that inquire are merged, generated query result, on the one hand, based on technical scheme of the present invention, mass data separately can be left in a plurality of databases, reduce the pressure in individual data storehouse, on the other hand, technical scheme of the present invention is divided into a plurality of single table inquiries by multi-table query, simplified query logic, can obtain quickly Query Result, improved the speed of data query.
For ease of understanding better the multilist data correlation enquiring and optimizing method in the embodiment of the present invention, with an application scenarios, the multilist data correlation enquiring and optimizing method in the embodiment of the present invention is described below, refer to Fig. 2, comprising:
201, receive data query request;
Data query device receives data query request, and wherein, above-mentioned data query request may be from user, also may be from upper layer application.
Above-mentioned data query request comprises: the data rows sign of the data of requesting query.
Whether the data that 202, judge above-mentioned data query request requesting query relate to two above tables of data;
Data query device is the corresponding relation with tables of data according to data rows sign, whether the data that judge above-mentioned data query request requesting query relate to two above tables of data, if do not relate to two above tables of data, perform step 203 and step 207, if relate to two above tables of data, perform step 204 to 207.
203, fill order shows inquiry;
Particularly, single table inquiry can, with reference to the single table query scheme in existing database, repeat no more herein.
204, the data of requesting query are divided into groups, the data that belong to same tables of data are divided in same inquiry group, wherein, belong to the data of different pieces of information table in different inquiry groups;
Data query device divides into groups the data to requesting query, to multi-table query is split as to a plurality of single table inquiries.
The embodiment of the present invention, data query device can be according to the tables of data under the allocation list data query in Database Systems and the stored database of each tables of data, concrete, the corresponding relation that allocation list comprises data rows sign and tables of data sign, the data rows of each data is designated known, therefore, data query device can be known the data rows under each data according to the data rows sign of the data of requesting query, further, according to the corresponding relation of the data rows sign comprising in allocation list and tables of data sign, know the tables of data that each data are affiliated, the data that belong to same tables of data are divided in same inquiry group, the data that belong to different pieces of information table are divided in different inquiry groups.It should be noted that, for some data, it may only belong to a tables of data, or, also may belong to a plurality of tables of data.
205,, for each inquiry group, the corresponding database using while determining the data of inquiring about this inquiry group, from the data of this inquiry group of this data base querying;
The specific implementation of step 205 can, with reference to the description in step 102 embodiment illustrated in fig. 1, repeat no more herein.
206, the data that inquire all inquiry groups are merged to generated query result;
The specific implementation of step 206 can, with reference to the description in step 103 embodiment illustrated in fig. 1, repeat no more herein.
207, output Query Result;
Data query device outputs to display interface by final Query Result and shows, or, if data query is upper layer application, initiate, data query device sends to this upper layer application by final Query Result, so that this upper layer application utilizes Query Result to carry out data analysis or other operation.
It should be noted that, the type of database that the Database Systems in the embodiment of the present invention comprise includes but not limited to hierarchical data storehouse, reticular pattern database and relevant database.
Therefore, Database Systems in the present invention comprise plural database, when data query, the data of requesting query are divided into groups and determined the corresponding database using of each inquiry group, from established data storehouse, inquire about respectively the data of respective queries group, finally the data of all inquiry groups that inquire are merged, generated query result, on the one hand, based on technical scheme of the present invention, mass data separately can be left in a plurality of databases, reduce the pressure in individual data storehouse, on the other hand, technical scheme of the present invention is divided into a plurality of single table inquiries by multi-table query, simplified query logic, can obtain quickly Query Result, improved the speed of data query.
The embodiment of the present invention also provides a kind of data query device, and as shown in Figure 3, the data query device 300 in the embodiment of the present invention comprises:
Inquiry split cells 301, when relating to more than two tables of data when the data of requesting query, the data of requesting query are divided into groups, the data that belong to same tables of data are divided in same inquiry group, wherein, the data that belong to different pieces of information table are in different inquiry groups;
Determining unit 302, for each the inquiry group splitting for inquiry split cells 301, the corresponding database using while determining the data of inquiring about above-mentioned inquiry group;
Query execution unit 303, for each the inquiry group splitting for above-mentioned inquiry split cells, that from determining unit 302, determines organizes corresponding database with inquiry, inquires about the data of above-mentioned inquiry group;
Merge cells 304, merges generated query result for the data of all inquiry groups that query execution unit 303 is inquired.
Alternatively, determining unit 302 specifically for: according to the enquiry frequency of the data of inquiry group, the corresponding database using while determining the data of the above-mentioned inquiry group of inquiry.
Alternatively, determining unit 302 specifically for: according to the time interval scope of the data of inquiry group, the corresponding database using while determining the data of the above-mentioned inquiry group of inquiry.
Alternatively, determining unit 302 specifically for: according to preset tables of data and the corresponding relation of database, the corresponding database using while determining the data of the above-mentioned inquiry group of inquiry.
Alternatively, on basis embodiment illustrated in fig. 3, merge cells 304 comprises: generation unit, generates ranks matrix bitmap for the data rows containing according to the packet of above-mentioned requesting query, wherein, the data rows that the row of above line column matrix bitmap and the packet of above-mentioned requesting query contain is corresponding one by one; Data stuffing unit, for according to default major key, by the data stuffing of each inquiry group inquiring, in above line column matrix bitmap, wherein, the row of above line column matrix bitmap is corresponding one by one with the value of above-mentioned default major key; Sub-determining unit, for being defined as above-mentioned Query Result by the ranks matrix bitmap after padding data.
It should be noted that, data query device in the embodiment of the present invention can be as the data query device in above-mentioned embodiment of the method, can be for realizing the whole technical schemes in said method embodiment, the function of its each functional module can be according to the method specific implementation in said method embodiment, its specific implementation process can, with reference to the associated description in above-described embodiment, repeat no more herein.
In the several embodiment that provide in the application, should be understood that disclosed apparatus and method can realize by another way.For example, device embodiment described above is only schematic, for example, the division of described unit, be only that a kind of logic function is divided, during actual realization, can have other dividing mode, for example a plurality of unit or assembly can in conjunction with or can be integrated into another system, or some features can ignore, or do not carry out.Another point, shown or discussed coupling each other or direct-coupling or communication connection can be by some interfaces, indirect coupling or the communication connection of device or unit can be electrically, machinery or other form.
The described unit as separating component explanation can or can not be also physically to separate, and the parts that show as unit can be or can not be also physical locations, can be positioned at a place, or also can be distributed in a plurality of network element.Can select according to the actual needs some or all of unit wherein to realize the object of the present embodiment scheme.
In addition, each functional unit in each embodiment of the present invention can be integrated in a processing unit, can be also that the independent physics of unit exists, and also can be integrated in a unit two or more unit.Above-mentioned integrated unit both can adopt the form of hardware to realize, and also can adopt the form of SFU software functional unit to realize.
If the form of SFU software functional unit of usining described integrated unit realizes and during as production marketing independently or use, can be stored in a computer read/write memory medium.Understanding based on such, the all or part of of the part that technical scheme of the present invention contributes to prior art in essence in other words or this technical scheme can embody with the form of software product, this computer software product is stored in a storage medium, comprise that some instructions are with so that a computer equipment (can be personal computer, server, or the network equipment etc.) carry out all or part of step of method described in each embodiment of the present invention.And aforesaid storage medium comprises: USB flash disk, portable hard drive, ROM (read-only memory) (ROM, Read-Only Memory), the various media that can be program code stored such as random access memory (RAM, Random Access Memory), magnetic disc or CD.
It should be noted that, for aforesaid each embodiment of the method, for easy description, therefore it is all expressed as to a series of combination of actions, but those skilled in the art should know, the present invention is not subject to the restriction of described sequence of movement, because according to the present invention, some step can adopt other order or carry out simultaneously.Secondly, those skilled in the art also should know, the embodiment described in instructions all belongs to preferred embodiment, and related action and module might not be all that the present invention is necessary.
In the above-described embodiments, the description of each embodiment is all emphasized particularly on different fields, in certain embodiment, there is no the part of detailed description, can be referring to the associated description of other embodiment.
It is more than the description of a kind of multilist data correlation enquiring and optimizing method provided by the present invention and device, for one of ordinary skill in the art, thought according to the embodiment of the present invention, all will change in specific embodiments and applications, to sum up, this description should not be construed as limitation of the present invention.