CN104794130A - Inter-table correlation query method and device - Google Patents

Inter-table correlation query method and device Download PDF

Info

Publication number
CN104794130A
CN104794130A CN201410026270.XA CN201410026270A CN104794130A CN 104794130 A CN104794130 A CN 104794130A CN 201410026270 A CN201410026270 A CN 201410026270A CN 104794130 A CN104794130 A CN 104794130A
Authority
CN
China
Prior art keywords
mark
identifies
result
list item
value
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
CN201410026270.XA
Other languages
Chinese (zh)
Other versions
CN104794130B (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.)
XFusion Digital Technologies Co Ltd
Original Assignee
Huawei Technologies Co 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 Huawei Technologies Co Ltd filed Critical Huawei Technologies Co Ltd
Priority to CN201410026270.XA priority Critical patent/CN104794130B/en
Publication of CN104794130A publication Critical patent/CN104794130A/en
Application granted granted Critical
Publication of CN104794130B publication Critical patent/CN104794130B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Abstract

The invention provides an inter-table correlation query method and device. The inter-table correlation query method and device can shorten the time of inter-table correlation query and increase the speed of inter-table correlation query. The method includes the steps that query indicating information is obtained, the query indicating information carries a first query condition, and instruction is conducted, so that a first query result is obtained from N tables according to the first query condition; the Mth corresponding relation between the Mth table and the (M+1)th table is established according to the correlation relation between the major key value of the Mth table in the N tables and the foreign key value of the (M+1)th table; the first query result is obtained according to the selection conditions in all the N tables in the first query condition and the number of times of the Mth identification corresponding to the (M+1)th identification in the Mth corresponding relation. The inter-table correlation query method and device are suitable for the field of computers.

Description

Relation query method and device between a kind of table
Technical field
The present invention relates to field of computer technology, particularly relate to relation query method and device between a kind of table.
Background technology
In data warehouse and online analysis process process (OLAP) field, the quick response of inquiry is particularly important, in OLAP field, inquiry needs process G level, T the level even data volume of P level, when big data quantity like this, require the quick response of inquiry, very large challenge is proposed to Database Performace, in a large amount of query statements, the association join that capital comprises between two tables operates, and occupy main query time, therefore promote correlation inquiry speed between table particularly important to data base querying performance.
In prior art, there is the direction of correlation inquiry between the following two kinds table:
The first, inquire about according to alternative condition in two tables respectively, finally join operation is carried out to the result after selection;
Second, first in the first table, inquiry acquisition first result is carried out according to the alternative condition in the first table, then the first result and second are shown to carry out join operation, then inquire about according to the alternative condition in the second table on join operating result, obtain the second result, finally the first result and the second result are carried out join operation, upgrade the first result.
Join operation at least one times is all related in direction due to inquiry between above-mentioned two kinds of tables, and join action need his-and-hers watches travel through, therefore elapsed time is larger, although propose some improvement projects for second direction in prior art, the such as example of embodiment part, but owing to still there is join operation at least one times, therefore elapsed time is still larger, reduce the speed of correlation inquiry between table, have impact on query performance.
Summary of the invention
Embodiments of the invention provide relation query method and device between a kind of table, can reduce the time of correlation inquiry between showing, improve the speed of correlation inquiry between table.
For achieving the above object, embodiments of the invention adopt following technical scheme:
First aspect, provide relation query method between a kind of table, described method comprises:
Obtain inquiry Indication message, described inquiry Indication message carries the first querying condition, instruction obtains the first Query Result according to described first querying condition in N number of table, wherein, described first querying condition comprises: the incidence relation between the foreign key value that in the alternative condition in described N number of table in each table and described N number of table, the Major key of M table and M+1 show, 1≤M≤N-1 is integer, and described first table is the table sorted from small to large in described N number of table to described N table;
According to the incidence relation between the foreign key value that Major key and the M+1 of M table in N number of table described in described first querying condition show, set up the M corresponding relation that described M shows to show with described M+1, comprise the information of M mark in described M corresponding relation, to identify the information that corresponding M+1 identifies with described M, described M identifies the number of times that corresponding described M+1 identifies, wherein, described M is designated the list item sequence number in described M table, and described M+1 is designated the list item sequence number in described M+1 table;
According to the alternative condition in each table in N number of table described in described first querying condition, and M described in described M corresponding relation identifies the number of times of corresponding described M+1 mark, obtains described first Query Result.
In the first possible implementation of first aspect, in conjunction with first aspect, described according to the alternative condition in each table in N number of table described in described first querying condition, and M described in described M corresponding relation identifies the number of times of corresponding described M+1 mark, obtains described first Query Result and comprises:
According to the alternative condition in the first table in described first querying condition, inquire about described first table, and obtain the first set, wherein, in described first set, comprise the first mark of the list item of the alternative condition met in described first table;
According to the value of M, circulation performs step S1-S3, until the value of M is all finished:
S1, according to described M corresponding relation and 2M-1 set, determine that 2M gathers, and each M in described 2M-1 set identifies the number of times TM of the M+1 mark in corresponding described 2M set, wherein, comprise the M in gathering with described 2M-1 in described 2M set to identify corresponding M+1 and identify;
S2, according in described first querying condition M+1 table in alternative condition, inquire about the list item of the M+1 mark correspondence in M+1 table in 2M set, and obtain 2M+1 set, wherein, comprise in described 2M+1 set and meet the M+1 mark that described M+1 shows the list item of interior alternative condition;
S3, according to described 2M+1 set, upgrade described TM;
According to the TM after described 2M-1 set, described 2M+1 set and described renewal, obtain described first Query Result.
In the implementation that first aspect the second is possible, in conjunction with the first possible implementation of first aspect, described according to the TM after described 2M-1 set, described 2M+1 set and described renewal, obtain described first Query Result and comprise:
If N=2, according to described first set, described 3rd set, and the T1 after described renewal, obtain described first Query Result;
If N > 2, according to the value of K, circulation performs step L1, until the value of K is all finished, wherein, 2≤K≤N-1 is integer:
L1, according to K result, T(K-1 after TK after described renewal and described renewal), obtain K+1 result, wherein, second result is initialization value 0, comprises described 2(K-i in described K+1 result) number of times of K+1 mark in-1 set in the corresponding described 2K set of each K-i mark, wherein, 1≤i≤K-1 is integer;
According to N result, the T(N-1 after described renewal) and described 2M-1 gathers, described 2M+1 gathers, and obtains described first Query Result.
In the third possible implementation of first aspect, in conjunction with first aspect, described according to the alternative condition in each table in N number of table described in described first querying condition, and M described in described M corresponding relation identifies the number of times of corresponding described M+1 mark, obtains described first Query Result and comprises:
According to the alternative condition in the first table in described first querying condition, inquire about described first table, and obtain the first set, wherein, in described first set, comprise the first mark of the list item of the alternative condition met in described first table;
According to the value of M, circulation performs step S1-S4, until the value of M is all finished:
S1, according to described M corresponding relation and 3M-2 set, determine that 3M-1 gathers, and each M in described 3M-2 set identifies the number of times TM of the M+1 mark in corresponding described 3M-1 set, wherein, comprise the M in gathering with described 3M-2 in described 3M-1 set to identify corresponding M+1 and identify;
S2, according to the alternative condition in the M+1 table in described first querying condition, inquire about M+1 table, and obtain 3M set, wherein, comprise in described 3M set meet described M+1 show in the M+1 mark of list item of alternative condition;
S3, to gather according to described 3M-1 set and described 3M, obtain 3M+1 set, wherein, described 3M+1 set comprise meet described M+1 show in alternative condition and the list item that corresponding M identifies meet described M show in the M+1 mark of list item of alternative condition;
S4, according to described 3M+1 set, upgrade described TM;
According to the TM after described 3M-2 set, described 3M+1 set and described renewal, obtain described first Query Result.
In first aspect the 4th kind of possible implementation, in conjunction with the third possible implementation of first aspect, described according to the TM after described 3M-2 set, described 3M+1 set and described renewal, obtain described first Query Result and comprise:
If N=2, according to described first set, described 4th set, and the T1 after described renewal, obtain described first Query Result;
If N > 2, according to the value of K, circulation performs step L1, until the value of K is all finished, wherein, 2≤K≤N-1 is integer:
L1, according to K result, T(K-1 after TK after described renewal and described renewal), obtain K+1 result, wherein, second result is initialization value 0, comprises described 3(K-i in described K+1 result) number of times of K+1 mark in-2 set in the corresponding described 3K-1 set of each K-i mark, wherein, 1≤i≤K-1 is integer;
According to N result, the T(N-1 after described renewal) and described 3M-2 gathers, described 3M+1 gathers, and obtains described first Query Result.
In first aspect the 5th kind of possible implementation, in conjunction with first aspect to first aspect the 4th kind of possible implementation, described M corresponding relation comprises:
Described M mark identifies the corresponding relation of the number of times that corresponding described M+1 identifies with described M, described M+1 identifies the ltsh chain table identifying corresponding Major key with described M.
In first aspect the 6th kind of possible implementation, in conjunction with first aspect to first aspect the 4th kind of possible implementation, incidence relation between the foreign key value that the described Major key according to M table in N number of table described in described first querying condition and M+1 are shown, before setting up the M corresponding relation that described M shows and described M+1 shows, also comprise:
Determine whether the M+1 mark of the list item that in described M+1 table, foreign key value is identical is continuous;
If the M+1 mark of the list item that foreign key value is identical is discontinuous in described M+1 table, sort to the list item in described M+1 table, the M+1 mark of the list item that in showing to make described M+1, foreign key value is identical continuously;
Described M corresponding relation comprises:
Described M mark identifies the corresponding relation of the number of times that corresponding described M+1 identifies with described M, described M identifies and identifies first corresponding corresponding relation that M+1 identifies with described M.
Second aspect, provide correlation inquiry device between a kind of table, described device comprises message retrieval unit, relation sets up unit, result acquiring unit;
Described message retrieval unit, for obtaining inquiry Indication message, described inquiry Indication message carries the first querying condition, instruction obtains the first Query Result according to described first querying condition in N number of table, wherein, described first querying condition comprises: the incidence relation between the foreign key value that in the alternative condition in described N number of table in each table and described N number of table, the Major key of M table and M+1 show, 1≤M≤N-1, for integer, described first table is the table sorted from small to large in described N number of table to described N table;
Described relation sets up unit, for the incidence relation between the foreign key value that Major key and the M+1 of M table in N number of table described in the first querying condition of carrying in the inquiry Indication message that obtains according to described message retrieval unit show, set up the M corresponding relation that described M shows to show with described M+1, the information of M mark is comprised in described M corresponding relation, the information that corresponding M+1 identifies is identified with described M, the number of times of the corresponding described M+1 mark of described M mark, wherein, described M is designated the list item sequence number in described M table, described M+1 is designated the list item sequence number in described M+1 table,
Described result acquiring unit, for the alternative condition in each table in N number of table described in the first querying condition of carrying in the inquiry Indication message that obtains according to described message retrieval unit, and described relation sets up the number of times of the corresponding described M+1 mark of M mark described in described M corresponding relation that unit sets up, obtains described first Query Result.
In the first possible implementation of second aspect, in conjunction with second aspect, described result acquiring unit comprises enquiry module, the first execution module, the first acquisition module;
Described enquiry module, for the alternative condition in the first table in the first querying condition of carrying in the inquiry Indication message that obtains according to described message retrieval unit, inquire about described first table, and obtain the first set, wherein, the first mark of the list item of the alternative condition met in described first table is comprised in described first set;
Described first execution module, for the value according to M, circulation performs step S1-S3, until the value of M is all finished:
S1, the described M corresponding relation setting up unit foundation according to described relation and 2M-1 set, determine that 2M gathers, and each M in described 2M-1 set identifies the number of times TM of the M+1 mark in corresponding described 2M set, wherein, comprise the M in gathering with described 2M-1 in described 2M set to identify corresponding M+1 and identify;
S2, according in described first querying condition M+1 table in alternative condition, inquire about the list item of the M+1 mark correspondence in M+1 table in 2M set, and obtain 2M+1 set, wherein, comprise in described 2M+1 set and meet the M+1 mark that described M+1 shows the list item of interior alternative condition;
S3, according to described 2M+1 set, upgrade described TM;
Described first acquisition module, for according to the TM after described 2M-1 set, described 2M+1 set and described renewal, obtains described first Query Result.
In the implementation that second aspect the second is possible, in conjunction with the first possible implementation of second aspect, described first acquisition module specifically for:
If N=2, according to described first set, described 3rd set, and the T1 after described renewal, obtain described first Query Result;
If N > 2, according to the value of K, circulation performs step L1, until the value of K is all finished, wherein, 2≤K≤N-1 is integer:
L1, according to K result, T(K-1 after TK after described renewal and described renewal), obtain K+1 result, wherein, second result is initialization value 0, comprises described 2(K-i in described K+1 result) number of times of K+1 mark in-1 set in the corresponding described 2K set of each K-i mark, wherein, 1≤i≤K-1 is integer;
According to N result, the T(N-1 after described renewal) and described 2M-1 gathers, described 2M+1 gathers, and obtains described first Query Result.
In the third possible implementation of second aspect, in conjunction with second aspect, described result acquiring unit comprises enquiry module, the second execution module, the second acquisition module;
Described enquiry module, for the alternative condition in the first table in the first querying condition of carrying in the inquiry Indication message that obtains according to described message retrieval unit, inquire about described first table, and obtain the first set, wherein, the first mark of the list item of the alternative condition met in described first table is comprised in described first set;
Described second execution module, for the value according to M, circulation performs step S1-S4, until the value of M is all finished:
S1, according to described M corresponding relation and 3M-2 set, determine that 3M-1 gathers, and each M in described 3M-2 set identifies the number of times TM of the M+1 mark in corresponding described 3M-1 set, wherein, comprise the M in gathering with described 3M-2 in described 3M-1 set to identify corresponding M+1 and identify;
S2, according to the alternative condition in the M+1 table in described first querying condition, inquire about M+1 table, and obtain 3M set, wherein, comprise in described 3M set meet described M+1 show in the M+1 mark of list item of alternative condition;
S3, to gather according to described 3M-1 set and described 3M, obtain 3M+1 set, wherein, described 3M+1 set comprise meet described M+1 show in alternative condition and the list item that corresponding M identifies meet described M show in the M+1 mark of list item of alternative condition;
S4, according to described 3M+1 set, upgrade described TM;
Described second acquisition module, for according to the TM after described 3M-2 set, described 3M+1 set and described renewal, obtains described first Query Result.
In second aspect the 4th kind of possible implementation, in conjunction with the third possible implementation of second aspect, described second acquisition module specifically for:
If N=2, according to described first set, described 4th set, and the T1 after described renewal, obtain described first Query Result;
If N > 2, according to the value of K, circulation performs step L1, until the value of K is all finished, wherein, 2≤K≤N-1 is integer:
L1, according to K result, T(K-1 after TK after described renewal and described renewal), obtain K+1 result, wherein, second result is initialization value 0, comprises described 3(K-i in described K+1 result) number of times of K+1 mark in-2 set in the corresponding described 3K-1 set of each K-i mark, wherein, 1≤i≤K-1 is integer;
According to N result, the T(N-1 after described renewal) and described 3M-2 gathers, described 3M+1 gathers, and obtains described first Query Result.
In second aspect the 5th kind of possible implementation, in conjunction with second aspect to second aspect the 4th kind of possible implementation, described M corresponding relation comprises:
Described M mark identifies the corresponding relation of the number of times that corresponding described M+1 identifies with described M, described M+1 identifies the ltsh chain table identifying corresponding Major key with described M.
In second aspect the 6th kind of possible implementation, in conjunction with second aspect to second aspect the 4th kind of possible implementation, described device also comprises determining unit, sequencing unit;
Described determining unit, for the incidence relation between the foreign key value that the Major key and M+1 of setting up M table in N number of table described in the first querying condition of carrying in inquiry Indication message that unit obtains according to described message retrieval unit in described relation are shown, before setting up the M corresponding relation that described M shows and described M+1 shows, determine whether the M+1 mark of the list item that in described M+1 table, foreign key value is identical is continuous;
Described sequencing unit, if determine that the M+1 mark of the list item that in described M+1 table, foreign key value is identical is discontinuous for described determining unit, sort to the list item in described M+1 table, the M+1 mark of the list item that in showing to make described M+1, foreign key value is identical continuously;
Described M corresponding relation comprises:
Described M mark identifies the corresponding relation of the number of times that corresponding described M+1 identifies with described M, described M identifies and identifies first corresponding corresponding relation that M+1 identifies with described M.
The third aspect, correlation inquiry device between a kind of table is provided, described device comprises processor and storer, described storer and described processor communication, program code stored in described storer, and described processor is for calling the program code stored in described storer, performs the method as described in any one of first aspect.
The embodiment of the present invention provides relation query method and device between a kind of table, described method comprises: obtain inquiry Indication message, described inquiry Indication message carries the first querying condition, instruction obtains the first Query Result according to described first querying condition in N number of table, wherein, described first querying condition comprises: the alternative condition in described N number of table in each table, and the incidence relation between the Major key that in described N number of table, M shows and the foreign key value that M+1 shows, 1≤M≤N-1, for integer, described first table is the table sorted from small to large in described N number of table to described N table, according to the incidence relation between the foreign key value that Major key and the M+1 of M table in N number of table described in described first querying condition show, set up the M corresponding relation that described M shows to show with described M+1, comprise the information of M mark in described M corresponding relation, to identify the information that corresponding M+1 identifies with described M, described M identifies the number of times that corresponding described M+1 identifies, wherein, described M is designated the list item sequence number in described M table, and described M+1 is designated the list item sequence number in described M+1 table, according to the alternative condition in each table in N number of table described in described first querying condition, and M described in described M corresponding relation identifies the number of times of corresponding described M+1 mark, obtains described first Query Result.Based on relation query method and device between the table that the embodiment of the present invention provides, due to after acquisition inquiry Indication message, according to the incidence relation between the foreign key value that Major key and the M+1 of M table in N number of table described in the first querying condition carried in described inquiry Indication message show, establish the M corresponding relation that described M shows to show with described M+1, and comprise the number of times of the corresponding described M+1 mark of M mark in described M corresponding relation, make obtaining in each table after corresponding Query Result according to the alternative condition in each table in N number of table of carrying in inquiry Indication message, the number of times of corresponding described M+1 mark can be identified according to M described in described M corresponding relation, the basis of this Query Result obtains the first Query Result fast, without the need to carrying out join operation, Query Result is traveled through successively, reduce the time of correlation inquiry between table, improve inquiry velocity, and then improve query performance.
Accompanying drawing explanation
Relation query method schematic flow sheet between the one table that Fig. 1 provides for the embodiment of the present invention one;
The one first corresponding relation exemplary plot that Fig. 2 provides for the embodiment of the present invention one;
Relation query method schematic flow sheet between the one table that Fig. 3 provides for the embodiment of the present invention two;
A kind of corresponding diagram 3 that Fig. 4 provides for the embodiment of the present invention two show between the case method process flow diagram of relation query method;
The data flow diagram of a kind of corresponding diagram 4 case method process flow diagram that Fig. 5 provides for the embodiment of the present invention two;
Relation query method schematic flow sheet between the another kind table that Fig. 6 provides for the embodiment of the present invention two;
A kind of corresponding diagram 6 that Fig. 7 provides for the embodiment of the present invention two show between the case method process flow diagram of relation query method;
The data flow diagram of a kind of corresponding diagram 7 case method process flow diagram that Fig. 8 provides for the embodiment of the present invention two;
The another kind of corresponding diagram 6 that Fig. 9 provides for the embodiment of the present invention two show between the case method process flow diagram of relation query method;
The data flow diagram of a kind of corresponding diagram 9 case method process flow diagram that Figure 10 provides for the embodiment of the present invention two;
Correlation inquiry apparatus structure schematic diagram one between the one table that Figure 11 provides for the embodiment of the present invention three;
Correlation inquiry apparatus structure schematic diagram two between the one table that Figure 12 provides for the embodiment of the present invention three;
Correlation inquiry apparatus structure schematic diagram three between the one table that Figure 13 provides for the embodiment of the present invention three;
Correlation inquiry apparatus structure schematic diagram four between the one table that Figure 14 provides for the embodiment of the present invention three;
Correlation inquiry apparatus structure schematic diagram between the one table that Figure 15 provides for the embodiment of the present invention four.
Embodiment
When showing in a database to do join operation, there is the relation of 1:N in 2 tables, and the table that wherein " N " is corresponding is called " showing greatly " in join operation, and the table of " 1 " correspondence is called the little table in join operation, and this definition is applicable to the following each embodiment of the present invention.
Suppose to there are following two tables:
Table a:customer (c_custkey, c_name, primary key (c_custkey)),
Table b:orders(o_orderkey, o_custkey, o_orderdate, primary key (o_orderkey),
foreign key(o_custkey)REFERENCES customer(o_custkey));
Wherein show a as follows respectively with the data of table b:
It should be noted that, more than c_name attribute may be there is in table a, in table b, more than o_orderdate attribute may be there is, in two tables, all may there is other attribute, be only that exemplary one of them attribute of enumerating is illustrated, in his-and-hers watches, attribute does not do concrete restriction herein.
Table a
c_oid c_custkey c_name
0 1 " Xiao Ming "
1 2 " Xiao Wang "
2 3 " Xiao Zhang "
3 4 " Xiao Li "
4 5 " little army "
Table b
o_oid o_custkey o_orderdate
0 2 2012-9-02
1 5 2012-9-07
2 4 2012-9-10
3 3 2012-8-21
4 3 2012-8-02
5 1 2012-9-26
6 2 2012-8-20
7 4 2012-8-09
8 2 2012-9-15
Existing query statement A:select o_orderkey from orders, customerwhere c_name in{ " Xiao Wang ", " Xiao Zhang " } and o_orderdate> " 2012-9-01 " and o_custkey=c_custkey;
First, querying method between one group of table of the prior art is provided:
Method one, be described for correlation inquiry direction between the table of first in background technology, implementation is as follows:
1) in customer table, alternative condition c_name in{ " Xiao Wang " is, Xiao Zhang " }, select the c_oid of the condition that is met for (1,2);
2) in orders table, be alternative condition o_orderdate> " 2012-9-01 ", select the o_oid of the condition that is met for (0,1,2,5,8);
3) according to c_oid and the o_oid satisfied condition, carry out join operation, wherein, Correlation Criteria is o_custkey=c_custkey, if with showing a contingency table b, then, when the c_oid in table a is 1, in traversal list b, o_oid is (0,1,2,5,8) list item, obtain meeting the o_oid of Correlation Criteria for (0,8), when the c_oid in table a is 2, in traversal list b, o_oid is (0,1,2,5,8), be there is not the o_oid meeting Correlation Criteria in list item; If with showing b contingency table a, then, when in table b, o_oid is 0, in traversal list a, c_oid is (2,3) list item, obtains meeting the c_oid of Correlation Criteria for (1), in like manner, when the o_oid in table b is respectively 1,2,5, when 8, repeat said process successively, the c_oid finally satisfied condition is (1), and o_oid is (0,8).
Can be learnt by above-mentioned query script, when carrying out join operation to the result after selection, no matter be table a contingency table b, or table b contingency table a, all need to travel through selection result successively, this process is when data volume is larger, the too much time can be consumed, and then affect query performance.
Method two, be described with the example that is improved in correlation inquiry direction between the table of second in background technology, the little table of large table association, implementation is as follows:
1) in data importing process, index between foundation table, the join operation very consuming time just performed when perform statement before substituting, between this table, in index preservation two table there is the identification number of incidence relation in Major key and foreign key value, as shown in Table 1:
Table one
o_oid c_oid
0 1
1 4
2 3
3 2
4 2
5 0
6 1
7 3
8 1
2) in orders table, do alternative condition, find the o_oid value of the o_orderdate> that satisfies condition " 2012-9-01 " for (0,1,2,5,8);
3) utilize the o_oid value obtained and table one, find corresponding c_oid value and duplicate removal, the c_oid value obtained is (Isosorbide-5-Nitrae, 3,0);
4) in c_oid value obtained above, alternative condition c_name in{ " Xiao Wang " is performed, " Xiao Zhang " }, the c_oid value finally satisfied condition is (1);
5) utilize c_oid value (1) and 2) in the corresponding c_oid value of o_oid that obtains carry out join operation, namely when to show the c_oid in a be 1, in traversal list b, o_oid is (0,1,2,5,8) list item, obtains meeting the o_oid of Correlation Criteria for (0,8).
Can be learnt by above-mentioned query script, although the method decreases the join number of operations in correlation inquiry direction between second table, in the end a step still needs to carry out join operation, and this process is when data volume is larger, the too much time can be consumed, and then affect query performance.
Method three, be described with the example that is improved in correlation inquiry direction between the table of second in background technology, little Biao Guan the United Nations General Assembly shows, and implementation is as follows:
1) in data importing process, set up index between vector table, the join operation very consuming time just performed when perform statement before substituting, between this vector table, the c_oid of little table and the bit vector Bitmap of large table preserved in index, the size of this Bitmap is the number of large table, and even the corresponding Major key of this little table c_oid is equal with the foreign key value shown greatly, then this position is set to 1, otherwise be 0, as shown in Table 2:
Table two
c_oid Bitmap
0 000001000
1 100000101
2 000110000
3 001000010
4 010000000
2) in little table customer, do alternative condition, find the c_name in{ " Xiao Wang " that satisfies condition, " Xiao Zhang " } c_oid value be (1,2);
3) utilize the c_oid value obtained and table two, find corresponding vector value (100000101,000110000), corresponding o_oid value can be found for (0,3,4,6,8);
4) in o_oid value obtained above, perform alternative condition o_orderdate> " 2012-9-01 ", the o_oid value finally satisfied condition is (0,8);
5) use the c_oid value and 2 that this o_oid is corresponding) in the c_oid value that obtains be join and operate, the c_oid value finally satisfied condition is (1).
Can be learnt by above-mentioned query script, similar with method two, although the method decreases the join number of operations in correlation inquiry direction between second table, but in the end a step still needs to carry out join operation, this process is when data volume is larger, the too much time can be consumed, and then affect query performance.
Below in conjunction with the accompanying drawing in the embodiment of the present invention, be clearly and completely described the technical scheme in the embodiment of the present invention, obviously, described embodiment is only the present invention's part embodiment, instead of whole embodiments.Based on the embodiment in the present invention, those of ordinary skill in the art, not making the every other embodiment obtained under creative work prerequisite, belong to the scope of protection of the invention.
Embodiment one,
The embodiment of the present invention provides relation query method between a kind of table, specifically as shown in Figure 1, comprising:
101, between table, correlation inquiry device obtains inquiry Indication message, and described inquiry Indication message carries the first querying condition, indicates and in N number of table, obtains the first Query Result according to the first querying condition.
Wherein, described first querying condition comprises: the alternative condition in described N number of table in each table, and the incidence relation between the Major key that in described N number of table, M shows and the foreign key value that M+1 shows, 1≤M≤N-1, for integer, described first table is the table sorted from small to large in described N number of table to described N table.
Concrete, in the embodiment of the present invention, between showing during correlation inquiry, between table, first correlation inquiry device can obtain inquiry Indication message, and this inquiry Indication message carries the first querying condition, indicates current needs to carry out correlation inquiry.
Exemplary, suppose to there is table a and table 2 shown in a b table, the query statement A:select o_orderkey from orders corresponding by above-mentioned table a and table b, customer wherec_name in{ " Xiao Wang ", " Xiao Zhang " } and o_orderdate> " 2012-9-01 " and o_custkey=c_custkey is known, first querying condition comprises: the querying condition c_name in{ " Xiao Wang " in table a, " Xiao Zhang " }, querying condition o_orderdate> " 2012-9-01 " in table b, incidence relation o_custkey=c_custkey between the Major key of table a and the foreign key value of table b.
It should be noted that, the value of N be more than or equal to 2 integer, namely the value of N can be 2,3,4 ..., and 1≤M≤N-1, then exemplary, if the value of N is 2, then the value of M can be 1, namely there is the first table, the second table 2 table; If the value of N is 3, then 1≤M≤2, the value of M can be 1,2, namely there is the first table, the second table, the 3rd table 3 table.
It should be noted that, the first table described in the embodiment of the present invention to described N table is the table of ascending sequence, between follow-up table in correlation inquiry, can reduce the number of times of index or retrieval like this, improve inquiry velocity.
102, between table, correlation inquiry device, according to the incidence relation between the Major key of M table in N number of table described in the first querying condition and the foreign key value show of M+1, sets up the M corresponding relation that described M shows and described M+1 shows.
Comprise the information of M mark in described M corresponding relation, to identify the information that corresponding M+1 identifies with described M, described M identifies the number of times that corresponding described M+1 identifies, wherein, described M is designated the list item sequence number in described M table, and described M+1 is designated the list item sequence number in described M+1 table.
Concrete, in the embodiment of the present invention, described M corresponding relation can comprise that described M mark identifies the corresponding relation of the number of times that corresponding described M+1 identifies with described M, described M+1 identifies the ltsh chain table identifying corresponding Major key with described M; Or,
Incidence relation between the foreign key value that the described Major key according to M table in N number of table described in described first querying condition and M+1 are shown, before setting up the M corresponding relation that described M shows and described M+1 shows, also comprises:
Determine whether the M+1 mark of the list item that in described M+1 table, foreign key value is identical is continuous;
If the M+1 mark of the list item that foreign key value is identical is discontinuous in described M+1 table, sort to the list item in described M+1 table, the M+1 mark of the list item that in showing to make described M+1, foreign key value is identical continuously;
Now, described M corresponding relation comprises:
Described M mark identifies the corresponding relation of the number of times that corresponding described M+1 identifies with described M, described M identifies and identifies first corresponding corresponding relation that M+1 identifies with described M.
It should be noted that, in the embodiment of the present invention, described M is designated the list item sequence number in described M table, described M+1 is designated the list item sequence number in described M+1 table, such as, at table a with table b, first is designated the list item sequence number c_oid in table a, and second is designated the list item sequence number o_oid in table b.
Exemplary, suppose N=2, 2 tables of current existence as shown in table a and table b, then M value is 1, according to the incidence relation o_custkey=c_custkey between the first Major key shown and the second foreign key value shown, the first corresponding relation as shown in Figure 2 can be set up, wherein, corresponding relation 201 in described first corresponding relation is the corresponding relation that the first mark c_oid and first identifies that c_oid corresponding second identifies the number of times of o_oid, ltsh chain table 202 be the second mark o_oid with cryptographic hash associate chained list, wherein cryptographic hash is herein the Major key that the first mark c_oid is corresponding.
Certainly, except the first corresponding relation shown in Fig. 2, as mentioned above, also there is a kind of method setting up the first corresponding relation, namely first determine that whether the second mark o_oid of the list item that in the second table, foreign key value is identical is continuous, if discontinuous, the list item in the second table is sorted, to make the second mark of list item that in the second table, foreign key value is identical continuously.
Exemplary, as can be seen from table b, the second mark o_oid of the list item that in the second table, foreign key value is identical is discontinuous, and first sort to the list item in the second table, result is as table b1:
Table b1
o_oid o_custkey o_orderdate
0 2 2012-9-02
1 2 2012-8-20
2 2 2012-9-15
3 5 2012-9-07
4 4 2012-9-10
5 4 2012-8-09
6 3 2012-8-21
7 3 2012-8-02
8 1 2012-9-26
According to the incidence relation o_custkey=c_custkey between the foreign key value that the Major key and second of the first table shows (showing b2), the first corresponding relation as shown in Table 3 can be set up:
Table three
c_oid o_oid Number of times
1 0 3
4 3 1
3 4 2
2 6 2
0 8 1
It should be noted that, table b1 is only a kind of possible rearrangement result, second of the list item that after the embodiment of the present invention only limits sequence, in the second table, foreign key value is identical identifies continuously, for the sequencing of the different values of o_custkey, the embodiment of the present invention does not do concrete restriction, exemplary, sort to the list item in the second table, result as can also show b2:
Table b2
o_oid o_custkey o_orderdate
0 1 2012-9-26
1 2 2012-9-02
2 2 2012-8-20
3 2 2012-9-15
4 3 2012-8-21
5 3 2012-8-02
6 4 2012-9-10
7 4 2012-8-09
8 5 2012-9-07
According to the incidence relation o_custkey=c_custkey between the foreign key value that the Major key and second of the first table shows (showing b2), the first corresponding relation as shown in Table 4 can be set up:
Table four
c_oid o_oid Number of times
0 0 1
1 1 3
2 4 2
3 6 2
4 8 1
It should be noted that, described first corresponding relation is only conveniently obtain the first Query Result and set up, the first corresponding relation no matter set up is as shown in table three or table four, still as shown in Figure 2, or other possible situation, all do not affect final correlation inquiry result, the embodiment of the present invention does not do concrete restriction to the form of M corresponding relation.
103, between table, correlation inquiry device is according to the alternative condition in each table in N number of table described in the first querying condition, and M described in described M corresponding relation identifies the number of times of corresponding described M+1 mark, obtains described first Query Result.
Concrete, in the embodiment of the present invention, corresponding Query Result in each table can be obtained according to the alternative condition in table each in N number of table, and the number of times of corresponding described M+1 mark is identified according to M described in described M corresponding relation, the first Query Result can being obtained fast on the basis of this Query Result, without the need to carrying out join operation, Query Result being traveled through successively, concrete implementation procedure can with reference to subsequent embodiment, and the embodiment of the present invention does not repeat them here.
The embodiment of the present invention provides relation query method between a kind of table, described method comprises: obtain inquiry Indication message, described inquiry Indication message carries the first querying condition, instruction obtains the first Query Result according to described first querying condition in N number of table, wherein, described first querying condition comprises: the incidence relation between the foreign key value that in the alternative condition in described N number of table in each table and described N number of table, the Major key of M table and M+1 show, 1≤M≤N-1, for integer, described first table is the table sorted from small to large in described N number of table to described N table; According to the incidence relation between the foreign key value that Major key and the M+1 of M table in N number of table described in described first querying condition show, set up the M corresponding relation that described M shows to show with described M+1, comprise the information of M mark in described M corresponding relation, to identify the information that corresponding M+1 identifies with described M, described M identifies the number of times that corresponding described M+1 identifies, wherein, described M is designated the list item sequence number in described M table, and described M+1 is designated the list item sequence number in described M+1 table; According to the alternative condition in each table in N number of table described in described first querying condition, and M described in described M corresponding relation identifies the number of times of corresponding described M+1 mark, obtains described first Query Result.Based on relation query method between the table that the embodiment of the present invention provides, due to after acquisition inquiry Indication message, according to the incidence relation between the foreign key value that Major key and the M+1 of M table in N number of table described in the first querying condition carried in described inquiry Indication message show, establish the M corresponding relation that described M shows to show with described M+1, and comprise the number of times of the corresponding described M+1 mark of M mark in described M corresponding relation, make obtaining in each table after corresponding Query Result according to the alternative condition in each table in N number of table of carrying in inquiry Indication message, the number of times of corresponding described M+1 mark can be identified according to M described in described M corresponding relation, the basis of this Query Result obtains the first Query Result fast, without the need to carrying out join operation, Query Result is traveled through successively, reduce the time of correlation inquiry between table, improve inquiry velocity, and then improve query performance.
Embodiment two,
The embodiment of the present invention provides relation query method between a kind of table, and described method is described based on correlation inquiry direction by between first table, specifically as shown in Figure 3, comprising:
301, between table, correlation inquiry device obtains inquiry Indication message, and described inquiry Indication message carries the first querying condition, indicates and in N number of table, obtains the first Query Result according to the first querying condition.
Wherein, described first querying condition comprises: the alternative condition in described N number of table in each table, and the incidence relation between the Major key that in described N number of table, M shows and the foreign key value that M+1 shows, 1≤M≤N-1, for integer, described first table is the table sorted from small to large in described N number of table to described N table.
Concrete, in the embodiment of the present invention, between showing during correlation inquiry, between table, first correlation inquiry device can obtain inquiry Indication message, and this inquiry Indication message carries the first querying condition, indicates current needs to carry out correlation inquiry.
Concrete, between table correlation inquiry device obtain the example of inquiry Indication message can description in reference example one in step 101, the embodiment of the present invention does not repeat them here.
It should be noted that, the value of N be more than or equal to 2 integer, namely the value of N can be 2,3,4 ..., and 1≤M≤N-1, then exemplary, if the value of N is 2, then the value of M can be 1, namely there is the first table, the second table 2 table; If the value of N is 3, then 1≤M≤2, the value of M can be 1,2, namely there is the first table, the second table, the 3rd table 3 table.
302, between table, correlation inquiry device, according to the incidence relation between the Major key of M table in N number of table described in the first querying condition and the foreign key value show of M+1, sets up the M corresponding relation that described M shows and described M+1 shows.
Comprise the information of M mark in described M corresponding relation, to identify the information that corresponding M+1 identifies with described M, described M identifies the number of times that corresponding described M+1 identifies, wherein, described M is designated the list item sequence number in described M table, and described M+1 is designated the list item sequence number in described M+1 table.
Concrete, between table, correlation inquiry device is according to the incidence relation between the Major key of M table in N number of table described in the first querying condition and the foreign key value shown of M+1, set up described M show the form of the example of the M corresponding relation shown with described M+1 and described M corresponding relation can the description of step 102 in reference example one, the embodiment of the present invention does not repeat them here.
303, between table, correlation inquiry device, according to the alternative condition in the first table in the first querying condition, is inquired about described first table, and is obtained the first set, wherein, comprises the first mark of the list item meeting querying condition in described first table in described first set.
304, between table, correlation inquiry device is according to the value of M, and circulation performs step S1-S4, until the value of M is all finished:
S1, according to described M corresponding relation and 3M-2 set, determine that 3M-1 gathers, and each M in described 3M-2 set identifies the number of times TM of the M+1 mark in corresponding described 3M-1 set, wherein, comprise the M in gathering with described 3M-2 in described 3M-1 set to identify corresponding M+1 and identify.
S2, according to the alternative condition in the M+1 table in described first querying condition, inquire about M+1 table, and obtain 3M set, wherein, comprise in described 3M set meet described M+1 show in the M+1 mark of list item of alternative condition.
S3, gather according to described 3M-1 set and described 3M, obtains 3M+1 set, wherein, described 3M+1 set comprise satisfied M+1 show in alternative condition and the list item that corresponding M identifies meet described M show in the M+1 of list item of alternative condition identify;
S4, according to described 3M+1 set, upgrade described TM.
305, table between correlation inquiry device gather according to described 3M-2, described 3M+1 gather and described renewal after TM acquisition described first Query Result.
Concrete, described according to the TM after described 3M-2 set, described 3M+1 set and described renewal, obtain described first Query Result and comprise:
If N=2, according to described first set, described 4th set, and the T1 after described renewal, obtain described first Query Result;
If N > 2, according to the value of K, circulation performs step L1, until the value of K is all finished, wherein, 2≤K≤N-1 is integer:
L1, according to K result, T(K-1 after TK after described renewal and described renewal), obtain K+1 result, wherein, second result is initialization value 0, comprises described 3(K-i in described K+1 result) number of times of K+1 mark in-2 set in the corresponding 3K-1 set of each K-i mark, wherein, 1≤i≤K-1 is integer;
According to N result, the T(N-1 after described renewal) and described 3M-2 gathers, described 3M+1 gathers, and obtains described first Query Result.
Below in conjunction with the embodiment shown in Fig. 3, suppose N=2, there are two tables as shown in table a and table b, enumerate the example of correlation inquiry between a table as shown in Figure 4:
401, between table, correlation inquiry device obtains inquiry Indication message, described inquiry Indication message carries the first querying condition, indicate and in table a and table b, obtain the first Query Result according to the first querying condition, wherein, described first querying condition comprises: the alternative condition in table a and table b, and the incidence relation between the foreign key value of the Major key of table a and table b.
It should be noted that, because the first table is the table sorted from small to large in N number of table to N table, therefore in this example, corresponding first table of table a, corresponding second table of table b.
402, between table, correlation inquiry device, according to the incidence relation shown in the first querying condition between the Major key of a and the foreign key value of table b, sets up first corresponding relation of table a and table b.
Concrete, suppose in this example that the first corresponding relation set up is the first corresponding relation as shown in Figure 2.
Certain first corresponding relation also can for shown in such as table three or table four, and the embodiment of the present invention does not do concrete restriction to this.
403, between table, correlation inquiry device is according to the alternative condition shown in the first querying condition in a, and question blank a, and obtain the first set, wherein, comprises the first mark of the list item meeting querying condition in table a in described first set.
Concrete, according to the alternative condition c_name in{ " Xiao Wang " in table a, " Xiao Zhang " }, the first set of the condition that is met can be selected to be (1,2), as shown in Figure 5.
404, between table, correlation inquiry device, according to the first corresponding relation and the first set, determines the second set, and each first in the first set identifies the number of times T1 of the second mark in corresponding second set.
Concrete, the second set and T1 are as shown in Figure 5.
405, between table, correlation inquiry device is according to the alternative condition in the table b in the first querying condition, and question blank b, selects the 3rd set of the condition that is met.
Concrete, according to the alternative condition o_orderdate> " 2012-9-01 " in table b, the 3rd set of the condition that is met can be selected to be (0,5,8,1,2), as shown in Figure 5.
406, between table, correlation inquiry device, according to the second set and the 3rd set, obtains the 4th set.
Concrete, because the second set is for (0,6,8,3,4), 3rd set is for (0,5,8,1,2), and comprise in the 4th set and meet alternative condition in table b, and the list item of corresponding first mark meets the second mark of the list item of alternative condition in table a, therefore the 4th set is the second set and the 3rd intersection of sets collection (0,8).
407, between table, correlation inquiry device, according to the 4th set, upgrades T1.
Concrete, according to the 4th set (0,8), index first corresponding relation, because the first mark indexing (0,8) corresponding is c_oid=1, therefore can obtain T1 as shown in Figure 5.
408, between table, correlation inquiry device, according to the first set, the 4th set and the T1 after upgrading, obtains the first Query Result.
Concrete, as shown in Figure 5, because the number of times that the number of times of corresponding second mark of the first mark c_oid=1 in the first set is corresponding second mark of the 2, first mark c_oid=2 is 0, therefore directly can obtain the first Query Result is c_oid=1, o_oid=0; C_oid=1, o_oid=8.
Easily drawn by above-mentioned example, the embodiment of the present invention is after step 406 obtains the 4th set, the number of times of corresponding second mark directly can be identified according to the 4th set renewal first, and then directly determine according to the number of times of corresponding second mark of the first mark the first mark that in the 4th set, the second mark is corresponding, without the need to operating acquisition first Query Result by join very consuming time after acquisition the 3rd is gathered, therefore the time of correlation inquiry between showing can be reduced, improve inquiry velocity, and then promote query performance.
Optionally, the embodiment of the present invention also provides relation query method between a kind of table, and described method is described based on correlation inquiry direction by between second table, specifically as shown in Figure 6, comprising:
601, between table, correlation inquiry device obtains inquiry Indication message, and described inquiry Indication message carries the first querying condition, indicates and in N number of table, obtains the first Query Result according to the first querying condition.
Wherein, described first querying condition comprises: the alternative condition in described N number of table in each table, and the incidence relation between the Major key that in described N number of table, M shows and the foreign key value that M+1 shows, 1≤M≤N-1, for integer, described first table is the table sorted from small to large in described N number of table to described N table.
Concrete, in the embodiment of the present invention, between showing during correlation inquiry, between table, first correlation inquiry device can obtain inquiry Indication message, and this inquiry Indication message carries the first querying condition, indicates current needs to carry out correlation inquiry.
Concrete, between table correlation inquiry device obtain the example of inquiry Indication message can description in reference example one in step 101, the embodiment of the present invention does not repeat them here.
It should be noted that, the value of N be more than or equal to 2 integer, namely the value of N can be 2,3,4 ..., and 1≤M≤N-1, then exemplary, if the value of N is 2, then the value of M can be 1, namely there is the first table, the second table 2 table; If the value of N is 3, then 1≤M≤2, the value of M can be 1,2, namely there is the first table, the second table, the 3rd table 3 table.
602, between table, correlation inquiry device, according to the incidence relation between the Major key of M table in N number of table described in the first querying condition and the foreign key value show of M+1, sets up the M corresponding relation that described M shows and described M+1 shows.
Comprise the information of M mark in described M corresponding relation, to identify the information that corresponding M+1 identifies with described M, described M identifies the number of times that corresponding described M+1 identifies, wherein, described M is designated the list item sequence number in described M table, and described M+1 is designated the list item sequence number in described M+1 table.
Concrete, between table, correlation inquiry device is according to the incidence relation between the Major key of M table in N number of table described in the first querying condition and the foreign key value shown of M+1, set up described M show the form of the example of the M corresponding relation shown with described M+1 and described M corresponding relation can the description of step 102 in reference example one, the embodiment of the present invention does not repeat them here.
603, between table, correlation inquiry device, according to the alternative condition in the first table in the first querying condition, is inquired about described first table, and is obtained the first set, wherein, comprises the first mark of the list item meeting querying condition in described first table in described first set.
604, between table, correlation inquiry device is according to the value of M, and circulation performs step S1-S3, until the value of M is all finished:
S1, according to described M corresponding relation and 2M-1 set, determine that 2M gathers, and each M in described 2M-1 set identifies the number of times TM of the M+1 mark in corresponding described 2M set, wherein, comprise the M in gathering with described 2M-1 in described 2M set to identify corresponding M+1 and identify.
S2, according in described first querying condition M+1 table in alternative condition, inquire about the list item of the M+1 mark correspondence in M+1 table in 2M set, and obtain 2M+1 set, wherein, comprise in described 2M+1 set and meet the M+1 mark that described M+1 shows the list item of interior alternative condition.
S3, according to described 2M+1 set, upgrade described TM.
605, table between correlation inquiry device gather according to described 2M-1, described 2M+1 set and described renewal after TM, obtain described first Query Result.
Concrete, described according to the TM after described 2M-1 set, described 2M+1 set and described renewal, obtain described first Query Result and comprise:
If N=2, according to described first set, described 3rd set, and the T1 after described renewal, obtain described first Query Result;
If N > 2, according to the value of K, circulation performs step L1, until the value of K is all finished, wherein, and 2≤K≤N-1:
L1, according to K result, T(K-1 after TK after described renewal and described renewal), obtain K+1 result, wherein, second result is initialization value 0, described 2(K-i is comprised in described K+1 result) number of times of K+1 mark in-1 set in the corresponding 2K set of each K-i mark, wherein, 1≤i≤K-1;
According to N result, the T(N-1 after described renewal) and described 2M-1 gathers, described 2M+1 gathers, and obtains described first Query Result.
Below in conjunction with the embodiment shown in Fig. 6, suppose N=2, there are two tables as shown in table a and table b, enumerate the example of correlation inquiry between a table as shown in Figure 7:
701, between table, correlation inquiry device obtains inquiry Indication message, described inquiry Indication message carries the first querying condition, indicate and in table a and table b, obtain the first Query Result according to the first querying condition, wherein, described first querying condition comprises: the alternative condition in table a and table b, and the incidence relation between the foreign key value of the Major key of table a and table b.
It should be noted that, because the first table is the table sorted from small to large in N number of table to N table, therefore in this example, corresponding first table of table a, corresponding second table of table b.
702, between table, correlation inquiry device, according to the incidence relation shown in the first querying condition between the Major key of a and the foreign key value of table b, sets up first corresponding relation of table a and table b.
Concrete, suppose in this example that the first corresponding relation set up is the first corresponding relation as shown in Figure 2.
Certain first corresponding relation also can for shown in such as table three or table four, and the embodiment of the present invention does not do concrete restriction to this.
703, between table, correlation inquiry device is according to the alternative condition shown in the first querying condition in a, and question blank a, and obtain the first set, wherein, comprises the first mark of the list item meeting querying condition in table a in described first set.
Concrete, according to the alternative condition c_name in{ " Xiao Wang " in table a, " Xiao Zhang " }, the first set of the condition that is met can be selected to be (1,2), as shown in Figure 8.
704, between table, correlation inquiry device, according to the first corresponding relation and the first set, determines the second set, and each first in the first set identifies the number of times T1 of the second mark in corresponding second set.
Concrete, the second set and T1 are as shown in Figure 8.
705, between table, correlation inquiry device is according to the alternative condition in the table b in the first querying condition, and the list item that the second mark in question blank b in the second set is corresponding, selects the 3rd set of the condition that is met.
Concrete, according to the alternative condition o_orderdate> " 2012-9-01 " in table b, the 3rd set of the condition that is met can be selected to be (0,8), as shown in Figure 8.
706, between table, correlation inquiry device, according to the 3rd set, upgrades T1.
Concrete, according to the 3rd set (0,8), index first corresponding relation, because the first mark indexing (0,8) corresponding is c_oid=1, therefore can obtain T1 as shown in Figure 8.
707, between table, correlation inquiry device, according to the first set, the 3rd set and the T1 after upgrading, obtains the first Query Result.
Concrete, as shown in Figure 8, because the number of times that the number of times of corresponding second mark of the first mark c_oid=1 in the first set is corresponding second mark of the 2, first mark c_oid=2 is 0, therefore directly can obtain the first Query Result is c_oid=1, o_oid=0; C_oid=1, o_oid=8.
Easily drawn by above-mentioned example, the embodiment of the present invention is after step 705 obtains the 3rd set, the number of times of corresponding second mark directly can be identified according to the 3rd set renewal first, and then directly determine according to the number of times of corresponding second mark of the first mark the first mark that in the 3rd set, the second mark is corresponding, without the need to operating acquisition first Query Result by join consuming time after acquisition the 3rd is gathered, therefore can reduce the time of correlation inquiry between showing, improve inquiry velocity, and then promote query performance.
Further, correlation inquiry example between table when providing a N=3 below, three tables are respectively as shown in table c, table o, table l, wherein, for the purpose of simple, in table c, table o, table l, only list identification item and key assignments item, attribute item is also unlisted, and the embodiment of the present invention does not do concrete restriction to attribute item.
Table c
c_oid c_custkey
0 1
1 2
2 3
3 4
Table o
o_oid o_orderkey o_custkey
0 1 1
1 2 1
2 3 1
3 4 2
4 5 2
5 6 3
6 7 4
7 8 4
Table l
l_oid l_orderkey
0 1
1 1
2 2
3 2
4 2
5 3
6 4
7 4
8 5
9 6
10 6
11 6
12 7
13 8
14 8
This example is described based on correlation inquiry direction by between second table, specifically as shown in Figure 9, comprising:
901, between table, correlation inquiry device obtains inquiry Indication message, and described inquiry Indication message carries the first querying condition, indicates and in table c, table o, table l, obtains the first Query Result according to the first querying condition.
Wherein, described first querying condition comprises: the alternative condition in table c, table o, table l, and the incidence relation between the foreign key value of the Major key of table c and table o, the incidence relation between the Major key showing o and the foreign key value of table l.
It should be noted that, because the first table is the table sorted from small to large in N number of table to N table, therefore in this example, corresponding first table of table c, corresponding second table of table o, corresponding 3rd table of table l.
902, between table, correlation inquiry device, according to the incidence relation shown in the first querying condition between the Major key of c and the foreign key value of table o, sets up first corresponding relation of table c and table o; According to the incidence relation shown in the first querying condition between the Major key of o and the foreign key value of table l, set up second corresponding relation of table o and table l.
Concrete, the first corresponding relation in this example can as shown in Table 5, and the second corresponding relation can as shown in Table 6, and concrete process of establishing can the description of reference example one step 102, repeats no more herein.
Table five
c_oid o_oid Number of times
0 0 3
1 3 2
2 5 1
3 6 2
Table six
o_oid l_oid Number of times
0 0 2
1 2 3
2 5 1
3 6 2
4 8 1
5 9 3
6 12 1
7 13 2
903, between table, correlation inquiry device is according to the alternative condition shown in the first querying condition in c, and question blank c, and obtain the first set, wherein, comprises the first mark of the list item meeting querying condition in table c in described first set.
Concrete, suppose to select through attribute conditions, the first set of the condition that is met can be selected to be (1,3), as shown in Figure 10.
904, between table, correlation inquiry device, according to the first corresponding relation and the first set, determines the second set, and each first in the first set identifies the number of times T1 of the second mark in corresponding second set.
Concrete, the second set and T1 are as shown in Figure 10.
905, between table, correlation inquiry device is according to the alternative condition in the table o in the first querying condition, and the list item that the second mark in question blank o in the second set is corresponding, selects the 3rd set of the condition that is met.
Concrete, suppose to select through attribute conditions, the 3rd set of the condition that is met can be selected to be (3,4,7), as shown in Figure 10.
906, between table, correlation inquiry device, according to the 3rd set, upgrades T1.
Concrete, according to the 3rd set (3,4,7), index first corresponding relation, because index (3,4) correspondence first is designated c_oid=1, first of (7) correspondence is designated c_oid=3, therefore can obtain the T1 after renewal as shown in Figure 10.
907, between table, correlation inquiry device, according to the second corresponding relation and the 3rd set, determines the 4th set, and each second in the 3rd set identifies the number of times T2 of the 3rd mark in corresponding 4th set.
Concrete, the 4th set and T2 are as shown in Figure 10.
908, between table, correlation inquiry device is according to the alternative condition in the table l in the first querying condition, and the list item that the 3rd mark in question blank l in the 4th set is corresponding, selects the 5th set of the condition that is met.
Concrete, suppose to select through attribute conditions, the 5th set of the condition that is met can be selected to be (6,8), as shown in Figure 10.
909, between table, correlation inquiry device, according to the 3rd set, upgrades T2.
Concrete, according to the 5th set (6,8), index second corresponding relation, because index (6) correspondence second is designated o_oid=3, second of (8) correspondence is designated o_oid=4, therefore can obtain T2 as shown in Figure 10.
910, between table, correlation inquiry device, according to the T1 after upgrading and the T2 after upgrading, obtains the 3rd result, wherein comprises the number of times T12 of the 3rd mark in the first set in corresponding 4th set of each first mark in the 3rd result.
Concrete, N=3 in this example, because 2≤K≤N-1, therefore the value of K is only 2, and 1≤i≤K-1, therefore the value of i is only 1, K-i=1.
It should be noted that, obtaining in the process of T12 according to T1 and T2 after renewal, because the number of times that the corresponding o_oid mark of c_oid=1 occurs is 2, namely corresponding o_oid=3 is distinguished, o_oid=4, therefore the number of times that the corresponding l_oid mark of c_oid=1 occurs is that o_oid=3 correspondence l_oid identifies the superposition that the number of times l_oid corresponding to o_oid=4 occurred identifies the number of times occurred, the number of times that in like manner can obtain the appearance of c_oid=3 corresponding l_oid mark is 0.
911, table between correlation inquiry device according to T12, upgrade after T2 and described first set, described 3rd set, described 5th set, obtain described first Query Result.
Concrete, the first Query Result is as shown in Figure 10.
Certainly, if N=4, after acquisition the 3rd result, also need according to the 3rd result, T3 after renewal and the T4 after upgrading, obtain the 4th result, wherein, in the 4th result, comprise the number of times of the 4th mark in the number of times of the 4th mark in the 3rd set in corresponding 6th set of each second mark, the first set in corresponding 6th set of each first mark; If N=5,6,7 ..., then the rest may be inferred, and the embodiment of the present invention will not enumerate at this.
In addition, between the table between first table during the N > 2 of correlation inquiry direction, relation query method can with reference to the example shown in figure 9, and the embodiment of the present invention will not enumerate at this.
The embodiment of the present invention provides relation query method between a kind of table, described method comprises: obtain inquiry Indication message, described inquiry Indication message carries the first querying condition, instruction obtains the first Query Result according to described first querying condition in N number of table, wherein, described first querying condition comprises: the incidence relation between the foreign key value that in the alternative condition in described N number of table in each table and described N number of table, the Major key of M table and M+1 show, 1≤M≤N-1, for integer, described first table is the table sorted from small to large in described N number of table to described N table; According to the incidence relation between the foreign key value that Major key and the M+1 of M table in N number of table described in described first querying condition show, set up the M corresponding relation that described M shows to show with described M+1, comprise the information of M mark in described M corresponding relation, to identify the information that corresponding M+1 identifies with described M, described M identifies the number of times that corresponding described M+1 identifies, wherein, described M is designated the list item sequence number in described M table, and described M+1 is designated the list item sequence number in described M+1 table; According to the alternative condition in each table in N number of table described in described first querying condition, and M described in described M corresponding relation identifies the number of times of corresponding described M+1 mark, obtains described first Query Result.Based on relation query method between the table that the embodiment of the present invention provides, due to after acquisition inquiry Indication message, according to the incidence relation between the foreign key value that Major key and the M+1 of M table in N number of table described in the first querying condition carried in described inquiry Indication message show, establish the M corresponding relation that described M shows to show with described M+1, and comprise the number of times of the corresponding described M+1 mark of M mark in described M corresponding relation, make obtaining in each table after corresponding Query Result according to the alternative condition in each table in N number of table of carrying in inquiry Indication message, the number of times of corresponding described M+1 mark can be identified according to M described in described M corresponding relation, the basis of this Query Result obtains the first Query Result fast, without the need to carrying out join operation, Query Result is traveled through successively, reduce the time of correlation inquiry between table, improve inquiry velocity, and then improve query performance.
Embodiment three,
The embodiment of the present invention provides correlation inquiry device 1100 between a kind of table, and specifically as shown in figure 11, described device 1100 comprises message retrieval unit 1101, relation sets up unit 1102, result acquiring unit 1103.
Described message retrieval unit 1101, for obtaining inquiry Indication message, described inquiry Indication message carries the first querying condition, instruction obtains the first Query Result according to described first querying condition in N number of table, wherein, described first querying condition comprises: the incidence relation between the foreign key value that in the alternative condition in described N number of table in each table and described N number of table, the Major key of M table and M+1 show, 1≤M≤N-1, for integer, described first table is the table sorted from small to large in described N number of table to described N table.
Described relation sets up unit 1102, for the incidence relation between the foreign key value that Major key and the M+1 of M table in N number of table described in the first querying condition of carrying in the inquiry Indication message that obtains according to described message retrieval unit 1101 show, set up the M corresponding relation that described M shows to show with described M+1, the information of M mark is comprised in described M corresponding relation, the information that corresponding M+1 identifies is identified with described M, the number of times of the corresponding described M+1 mark of described M mark, wherein, described M is designated the list item sequence number in described M table, described M+1 is designated the list item sequence number in described M+1 table.
Described result acquiring unit 1103, for the alternative condition in each table in N number of table described in the first querying condition of carrying in the inquiry Indication message that obtains according to described message retrieval unit 1101, and described relation sets up the number of times of the corresponding described M+1 mark of M mark described in described M corresponding relation that unit 1102 sets up, obtains described first Query Result.
In a kind of possible implementation, as shown in figure 12, described result acquiring unit 1103 comprises enquiry module 11031, first execution module 11032, first acquisition module 11033.
Described enquiry module 11031, for the alternative condition in the first table in the first querying condition of carrying in the inquiry Indication message that obtains according to described message retrieval unit 1101, inquire about described first table, and obtain the first set, wherein, the first mark of the list item of the alternative condition met in described first table is comprised in described first set.
Described first execution module 11032, for the value according to M, circulation performs step S1-S3, until the value of M is all finished:
S1, the described M corresponding relation setting up unit 1102 foundation according to described relation and 2M-1 set, determine that 2M gathers, and each M in described 2M-1 set identifies the number of times TM of the M+1 mark in corresponding described 2M set, wherein, comprise the M in gathering with described 2M-1 in described 2M set to identify corresponding M+1 and identify;
S2, according in described first querying condition M+1 table in alternative condition, inquire about the list item of the M+1 mark correspondence in M+1 table in 2M set, and obtain 2M+1 set, wherein, comprise in described 2M+1 set and meet the M+1 mark that described M+1 shows the list item of interior alternative condition;
S3, according to described 2M+1 set, upgrade described TM.
Described first acquisition module 11033, for according to the TM after described 2M-1 set, described 2M+1 set and described renewal, obtains described first Query Result.
Further, described first acquisition module 11033 specifically for:
If N=2, according to described first set, described 3rd set, and the T1 after described renewal, obtain described first Query Result;
If N > 2, according to the value of K, circulation performs step L1, until the value of K is all finished, wherein, 2≤K≤N-1 is integer:
L1, according to K result, T(K-1 after TK after described renewal and described renewal), obtain K+1 result, wherein, second result is initialization value 0, comprises described 2(K-i in described K+1 result) number of times of K+1 mark in-1 set in the corresponding described 2K set of each K-i mark, wherein, 1≤i≤K-1 is integer;
According to N result, the T(N-1 after described renewal) and described 2M-1 gathers, described 2M+1 gathers, and obtains described first Query Result.
In another kind of possible implementation, as shown in figure 13, described result acquiring unit 1103 comprises enquiry module 11031, second execution module 11034, second acquisition module 11035.
Described enquiry module 11031, for the alternative condition in the first table in the first querying condition of carrying in the inquiry Indication message that obtains according to described message retrieval unit 1101, inquire about described first table, and obtain the first set, wherein, the first mark of the list item of the alternative condition met in described first table is comprised in described first set.
Described second execution module 11034, for the value according to M, circulation performs step S1-S4, until the value of M is all finished:
S1, according to described M corresponding relation and 3M-2 set, determine that 3M-1 gathers, and each M in described 3M-2 set identifies the number of times TM of the M+1 mark in corresponding described 3M-1 set, wherein, comprise the M in gathering with described 3M-2 in described 3M-1 set to identify corresponding M+1 and identify;
S2, according to the alternative condition in the M+1 table in described first querying condition, inquire about M+1 table, and obtain 3M set, wherein, comprise in described 3M set meet described M+1 show in the M+1 mark of list item of alternative condition;
S3, to gather according to described 3M-1 set and described 3M, obtain 3M+1 set, wherein, described 3M+1 set comprise meet described M+1 show in alternative condition and the list item that corresponding M identifies meet described M show in the M+1 mark of list item of alternative condition;
S4, according to described 3M+1 set, upgrade described TM.
Described second acquisition module 11035, for according to the TM after described 3M-2 set, described 3M+1 set and described renewal, obtains described first Query Result.
Further, described second acquisition module 11035 specifically for:
If N=2, according to described first set, described 4th set, and the T1 after described renewal, obtain described first Query Result;
If N > 2, according to the value of K, circulation performs step L1, until the value of K is all finished, wherein, 2≤K≤N-1 is integer:
L1, according to K result, T(K-1 after TK after described renewal and described renewal), obtain K+1 result, wherein, second result is initialization value 0, comprises described 3(K-i in described K+1 result) number of times of K+1 mark in-2 set in the corresponding described 3K-1 set of each K-i mark, wherein, 1≤i≤K-1 is integer;
According to N result, the T(N-1 after described renewal) and described 3M-2 gathers, described 3M+1 gathers, and obtains described first Query Result.
Concrete, described M corresponding relation can comprise:
Described M mark identifies the corresponding relation of the number of times that corresponding described M+1 identifies with described M, described M+1 identifies the ltsh chain table identifying corresponding Major key with described M.
Optionally, as shown in figure 14, described device 1100 also comprises determining unit 1104, sequencing unit 1105.
Described determining unit 1104, for the incidence relation between the foreign key value that the Major key and M+1 of setting up M table in N number of table described in the first querying condition of carrying in inquiry Indication message that unit 1102 obtains according to described message retrieval unit 1101 in described relation are shown, before setting up the M corresponding relation that described M shows and described M+1 shows, determine whether the M+1 mark of the list item that in described M+1 table, foreign key value is identical is continuous.
Described sequencing unit 1105, if determine that the M+1 mark of the list item that in described M+1 table, foreign key value is identical is discontinuous for described determining unit 1104, sort to the list item in described M+1 table, the M+1 mark of the list item that in showing to make described M+1, foreign key value is identical continuously.
Described M corresponding relation comprises:
Described M mark identifies the corresponding relation of the number of times that corresponding described M+1 identifies with described M, described M identifies and identifies first corresponding corresponding relation that M+1 identifies with described M.
Concrete, between being shown by correlation inquiry device 1100 between described table, the method for correlation inquiry can the description of reference example one or embodiment two, and the embodiment of the present invention does not repeat them here.
The embodiment of the present invention provides correlation inquiry device between a kind of table, comprise: message retrieval unit, for obtaining inquiry Indication message, described inquiry Indication message carries the first querying condition, instruction obtains the first Query Result according to described first querying condition in N number of table, wherein, described first querying condition comprises: the alternative condition in described N number of table in each table, and the incidence relation between the Major key that in described N number of table, M shows and the foreign key value that M+1 shows, 1≤M≤N-1, for integer, described first table is the table sorted from small to large in described N number of table to described N table, relation sets up unit, for the incidence relation between the foreign key value that Major key and the M+1 of M table in N number of table described in the first querying condition of carrying in the inquiry Indication message that obtains according to described message retrieval unit show, set up the M corresponding relation that described M shows to show with described M+1, the information of M mark is comprised in described M corresponding relation, the information that corresponding M+1 identifies is identified with described M, the number of times of the corresponding described M+1 mark of described M mark, wherein, described M is designated the list item sequence number in described M table, described M+1 is designated the list item sequence number in described M+1 table, result acquiring unit, for the alternative condition in each table in N number of table described in the first querying condition of carrying in the inquiry Indication message that obtains according to described message retrieval unit, and described relation sets up the number of times of the corresponding described M+1 mark of M mark described in described M corresponding relation that unit sets up, obtains described first Query Result.Based on correlation inquiry device between the table that the embodiment of the present invention provides, after obtaining inquiry Indication message at message retrieval unit, relation sets up unit according to the incidence relation between the Major key of M table in N number of table described in the first querying condition carried in described inquiry Indication message and the foreign key value shown of M+1, establish the M corresponding relation that described M shows to show with described M+1, and comprise the number of times of the corresponding described M+1 mark of M mark in described M corresponding relation, make result acquiring unit obtaining in each table after corresponding Query Result according to the alternative condition in each table in N number of table of carrying in inquiry Indication message, the number of times of corresponding described M+1 mark can be identified according to M described in described M corresponding relation, the basis of this Query Result obtains the first Query Result fast, without the need to carrying out join operation, Query Result is traveled through successively, reduce the time of correlation inquiry between table, improve inquiry velocity, and then improve query performance.
Embodiment four,
The embodiment of the present invention provides correlation inquiry device 1500 between a kind of table, described device 1500 can be used in performing the corresponding operating in said method embodiment, specifically as shown in figure 15, described device 1500 comprises processor 1501 and storer 1502, described storer 1502 communicates with described processor 1501, program code stored in described storer 1502, and described processor 1501 is for calling the program code stored in described storer 1502, performs following operation:
Obtain inquiry Indication message, described inquiry Indication message carries the first querying condition, instruction obtains the first Query Result according to described first querying condition in N number of table, wherein, described first querying condition comprises: the incidence relation between the foreign key value that in the alternative condition in described N number of table in each table and described N number of table, the Major key of M table and M+1 show, 1≤M≤N-1 is integer, and described first table is the table sorted from small to large in described N number of table to described N table;
According to the incidence relation between the foreign key value that Major key and the M+1 of M table in N number of table described in described first querying condition show, set up the M corresponding relation that described M shows to show with described M+1, comprise the information of M mark in described M corresponding relation, to identify the information that corresponding M+1 identifies with described M, described M identifies the number of times that corresponding described M+1 identifies, wherein, described M is designated the list item sequence number in described M table, and described M+1 is designated the list item sequence number in described M+1 table;
According to the alternative condition in each table in N number of table described in described first querying condition, and M described in described M corresponding relation identifies the number of times of corresponding described M+1 mark, obtains described first Query Result.
In a kind of possible implementation, described according to the alternative condition in each table in N number of table described in described first querying condition, and M described in described M corresponding relation identifies the number of times of corresponding described M+1 mark, obtaining described first Query Result can comprise:
According to the alternative condition in the first table in described first querying condition, inquire about described first table, and obtain the first set, wherein, in described first set, comprise the first mark of the list item of the alternative condition met in described first table;
According to the value of M, circulation performs step S1-S3, until the value of M is all finished:
S1, according to described M corresponding relation and 2M-1 set, determine that 2M gathers, and each M in described 2M-1 set identifies the number of times TM of the M+1 mark in corresponding described 2M set, wherein, comprise the M in gathering with described 2M-1 in described 2M set to identify corresponding M+1 and identify;
S2, according in described first querying condition M+1 table in alternative condition, inquire about the list item of the M+1 mark correspondence in M+1 table in 2M set, and obtain 2M+1 set, wherein, comprise in described 2M+1 set and meet the M+1 mark that described M+1 shows the list item of interior alternative condition;
S3, according to described 2M+1 set, upgrade described TM;
According to the TM after described 2M-1 set, described 2M+1 set and described renewal, obtain described first Query Result.
Concrete, described according to the TM after described 2M-1 set, described 2M+1 set and described renewal, obtaining described first Query Result can comprise:
If N=2, according to described first set, described 3rd set, and the T1 after described renewal, obtain described first Query Result;
If N > 2, according to the value of K, circulation performs step L1, until the value of K is all finished, wherein, 2≤K≤N-1 is integer:
L1, according to K result, T(K-1 after TK after described renewal and described renewal), obtain K+1 result, wherein, second result is initialization value 0, comprises described 2(K-i in described K+1 result) number of times of K+1 mark in-1 set in the corresponding described 2K set of each K-i mark, wherein, 1≤i≤K-1 is integer;
According to N result, the T(N-1 after described renewal) and described 2M-1 gathers, described 2M+1 gathers, and obtains described first Query Result.
In another kind of possible implementation, described according to the alternative condition in each table in N number of table described in described first querying condition, and M described in described M corresponding relation identifies the number of times of corresponding described M+1 mark, obtaining described first Query Result can comprise:
According to the alternative condition in the first table in described first querying condition, inquire about described first table, and obtain the first set, wherein, in described first set, comprise the first mark of the list item of the alternative condition met in described first table;
According to the value of M, circulation performs step S1-S4, until the value of M is all finished:
S1, according to described M corresponding relation and 3M-2 set, determine that 3M-1 gathers, and each M in described 3M-2 set identifies the number of times TM of the M+1 mark in corresponding described 3M-1 set, wherein, comprise the M in gathering with described 3M-2 in described 3M-1 set to identify corresponding M+1 and identify;
S2, according to the alternative condition in the M+1 table in described first querying condition, inquire about M+1 table, and obtain 3M set, wherein, comprise in described 3M set meet described M+1 show in the M+1 mark of list item of alternative condition;
S3, to gather according to described 3M-1 set and described 3M, obtain 3M+1 set, wherein, described 3M+1 set comprise meet described M+1 show in alternative condition and the list item that corresponding M identifies meet described M show in the M+1 mark of list item of alternative condition;
S4, according to described 3M+1 set, upgrade described TM;
According to the TM after described 3M-2 set, described 3M+1 set and described renewal, obtain described first Query Result.
Concrete, described according to the TM after described 3M-2 set, described 3M+1 set and described renewal, obtain described first Query Result and comprise:
If N=2, according to described first set, described 4th set, and the T1 after described renewal, obtain described first Query Result;
If N > 2, according to the value of K, circulation performs step L1, until the value of K is all finished, wherein, 2≤K≤N-1 is integer:
L1, according to K result, T(K-1 after TK after described renewal and described renewal), obtain K+1 result, wherein, second result is initialization value 0, comprises described 3(K-i in described K+1 result) number of times of K+1 mark in-2 set in the corresponding described 3K-1 set of each K-i mark, wherein, 1≤i≤K-1 is integer;
According to N result, the T(N-1 after described renewal) and described 3M-2 gathers, described 3M+1 gathers, and obtains described first Query Result.
Concrete, described M corresponding relation can comprise:
Described M mark identifies the corresponding relation of the number of times that corresponding described M+1 identifies with described M, described M+1 identifies the ltsh chain table identifying corresponding Major key with described M.
Optionally, the incidence relation between the foreign key value that the described Major key according to M table in N number of table described in described first querying condition and M+1 are shown, before setting up the M corresponding relation that described M shows and described M+1 shows, also comprises:
Determine whether the M+1 mark of the list item that in described M+1 table, foreign key value is identical is continuous;
If the M+1 mark of the list item that foreign key value is identical is discontinuous in described M+1 table, sort to the list item in described M+1 table, the M+1 mark of the list item that in showing to make described M+1, foreign key value is identical continuously;
Described M corresponding relation can comprise:
Described M mark identifies the corresponding relation of the number of times that corresponding described M+1 identifies with described M, described M identifies and identifies first corresponding corresponding relation that M+1 identifies with described M.
Concrete, between being shown by correlation inquiry device 1500 between described table, the method for correlation inquiry can the description of reference example one or embodiment two, and the embodiment of the present invention does not repeat them here.
Based on correlation inquiry device between the table that the embodiment of the present invention provides, because described processor can call and perform the program code stored in described storer, to make between described table correlation inquiry device can after acquisition inquiry Indication message, according to the incidence relation between the foreign key value that Major key and the M+1 of M table in N number of table described in the first querying condition carried in described inquiry Indication message show, set up the M corresponding relation that described M shows to show with described M+1, and comprise the number of times of the corresponding described M+1 mark of M mark in described M corresponding relation, and then between described table correlation inquiry device obtaining in each table after corresponding Query Result according to the alternative condition in each table in N number of table of carrying in inquiry Indication message, the number of times of corresponding described M+1 mark can be identified according to M described in described M corresponding relation, the basis of this Query Result obtains the first Query Result fast, without the need to carrying out join operation, Query Result is traveled through successively, reduce the time of correlation inquiry between table, improve inquiry velocity, and then improve query performance.
Those skilled in the art can be well understood to, for convenience and simplicity of description, the device of foregoing description, only be illustrated with the division of above-mentioned each functional module, in practical application, can distribute as required and by above-mentioned functions and be completed by different functional modules, the inner structure by device is divided into different functional modules, to complete all or part of function described above.The specific works process of the system of foregoing description, device and unit, with reference to the corresponding process in preceding method embodiment, can not repeat them here.
In several embodiments that the application provides, should be understood that, disclosed system, apparatus and method, can realize by another way.Such as, device embodiment described above is only schematic, such as, the division of described module or unit, be only a kind of logic function to divide, actual can have other dividing mode when realizing, such as multiple unit or assembly can in conjunction with or another system can be integrated into, or some features can be ignored, or do not perform.Another point, shown or discussed coupling each other or direct-coupling or communication connection can be by some interfaces, and the indirect coupling of device or unit or communication connection can be electrical, machinery or other form.
The described unit illustrated as separating component or can may not be and physically separates, and the parts as unit display can be or may not be physical location, namely can be positioned at a place, or also can be distributed in multiple network element.Some or all of unit wherein can be selected according to the actual needs 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, also can be that the independent physics of unit exists, also can two or more unit in a unit integrated.Above-mentioned integrated unit both can adopt the form of hardware to realize, and the form of SFU software functional unit also can be adopted to realize.
If described integrated unit using the form of SFU software functional unit realize and as independently production marketing or use time, can be stored in a computer read/write memory medium.Based on such understanding, the part that technical scheme of the present invention contributes to prior art in essence in other words or all or part of of this technical scheme can embody with the form of software product, this computer software product is stored in a storage medium, comprising some instructions in order to make a computer equipment (can be personal computer, server, or the network equipment etc.) or processor (processor) perform 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-OnlyMemory), random access memory (RAM, Random Access Memory), magnetic disc or CD etc. various can be program code stored medium.
The above; be only the specific embodiment of the present invention, but protection scope of the present invention is not limited thereto, is anyly familiar with those skilled in the art in the technical scope that the present invention discloses; change can be expected easily or replace, all should be encompassed within protection scope of the present invention.Therefore, protection scope of the present invention should be as the criterion with the protection domain of described claim.

Claims (15)

1. a relation query method between table, it is characterized in that, described method comprises:
Obtain inquiry Indication message, described inquiry Indication message carries the first querying condition, instruction obtains the first Query Result according to described first querying condition in N number of table, wherein, described first querying condition comprises: the incidence relation between the foreign key value that in the alternative condition in described N number of table in each table and described N number of table, the Major key of M table and M+1 show, 1≤M≤N-1 is integer, and described first table is the table sorted from small to large in described N number of table to described N table;
According to the incidence relation between the foreign key value that Major key and the M+1 of M table in N number of table described in described first querying condition show, set up the M corresponding relation that described M shows to show with described M+1, comprise the information of M mark in described M corresponding relation, to identify the information that corresponding M+1 identifies with described M, described M identifies the number of times that corresponding described M+1 identifies, wherein, described M is designated the list item sequence number in described M table, and described M+1 is designated the list item sequence number in described M+1 table;
According to the alternative condition in each table in N number of table described in described first querying condition, and M described in described M corresponding relation identifies the number of times of corresponding described M+1 mark, obtains described first Query Result.
2. method according to claim 1, it is characterized in that, described according to the alternative condition in each table in N number of table described in described first querying condition, and M described in described M corresponding relation identifies the number of times of corresponding described M+1 mark, obtains described first Query Result and comprises:
According to the alternative condition in the first table in described first querying condition, inquire about described first table, and obtain the first set, wherein, in described first set, comprise the first mark of the list item of the alternative condition met in described first table;
According to the value of M, circulation performs step S1-S3, until the value of M is all finished:
S1, according to described M corresponding relation and 2M-1 set, determine that 2M gathers, and each M in described 2M-1 set identifies the number of times TM of the M+1 mark in corresponding described 2M set, wherein, comprise the M in gathering with described 2M-1 in described 2M set to identify corresponding M+1 and identify;
S2, according in described first querying condition M+1 table in alternative condition, inquire about the list item of the M+1 mark correspondence in M+1 table in 2M set, and obtain 2M+1 set, wherein, comprise in described 2M+1 set and meet the M+1 mark that described M+1 shows the list item of interior alternative condition;
S3, according to described 2M+1 set, upgrade described TM;
According to the TM after described 2M-1 set, described 2M+1 set and described renewal, obtain described first Query Result.
3. method according to claim 2, is characterized in that, described according to the TM after described 2M-1 set, described 2M+1 set and described renewal, obtains described first Query Result and comprises:
If N=2, according to described first set, described 3rd set, and the T1 after described renewal, obtain described first Query Result;
If N > 2, according to the value of K, circulation performs step L1, until the value of K is all finished, wherein, 2≤K≤N-1 is integer:
L1, according to K result, T(K-1 after TK after described renewal and described renewal), obtain K+1 result, wherein, second result is initialization value 0, comprises described 2(K-i in described K+1 result) number of times of K+1 mark in-1 set in the corresponding described 2K set of each K-i mark, wherein, 1≤i≤K-1 is integer;
According to N result, the T(N-1 after described renewal) and described 2M-1 gathers, described 2M+1 gathers, and obtains described first Query Result.
4. method according to claim 1, it is characterized in that, described according to the alternative condition in each table in N number of table described in described first querying condition, and M described in described M corresponding relation identifies the number of times of corresponding described M+1 mark, obtains described first Query Result and comprises:
According to the alternative condition in the first table in described first querying condition, inquire about described first table, and obtain the first set, wherein, in described first set, comprise the first mark of the list item of the alternative condition met in described first table;
According to the value of M, circulation performs step S1-S4, until the value of M is all finished:
S1, according to described M corresponding relation and 3M-2 set, determine that 3M-1 gathers, and each M in described 3M-2 set identifies the number of times TM of the M+1 mark in corresponding described 3M-1 set, wherein, comprise the M in gathering with described 3M-2 in described 3M-1 set to identify corresponding M+1 and identify;
S2, according to the alternative condition in the M+1 table in described first querying condition, inquire about M+1 table, and obtain 3M set, wherein, comprise in described 3M set meet described M+1 show in the M+1 mark of list item of alternative condition;
S3, to gather according to described 3M-1 set and described 3M, obtain 3M+1 set, wherein, described 3M+1 set comprise meet described M+1 show in alternative condition and the list item that corresponding M identifies meet described M show in the M+1 mark of list item of alternative condition;
S4, according to described 3M+1 set, upgrade described TM;
According to the TM after described 3M-2 set, described 3M+1 set and described renewal, obtain described first Query Result.
5. method according to claim 4, is characterized in that, described according to the TM after described 3M-2 set, described 3M+1 set and described renewal, obtains described first Query Result and comprises:
If N=2, according to described first set, described 4th set, and the T1 after described renewal, obtain described first Query Result;
If N > 2, according to the value of K, circulation performs step L1, until the value of K is all finished, wherein, 2≤K≤N-1 is integer:
L1, according to K result, T(K-1 after TK after described renewal and described renewal), obtain K+1 result, wherein, second result is initialization value 0, comprises described 3(K-i in described K+1 result) number of times of K+1 mark in-2 set in the corresponding described 3K-1 set of each K-i mark, wherein, 1≤i≤K-1 is integer;
According to N result, the T(N-1 after described renewal) and described 3M-2 gathers, described 3M+1 gathers, and obtains described first Query Result.
6. the method according to any one of claim 1-5, is characterized in that, described M corresponding relation comprises:
Described M mark identifies the corresponding relation of the number of times that corresponding described M+1 identifies with described M, described M+1 identifies the ltsh chain table identifying corresponding Major key with described M.
7. the method according to any one of claim 1-5, it is characterized in that, incidence relation between the foreign key value that the described Major key according to M table in N number of table described in described first querying condition and M+1 are shown, before setting up the M corresponding relation that described M shows and described M+1 shows, also comprise:
Determine whether the M+1 mark of the list item that in described M+1 table, foreign key value is identical is continuous;
If the M+1 mark of the list item that foreign key value is identical is discontinuous in described M+1 table, sort to the list item in described M+1 table, the M+1 mark of the list item that in showing to make described M+1, foreign key value is identical continuously;
Described M corresponding relation comprises:
Described M mark identifies the corresponding relation of the number of times that corresponding described M+1 identifies with described M, described M identifies and identifies first corresponding corresponding relation that M+1 identifies with described M.
8. a correlation inquiry device between table, is characterized in that, described device comprises message retrieval unit, relation sets up unit, result acquiring unit;
Described message retrieval unit, for obtaining inquiry Indication message, described inquiry Indication message carries the first querying condition, instruction obtains the first Query Result according to described first querying condition in N number of table, wherein, described first querying condition comprises: the incidence relation between the foreign key value that in the alternative condition in described N number of table in each table and described N number of table, the Major key of M table and M+1 show, 1≤M≤N-1, for integer, described first table is the table sorted from small to large in described N number of table to described N table;
Described relation sets up unit, for the incidence relation between the foreign key value that Major key and the M+1 of M table in N number of table described in the first querying condition of carrying in the inquiry Indication message that obtains according to described message retrieval unit show, set up the M corresponding relation that described M shows to show with described M+1, the information of M mark is comprised in described M corresponding relation, the information that corresponding M+1 identifies is identified with described M, the number of times of the corresponding described M+1 mark of described M mark, wherein, described M is designated the list item sequence number in described M table, described M+1 is designated the list item sequence number in described M+1 table,
Described result acquiring unit, for the alternative condition in each table in N number of table described in the first querying condition of carrying in the inquiry Indication message that obtains according to described message retrieval unit, and described relation sets up the number of times of the corresponding described M+1 mark of M mark described in described M corresponding relation that unit sets up, obtains described first Query Result.
9. device according to claim 8, is characterized in that, described result acquiring unit comprises enquiry module, the first execution module, the first acquisition module;
Described enquiry module, for the alternative condition in the first table in the first querying condition of carrying in the inquiry Indication message that obtains according to described message retrieval unit, inquire about described first table, and obtain the first set, wherein, the first mark of the list item of the alternative condition met in described first table is comprised in described first set;
Described first execution module, for the value according to M, circulation performs step S1-S3, until the value of M is all finished:
S1, the described M corresponding relation setting up unit foundation according to described relation and 2M-1 set, determine that 2M gathers, and each M in described 2M-1 set identifies the number of times TM of the M+1 mark in corresponding described 2M set, wherein, comprise the M in gathering with described 2M-1 in described 2M set to identify corresponding M+1 and identify;
S2, according in described first querying condition M+1 table in alternative condition, inquire about the list item of the M+1 mark correspondence in M+1 table in 2M set, and obtain 2M+1 set, wherein, comprise in described 2M+1 set and meet the M+1 mark that described M+1 shows the list item of interior alternative condition;
S3, according to described 2M+1 set, upgrade described TM;
Described first acquisition module, for according to the TM after described 2M-1 set, described 2M+1 set and described renewal, obtains described first Query Result.
10. device according to claim 9, is characterized in that, described first acquisition module specifically for:
If N=2, according to described first set, described 3rd set, and the T1 after described renewal, obtain described first Query Result;
If N > 2, according to the value of K, circulation performs step L1, until the value of K is all finished, wherein, 2≤K≤N-1 is integer:
L1, according to K result, T(K-1 after TK after described renewal and described renewal), obtain K+1 result, wherein, second result is initialization value 0, comprises described 2(K-i in described K+1 result) number of times of K+1 mark in-1 set in the corresponding described 2K set of each K-i mark, wherein, 1≤i≤K-1 is integer;
According to N result, the T(N-1 after described renewal) and described 2M-1 gathers, described 2M+1 gathers, and obtains described first Query Result.
11. devices according to claim 8, is characterized in that, described result acquiring unit comprises enquiry module, the second execution module, the second acquisition module;
Described enquiry module, for the alternative condition in the first table in the first querying condition of carrying in the inquiry Indication message that obtains according to described message retrieval unit, inquire about described first table, and obtain the first set, wherein, the first mark of the list item of the alternative condition met in described first table is comprised in described first set;
Described second execution module, for the value according to M, circulation performs step S1-S4, until the value of M is all finished:
S1, according to described M corresponding relation and 3M-2 set, determine that 3M-1 gathers, and each M in described 3M-2 set identifies the number of times TM of the M+1 mark in corresponding described 3M-1 set, wherein, comprise the M in gathering with described 3M-2 in described 3M-1 set to identify corresponding M+1 and identify;
S2, according to the alternative condition in the M+1 table in described first querying condition, inquire about M+1 table, and obtain 3M set, wherein, comprise in described 3M set meet described M+1 show in the M+1 mark of list item of alternative condition;
S3, to gather according to described 3M-1 set and described 3M, obtain 3M+1 set, wherein, described 3M+1 set comprise meet described M+1 show in alternative condition and the list item that corresponding M identifies meet described M show in the M+1 mark of list item of alternative condition;
S4, according to described 3M+1 set, upgrade described TM;
Described second acquisition module, for according to the TM after described 3M-2 set, described 3M+1 set and described renewal, obtains described first Query Result.
12. devices according to claim 11, is characterized in that, described second acquisition module specifically for:
If N=2, according to described first set, described 4th set, and the T1 after described renewal, obtain described first Query Result;
If N > 2, according to the value of K, circulation performs step L1, until the value of K is all finished, wherein, 2≤K≤N-1 is integer:
L1, according to K result, T(K-1 after TK after described renewal and described renewal), obtain K+1 result, wherein, second result is initialization value 0, comprises described 3(K-i in described K+1 result) number of times of K+1 mark in-2 set in the corresponding described 3K-1 set of each K-i mark, wherein, 1≤i≤K-1 is integer;
According to N result, the T(N-1 after described renewal) and described 3M-2 gathers, described 3M+1 gathers, and obtains described first Query Result.
13. devices according to Claim 8 described in-12 any one, it is characterized in that, described M corresponding relation comprises:
Described M mark identifies the corresponding relation of the number of times that corresponding described M+1 identifies with described M, described M+1 identifies the ltsh chain table identifying corresponding Major key with described M.
14. devices according to Claim 8 described in-12 any one, it is characterized in that, described device also comprises determining unit, sequencing unit;
Described determining unit, for the incidence relation between the foreign key value that the Major key and M+1 of setting up M table in N number of table described in the first querying condition of carrying in inquiry Indication message that unit obtains according to described message retrieval unit in described relation are shown, before setting up the M corresponding relation that described M shows and described M+1 shows, determine whether the M+1 mark of the list item that in described M+1 table, foreign key value is identical is continuous;
Described sequencing unit, if determine that the M+1 mark of the list item that in described M+1 table, foreign key value is identical is discontinuous for described determining unit, sort to the list item in described M+1 table, the M+1 mark of the list item that in showing to make described M+1, foreign key value is identical continuously;
Described M corresponding relation comprises:
Described M mark identifies the corresponding relation of the number of times that corresponding described M+1 identifies with described M, described M identifies and identifies first corresponding corresponding relation that M+1 identifies with described M.
Correlation inquiry device between 15. 1 kinds of tables, it is characterized in that, described device comprises processor and storer, described storer and described processor communication, program code stored in described storer, and described processor is for calling the program code stored in described storer, performs the method as described in any one of claim 1-7.
CN201410026270.XA 2014-01-20 2014-01-20 Relation query method and device between a kind of table Active CN104794130B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201410026270.XA CN104794130B (en) 2014-01-20 2014-01-20 Relation query method and device between a kind of table

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201410026270.XA CN104794130B (en) 2014-01-20 2014-01-20 Relation query method and device between a kind of table

Publications (2)

Publication Number Publication Date
CN104794130A true CN104794130A (en) 2015-07-22
CN104794130B CN104794130B (en) 2018-05-18

Family

ID=53558924

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201410026270.XA Active CN104794130B (en) 2014-01-20 2014-01-20 Relation query method and device between a kind of table

Country Status (1)

Country Link
CN (1) CN104794130B (en)

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105095522A (en) * 2015-09-22 2015-11-25 南开大学 Relation table collection foreign key identification method based on nearest neighbor search
CN109388654A (en) * 2017-08-04 2019-02-26 北京京东尚科信息技术有限公司 A kind of method and apparatus for inquiring tables of data
CN110196889A (en) * 2019-05-30 2019-09-03 北京字节跳动网络技术有限公司 Data processing method, device, electronic equipment and storage medium
CN110609841A (en) * 2019-09-18 2019-12-24 镁佳(北京)科技有限公司 Method, device, readable medium and electronic equipment for asynchronously processing messages
CN110019212B (en) * 2017-11-29 2021-06-18 杭州海康威视数字技术股份有限公司 Data processing method and device and database server
CN117131078A (en) * 2023-10-20 2023-11-28 天津南大通用数据技术股份有限公司 Cross-distribution mode-based associated query optimization method

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5295256A (en) * 1990-12-14 1994-03-15 Racal-Datacom, Inc. Automatic storage of persistent objects in a relational schema
US6662175B1 (en) * 2001-05-08 2003-12-09 Ncr Corporation Semantic query optimization using value correlation
US20050038784A1 (en) * 2001-02-27 2005-02-17 Oracle International Corporation Method and mechanism for database partitioning
CN101164065A (en) * 2005-04-14 2008-04-16 微软公司 Path expression in structured query language
CN102521374A (en) * 2011-12-20 2012-06-27 南京捷梭软件科技有限公司 Intelligent data aggregation method and intelligent data aggregation system based on relational online analytical processing
CN102841892A (en) * 2011-06-21 2012-12-26 中国科学院计算技术研究所 Service encapsulation system and method of relational data

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5295256A (en) * 1990-12-14 1994-03-15 Racal-Datacom, Inc. Automatic storage of persistent objects in a relational schema
US20050038784A1 (en) * 2001-02-27 2005-02-17 Oracle International Corporation Method and mechanism for database partitioning
US6662175B1 (en) * 2001-05-08 2003-12-09 Ncr Corporation Semantic query optimization using value correlation
CN101164065A (en) * 2005-04-14 2008-04-16 微软公司 Path expression in structured query language
CN102841892A (en) * 2011-06-21 2012-12-26 中国科学院计算技术研究所 Service encapsulation system and method of relational data
CN102521374A (en) * 2011-12-20 2012-06-27 南京捷梭软件科技有限公司 Intelligent data aggregation method and intelligent data aggregation system based on relational online analytical processing

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
冯士心 等: ""基于实例化视图的MDX语句执行性能优化"", 《计算机工程》 *

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105095522A (en) * 2015-09-22 2015-11-25 南开大学 Relation table collection foreign key identification method based on nearest neighbor search
CN105095522B (en) * 2015-09-22 2018-09-25 南开大学 Relation table set external key recognition methods based on nearest neighbor search
CN109388654A (en) * 2017-08-04 2019-02-26 北京京东尚科信息技术有限公司 A kind of method and apparatus for inquiring tables of data
CN110019212B (en) * 2017-11-29 2021-06-18 杭州海康威视数字技术股份有限公司 Data processing method and device and database server
CN110196889A (en) * 2019-05-30 2019-09-03 北京字节跳动网络技术有限公司 Data processing method, device, electronic equipment and storage medium
CN110609841A (en) * 2019-09-18 2019-12-24 镁佳(北京)科技有限公司 Method, device, readable medium and electronic equipment for asynchronously processing messages
CN117131078A (en) * 2023-10-20 2023-11-28 天津南大通用数据技术股份有限公司 Cross-distribution mode-based associated query optimization method
CN117131078B (en) * 2023-10-20 2024-02-06 天津南大通用数据技术股份有限公司 Cross-distribution mode-based associated query optimization method

Also Published As

Publication number Publication date
CN104794130B (en) 2018-05-18

Similar Documents

Publication Publication Date Title
CN108733681B (en) Information processing method and device
CN104794130A (en) Inter-table correlation query method and device
CN104769586A (en) Profiling data with location information
CN107016018B (en) Database index creation method and device
CN103703467A (en) Method and apparatus for storing data
CN107016019B (en) Database index creation method and device
CN105550225A (en) Index construction method and query method and apparatus
CN108255838B (en) Method and system for establishing intermediate data warehouse for big data analysis
CN107016501A (en) A kind of efficient industrial big data multidimensional analysis method
CN105517644A (en) Data partition method and device
CN104346458A (en) Data storage method and device
US20070239663A1 (en) Parallel processing of count distinct values
CN104778179A (en) Data migration test method and system
CN105302730A (en) Calculation model detection method, testing server and service platform
WO2017158802A1 (en) Data conversion system and data conversion method
CN104317850A (en) Data processing method and device
CN114781688A (en) Method, device, equipment and storage medium for identifying abnormal data of business expansion project
CN110737779A (en) Knowledge graph construction method and device, storage medium and electronic equipment
CN113918605A (en) Data query method, device, equipment and computer storage medium
CN109739854A (en) A kind of date storage method and device
CN104463627A (en) Data processing method and device
CN106528575B (en) Data interconnection method and device
CN102456073A (en) Partial extremum inquiry method
CN106547843B (en) Multi-stage classification query method and device
CN104408188A (en) Method and device for processing data

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
EXSB Decision made by sipo to initiate substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
TR01 Transfer of patent right

Effective date of registration: 20211222

Address after: 450046 Floor 9, building 1, Zhengshang Boya Plaza, Longzihu wisdom Island, Zhengdong New Area, Zhengzhou City, Henan Province

Patentee after: Super fusion Digital Technology Co.,Ltd.

Address before: 518129 Bantian HUAWEI headquarters office building, Longgang District, Guangdong, Shenzhen

Patentee before: HUAWEI TECHNOLOGIES Co.,Ltd.

TR01 Transfer of patent right