CN104504114B - Optimization method based on the operation relationship table Duoha Xi, apparatus and system - Google Patents

Optimization method based on the operation relationship table Duoha Xi, apparatus and system Download PDF

Info

Publication number
CN104504114B
CN104504114B CN201410844188.8A CN201410844188A CN104504114B CN 104504114 B CN104504114 B CN 104504114B CN 201410844188 A CN201410844188 A CN 201410844188A CN 104504114 B CN104504114 B CN 104504114B
Authority
CN
China
Prior art keywords
table
corresponding
xi
duoha
hash function
Prior art date
Application number
CN201410844188.8A
Other languages
Chinese (zh)
Other versions
CN104504114A (en
Inventor
董亚辉
严龙
黄海燕
Original Assignee
杭州华为数字技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 杭州华为数字技术有限公司 filed Critical 杭州华为数字技术有限公司
Priority to CN201410844188.8A priority Critical patent/CN104504114B/en
Publication of CN104504114A publication Critical patent/CN104504114A/en
Application granted granted Critical
Publication of CN104504114B publication Critical patent/CN104504114B/en

Links

Abstract

本发明实施例提供一种基于多哈希表的关系操作优化方法、装置和系统,该方法包括:接收客户端发送的查询语句,解析查询语句以判断查询语句中是否存在连接条件;若存在,则根据连接条件,在关系表中选择N个表作为构造表,并分别为N个构造表中的每一个构造表选择至少一个哈希函数;对于每个哈希函数,对相应的构造表进行扫描,以获取与哈希表对应的多哈希节点;对于每个哈希函数,根据哈希函数,在与哈希函数对应的多哈希节点中,查询是否存在与探测表匹配的连接条件的记录,若存在,则将记录发送到述客户端。 Embodiment the present invention provides a method of operation based on the relationship between optimization table Duoha Xi, apparatus and system, the method comprising: receiving a query sent by the client, parse the query to determine whether there is a connection condition of the query statement; If present, the connection condition table selection table as the N configuration tables, and each table is configured for each of the N configuration table selecting at least one hash function; for each hash function, the corresponding configuration table is scanned , to acquire the hash table corresponding to the node Duoha Xi; for each hash function, a hash function, the hash function Duoha Xi corresponding to the node, the query whether the recording condition is connected with the probe there are matching table, If present, the client will be sent to said recording. 本发明实施例提供的基于多哈希表的关系操作优化方法、装置和系统提高了查询性能。 Optimization embodiment of the present invention based on an operation table relation Duoha Xi method, apparatus and system for improving the performance provided by the query.

Description

基于多哈希表的关系操作优化方法、装置和系统 Optimization method based on the operation relationship table Duoha Xi, apparatus and system

技术领域 FIELD

[0001] 本发明实施例涉及数据查询技术,尤其涉及一种基于多哈希表的关系操作优化方法、装置和系统。 [0001] Example embodiments of the present invention relates to a data query technology, and particularly to a method of operating the table to optimize the relationship Duoha Xi methods, apparatus, and systems based.

背景技术 Background technique

[0002] 在关系型数据库中,OR与UNION是两个比较重要的关系操作算子,其中,OR常用于在多重条件查询中连接涉及多个关系表时的查询条件,UNION是对涉及多个表的查询结果集进行并集操作。 [0002] In a relational database, OR and UNION are two more important relationship operator operation, wherein, OR used to connect a plurality of query conditions relate to conditions in a multi-table queries, involving a plurality UNION table query result sets and set operations.

[0003] 现有技术中,在多个表进行连接时,如果连接条件之间是OR的关系,通常采用嵌套循环的方式进行连接,或者在包含多个子查询的复合查询中,如果这些子查询涉及的关系表相同,但过滤条件不同时,在对子查询进行OR操作运算时,通常采用将子查询中涉及的关系表进行多次扫描过滤,或者采用对查询语句进行优化及合并的方式进行运算。 [0003] In the prior art, when connecting a plurality of tables, if the connection relationship between the OR condition, usually nested loop mode connection, or a composite comprising a plurality of sub-queries in the query, if the sub- when a query involving the same table, but not the same filter condition, the oR operation performed in operation subquery, usually sub-table query involved multiple scan filter, or by way of the query is optimized and the combined operated. 另外,一个表与其他多个表连接后,如果进行UNION操作,通常对每个连接都采用哈希连接(Hash Join),然后将各结果集进行顺序追加合并,最后进行去重操作来完成。 Further, a plurality of the table and the other tables are connected, if the UNION operation, typically are used for each connection hash join (Hash Join), and then sequentially adding each of the combined result set, and finally to re-operations to complete.

[0004] 然而,在现有技术中,针对OR与UNION算子的相关运算,当对多表进行连接时,需要对涉及的关系表进行多次扫描,以及采用嵌套循环的方式进行连接操作,使得查询性能较差。 [0004] However, in the prior art, for the correlation calculation UNION OR operator, when connecting to multi-table, table according to the need for multiple scans, and the connecting operation using nested loop manner so that the poor query performance.

发明内容 SUMMARY

[0005] 本发明实施例提供一种基于多哈希表的关系操作优化方法、装置和系统,提高了查询性能。 Embodiment [0005] The present invention provides a method of operation based on the relationship between optimization table Duoha Xi, apparatus and system to improve the query performance.

[0006] 第一方面,本发明提供一种基于多哈希表的关系操作优化方法,包括: [0006] In a first aspect, the present invention provides an operating method of optimizing the relationship table based Duoha Xi, comprising:

[0007] 接收客户端发送的查询语句,解析所述查询语句以判断所述查询语句中是否存在连接条件;其中,所述连接条件包括OR或UNION; [0007] sent by a client query, parsing the query statement to determine whether there is a connection condition of the query statement; wherein the connection condition includes the UNION or OR;

[0008] 若存在所述连接条件,则根据所述连接条件,在关系表中选择N个表作为构造表, 并分别为所述N个构造表中的每一个构造表选择至少一个哈希函数;其中,N为整数,且大于〇; [0008] When the connection condition exists, according to the connection condition, select N relationship table as in table configuration table, and each table is configured for each of the N selected configuration of the table at least a hash function ; wherein, N is an integer and greater than a square;

[0009] 对于每个哈希函数,对相应的构造表进行扫描,以获取与所述哈希表对应的多哈希节点; [0009] For each of the hash function, the corresponding configuration table is scanned for the node Duoha Xi corresponding to the hash table;

[0010] 对于每个哈希函数,根据所述哈希函数,在与所述哈希函数对应的所述多哈希节点中,查询是否存在与探测表匹配的连接条件的记录,若存在,则将所述记录发送到所述客户端;其中,所述探测表为除构造表之外的其它关系表。 [0010] For each hash function, based on the hash function, the hash function Duoha Xi node and the corresponding, check whether there is a record in the connection condition table. The probe, if present, the the record is sent to the client; wherein the other table is a table detection in addition to the configuration table.

[0011] 结合第一方面,在第一方面的第一种可能的实现方式中,在所述对于每个哈希函数,对相应的构造表进行扫描,以获取与所述哈希表对应的多哈希节点之后,所述方法还包括: [0011] with the first aspect, the first possible implementation manner of the first aspect, for each hash function, the corresponding structure in the scan table, to acquire the hash table correspond to the after Duoha Xi node, the method further comprising:

[0012] 对所述探测表进行扫描,获得与所述探测表对应的扫描节点; [0012] The scanning of the detection table, obtained with a scanning node table corresponding to the probe;

[0013] 对于每个哈希函数,将所述扫描节点与所述哈希函数对应的多哈希节点进行多哈希连接,生成对应的多哈希连接节点; [0013] For each of the hash function, the hash function scan node and the corresponding node Duoha Xi Duoha Xi connected Duoha Xi generates a corresponding connection node;

[0014] 对于每个哈希函数,判断所述哈希函数对应的多哈希连接节点对应的执行路径是否满足查询条件; [0014] satisfies a query condition for each hash function, the hash function determines the execution path corresponding Duoha Xi corresponding to the connection node;

[0015] 则所述根据所述哈希函数,在与所述哈希函数对应的所述多哈希节点中,查询是否存在与探测表匹配的连接条件的记录,具体包括: [0015] is the basis of the hash function, the hash function Duoha Xi node and the corresponding query whether there is a connection condition detection record matching table comprises:

[0016] 若判断所述哈希函数对应的多哈希连接节点对应的执行路径满足所述查询条件, 则根据所述哈希函数,在与所述哈希函数对应的所述多哈希节点中,查询是否存在与探测表匹配的连接条件的记录。 [0016] When the connection determination execution path Duoha Xi corresponding to the node corresponding to the hash function satisfies the query condition, according to the hash function, the hash function Duoha Xi node and the corresponding, Search record whether there is a connection with the condition of the probe table match.

[0017] 结合第一方面的第一种可能的实现方式,在第一方面的第二种可能的实现方式中,所述对于每个哈希函数,判断所述哈希函数对应的多哈希连接节点对应的执行路径是否满足查询条件,具体包括: [0017] The first possible implementation of the first aspect, a second possible implementation manner of the first aspect, for each of the hash function, the hash function is determined corresponding connection Duoha Xi whether the node corresponding execution paths that satisfy the query comprises:

[0018] 对于每个哈希函数,确定所述哈希函数对应的多哈希连接节点对应的执行路径; [0018] For each of the hash function, the hash function is determined execution path corresponding Duoha Xi corresponding to the connection node;

[0019] 获取所述执行路径上的各多哈希连接节点的权值,并将各所述权值相加,获得所述执行路径的执行代价;其中,所述权值用于表示对应的多哈希连接节点与其相邻的多哈希连接节点之间的执行代价; [0019] Gets Duoha Xi weight of each node on the path connected to the execution, and each of said weight values ​​are added to obtain the execution cost of the execution path; wherein the weight value representing a correspondence Doha execution cost between nodes Duoha Xi Xi adjacent thereto is connected to the connection node;

[0020] 判断所述哈希函数对应的执行路径的所述执行代价,是否为所有的执行路径的执行代价中的最小值;若是,则所述哈希函数对应的多哈希连接节点对应的执行路径满足查询条件。 The execution path of the execution cost [0020] Analyzing the corresponding hash function, the execution cost is the minimum value of all of the execution paths; if yes, a hash function corresponding to the connection node of the corresponding execution Duo Haxi path satisfy the query.

[0021] 第二方面,本发明提供一种基于多哈希表的关系操作优化装置,包括: [0021] In a second aspect, the present invention provides a method of operating Duoha Xi optimized relationship table based apparatus, comprising:

[0022] 收发模块,用于接收客户端发送的查询语句; [0022] The transceiver module for receiving a query sent by a client;

[0023] 判断模块,用于解析所述查询语句以判断所述查询语句中是否存在连接条件;其中,所述连接条件包括OR或UNION; [0023] The judging module, configured to parse the query to determine whether there is a connection condition of the query statement; wherein the connection condition includes the UNION or OR;

[0024] 处理模块,用于在所述判断模块判断出存在所述连接条件时,根据所述连接条件, 在关系表中选择N个表作为构造表,并分别为所述N个构造表中的每一个构造表选择至少一个哈希函数;其中,N为整数,且大于0; [0024] The processing module, the judging module determines that the connection condition exists, according to the connection condition, select N tables in relational tables as the table structure, and each of the N configuration table each configuration table selecting at least one hash function; wherein, N is an integer and is greater than 0;

[0025] 扫描模块,用于对于每个哈希函数,对相应的构造表进行扫描,以获取与所述哈希表对应的多哈希节点; [0025] The scanning module for, for each hash function, the corresponding configuration table is scanned for the node Duoha Xi corresponding to the hash table;

[0026] 所述判断模块还用于对于每个哈希函数,根据所述哈希函数,在与所述哈希函数对应的所述多哈希节点中,查询是否存在与探测表匹配的连接条件的记录;所述收发模块还用于在所述判断模块判断出存在与探测表匹配的连接条件的记录时,将所述记录发送到所述客户端;其中,所述探测表为除构造表之外的其它关系表。 [0026] The determining module is further configured to, for each hash function, based on the hash function, the hash function Duoha Xi node and the corresponding query whether there is a connection condition table matches with the probe recording; the transceiver module is further configured when the determining module determines that the recording condition is connected with the presence of matched probe table, the record is sent to the client; wherein, in addition to the probe configuration table is a table other relational tables outside.

[0027] 结合第二方面,在第二方面的第一种可能的实现方式中,所述扫描模块,还用于对所述探测表进行扫描,获得与所述探测表对应的扫描节点; [0027] combination with the second aspect, the first possible implementation of the second aspect of the scanning module is further configured to detect the scanning table to obtain the node table corresponding to the scanning probe;

[0028] 所述处理模块还用于对于每个哈希函数,将所述扫描节点与所述哈希函数对应的多哈希节点进行多哈希连接,生成对应的多哈希连接节点; [0028] The processing module is further configured for each hash function, the hash function scan node and the corresponding node Duoha Xi Duoha Xi connected Duoha Xi generates a corresponding connection node;

[0029] 所述判断模块还用于对于每个哈希函数,判断所述哈希函数对应的多哈希连接节点对应的执行路径是否满足查询条件; [0029] The determining module is further configured for each hash function, the hash function is determined corresponding to the connection node Duoha Xi corresponding execution path satisfies the query condition;

[0030] 则所述判断模块具体用于若所述哈希函数对应的多哈希连接节点对应的执行路径满足所述查询条件,则根据所述哈希函数,在与所述哈希函数对应的所述多哈希节点中, 查询是否存在与探测表匹配的连接条件的记录。 [0030] The determining module is for performing a route if the corresponding hash function corresponding to the connection node Duoha Xi satisfies the query condition, according to the hash function, the hash function corresponding to the the Duoha Xi node, check whether there is a record in the connection condition table matched probe.

[0031] 结合第二方面的第一种可能的实现方式,在第二方面的第二种可能的实现方式中,所述判断模块还包括:确定单元、获取单元和判断单元; [0031] The first possible implementation of the second aspect, the second aspect of the second possible implementation manner, the determining module further comprises: a determination unit, the acquisition unit and judging means;

[0032] 其中,所述确定单元用于对于每个哈希函数,确定所述哈希函数对应的多哈希连接节点对应的执行路径; [0032] wherein said means for determining, for each hash function, the hash function is determined execution path corresponding Duoha Xi corresponding to the connection node;

[0033] 所述获取单元,用于获取所述执行路径上的各多哈希连接节点的权值,并将各所述权值相加,获得所述执行路径的执行代价;其中,所述权值用于表示对应的多哈希连接节点与其相邻的多哈希连接节点之间的执行代价; [0033] The obtaining unit configured to obtain weight of each Duoha Xi connection nodes on the path of the execution, and each of said weight values ​​are added to obtain the execution cost of the execution path; wherein the weight value is used to represent the corresponding execution cost between a connection node adjacent Duoha Xi Duoha Xi connection node;

[0034] 所述判断单元,用于判断所述哈希函数对应的执行路径的所述执行代价,是否为所有的执行路径的执行代价中的最小值;若是,则所述哈希函数对应的多哈希连接节点对应的执行路径满足查询条件。 [0034] The determination unit configured to determine a hash function corresponding to the execution path of the execution cost is the minimum value of all the execution cost of the execution paths; if yes, a hash function corresponding to the Duoha Xi execution path connecting nodes corresponding to satisfy the query.

[0035] 第三方面,本发明提供一种基于多哈希表的关系操作优化系统,包括:客户端和第二方面、第二方面的第一种至第二方面的第二种任一种基于多哈希表的关系操作优化装置。 [0035] In a third aspect, the present invention provides an optimized system relations Duoha Xi operating table, including those based on: the client and the second aspect, any of the first to the second aspect of the second aspect based on the second relationship between the operation table Duoha Xi optimization device.

[0036] 本发明实施例提供的基于多哈希表的关系操作优化方法、装置和系统,通过接收客户端发送的查询语句,解析查询语句以判断该查询语句中是否存在连接条件;其中,连接条件包括OR或UNION;若存在连接条件,则根据连接条件,在关系表中选择N个表作为构造表,并分别为N个构造表中的每一个构造表选择至少一个哈希函数,对于每个哈希函数,对相应的构造表进行扫描,以获取与哈希表对应的多哈希节点;对于每个哈希函数,根据哈希函数,在与哈希函数对应的多哈希节点中,查询是否存在与探测表匹配的连接条件的记录, 若存在,则将记录发送到客户端;其中,探测表为除构造表之外的其它关系表。 Wherein the connection condition; Embodiment [0036] The present invention provides a method based on the relationship between the operation optimization table Duoha Xi, apparatus and system, the query transmitted by the receiving client, parse the query to determine whether there is a connection condition of the query statement comprising the UNION or oR; If the connection condition exists, according to the connection condition table selected in the table as the N configuration table, and each table is configured for each of the N configuration table selecting at least one hash function for each hash function, the corresponding configuration table is scanned to acquire the hash table corresponding to the node Duoha Xi; for each hash function, a hash function, the hash function Duoha Xi corresponding to the node, the query whether the connector conditions and detecting the presence of matching table, if present, will be sent to the client record; wherein the probe table to another table in addition to the configuration table. 由于在OR或UNION的连接条件中,根据连接条件对构造表选择至少一个哈希函数,以生成与哈希函数对应的多哈希节点,并根据哈希函数,在与哈希函数对应的多哈希节点中,查询是否存在与探测表匹配的连接条件的记录,避免了现有技术中对涉及的关系表进行多次扫描,以及采用嵌套循环的方式进行连接操作的方式,提高了查询的性能。 Since the join condition or OR UNION, the connection conditions are selected according to a hash function for at least the construction table, a hash function to generate a corresponding Duoha Xi node, and hash function, the hash function corresponding to the Duo Haxi node, check whether there is a record with the connection table matching condition detection, avoiding the prior art embodiment of the table according to multiple scans, and by way of nested loops connecting operation, improves the performance of the query .

附图说明 BRIEF DESCRIPTION

[0037] 为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作一简单地介绍,显而易见地,下面描述中的附图是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。 [0037] In order to more clearly illustrate the technical solutions in the embodiments or the prior art embodiment of the present invention, the accompanying drawings for illustrating the prior art described or needed to be used in an embodiment will be briefly introduced hereinafter, the description below the figures show some embodiments of the present invention, those of ordinary skill in the art is concerned, without any creative effort, and can obtain other drawings based on these drawings.

[0038] 图1为本发明基于多哈希表的关系操作优化方法实施例一的流程示意图; [0038] FIG. 1 is a schematic view of an operation flow of embodiment relationship optimization method based on the present disclosure Duoha Xi table;

[0039] 图2为本发明基于多哈希表的关系操作优化方法实施例二的流程示意图; [0039] FIG. 2 is a schematic flow diagram according to a second embodiment of operation method of optimizing the relationship table based on the present disclosure Duoha Xi;

[0040] 图3为本发明基于多哈希表的关系操作优化装置实施例一的结构示意图; [0040] FIG. 3 is a schematic structural diagram of a relationship between the operation of the embodiment of the device based on table optimization Duoha Xi invention;

[0041] 图4为本发明基于多哈希表的关系操作优化装置实施例二的结构示意图; [0041] FIG. 4 is a schematic structural diagram according to a second embodiment of the relationship between the operation based on the optimization Duoha Xi table apparatus of the present invention;

[0042] 图5为本发明提供的服务器实施例一的结构示意图。 Schematic diagram of a structure of [0042] FIG. 5 of the present invention provides a server implementation.

具体实施方式 Detailed ways

[0043] 为使本发明实施例的目的、技术方案和优点更加清楚,下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本发明一部分实施例,而不是全部的实施例。 [0043] In order that the invention object, technical solutions, and advantages of the embodiments more clearly, the following the present invention in the accompanying drawings, technical solutions of embodiments of the present invention are clearly and completely described, obviously, the described the embodiment is an embodiment of the present invention is a part, but not all embodiments. 基于本发明中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。 Based on the embodiments of the present invention, those of ordinary skill in the art to make all other embodiments without creative work obtained by, it falls within the scope of the present invention.

[0044] 图1为本发明基于多哈希表的关系操作优化方法实施例一的流程示意图。 [0044] FIG. 1 is a schematic flowchart of a embodiment of the operation optimization Duoha Xi relationship table based on the present disclosure. 本发明实施例提供了一种基于多哈希表的关系操作优化方法,该方法可以由任意执行基于多哈希表的关系操作优化方法的装置来执行,该装置可以通过软件和/或硬件实现。 Example provided an operation method based on the relationship between optimization of the present invention Duoha Xi table, the method may be performed by any method of operation of the device in relation Duoha Xi optimization is performed based on a table, the apparatus can be implemented by software and / or hardware. 本实施例中, 该装置可以集成在数据库服务器中。 In this embodiment, the apparatus may be integrated in a database server. 如图1所示,本实施例的方法可以包括: As shown in FIG 1, the method according to the present embodiment may include:

[0045] 步骤101、接收客户端发送的查询语句,解析查询语句以判断查询语句中是否存在连接条件;其中,连接条件包括OR或UNION。 [0045] Step 101, the client receives the transmitted query, parse the query to determine whether there is a connection condition of the query statement; wherein the connection condition includes an OR or UNION.

[0046] 在本实施例中,用户可以通过客户端向数据库服务器发送查询语句,以请求对数据库进行相应的查询操作。 [0046] In the present embodiment, the user may send a query to the database server through the client, to request a corresponding database query. 可选地,当数据库服务器接收到客户端发送的查询语句后,首先检查查询语句的语法是否正确,若语法正确,再对该查询语句进行解析,根据解析结果判断查询语句中是否包含有OR或UNION算子,若查询语句语法不正确,则进行语法错误的提示。 Alternatively, when the server receives the database query sent by the client, the query is first checked for correct syntax, if the syntax is correct, then parse the query, determines whether or OR with the analysis result of the query statement or UNION operator, if the query syntax is incorrect syntax error tips is performed. 当然,也可以默认查询语句的语法正确而不进行语法检查。 Of course, you can also correct the default query syntax without syntax checking.

[0047] 步骤102、若存在连接条件,则根据连接条件,在关系表中选择N个表作为构造表, 并分别为N个构造表中的每一个构造表选择至少一个哈希函数;其中,N为整数,且大于0。 [0047] Step 102, if the connection condition exists, according to the connection condition table selected in the table as the N configuration table, and each table is configured for each of the N configuration table selecting at least one hash function; wherein, N is an integer and is greater than 0.

[0048] 在本实施例中,若查询语句中包含有连接条件,数据库服务器会根据连接条件的不同,在连接条件中涉及到的关系表中选择至少一个表作为构造表。 [0048] In the present embodiment, if the query contains the join condition, the database server, the relationship between the tables involved in the connection condition table selecting at least one table is configured as depending on the connection conditions. 在具体的实现过程中, 由于将构造表进行扫描,生成对应的哈希表后,是将哈希表存储在内存中,因此,为了节省内存空间,一般选择关系表中的较小表作为构造表。 In a specific implementation, since the configuration of the scan table, corresponding to the generated hash table is in memory, and therefore, in order to save memory space, typically for selecting a hash table stored in a relational table constructed as a small table table. 另外,数据库服务器分别为这些构造表中的每一个构造表选择至少一个哈希函数,以对构造表进行扫描。 Further, each database server selecting at least one hash function for each configuration of these configuration tables table, configured to scan the table. 例如:当查询条件为: tl. cl = t2. clor tl. c2 = t2. c2,即查询表tl的第一行cl与表t2的第一行cl相等或表tl的第二行c2与表t2的第二行c2相等的数据项时,假设表t2中的数据项较小,也就是说,表t2为较小表,则将表t2作为构造表,并为表t2选择两个哈希函数,以对表t2进行扫描。 For example: when a query condition is:.... Tl cl = t2 clor tl c2 = t2 c2, i.e. the first row of the query table tl cl cl and the first row of table t2 c2 is equal to the second row or table of table tl c2 t2 of the second row is equal to the data item is assumed that the data item table t2 is small, that is, smaller table t2 table, the table configured as a table t2, and t2 to select two hash tables function to scan the table t2.

[0049] 步骤103、对于每个哈希函数,对相应的构造表进行扫描,以获取与哈希表对应的多哈希节点。 [0049] Step 103, for each hash function, the corresponding configuration table are scanned to obtain a corresponding node and the hash table Duoha Xi.

[0050] 在本实施例中,利用关系表之间做连接的列上的哈希函数,生成多哈希节点。 [0050] In the present embodiment, the connection made between the use of a hash function in the relationship table column generates Duoha Xi node. 具体地,根据连接条件的不同,对于每一个构造表,有可能只有一个哈希函数,也有可能有多个哈希函数,针对每个哈希函数来说,均根据哈希函数对响应的构造表进行扫描,从而获得对应的多哈希节点。 Specifically, depending on the connection conditions, for each configuration table, there may be a hash function, there may be multiple hash function for each hash function, the hash function are configured to respond scan the table to obtain the corresponding node Duoha Xi. 例如:为表t2选择两个哈希函数之后,对于每一个哈希函数,均对表t2进行扫描,以获取与哈希表对应的多哈希节点,因此,对表t2进行扫描之后,会获得两个不同的哈希表,以及两个不同的哈希表对应的多个多哈希节点。 For example: After selecting two t2 table as a hash function for each hash function, each table t2 scanned to acquire the hash table corresponding to the node Duoha Xi, therefore, after the scan table t2, get two different hash tables, and a plurality of nodes Duoha Xi two hash tables corresponding to different.

[0051] 步骤104、对于每个哈希函数,根据哈希函数,在与哈希函数对应的多哈希节点中, 查询是否存在与探测表匹配的连接条件的记录,若存在,则将记录发送到客户端;其中,探测表为除构造表之外的其它关系表。 [0051] Step 104, for each hash function, a hash function, the hash Duoha Xi node corresponding to the function, check whether there is a record with the connection table matching condition detection, if present, will be transmitted records to the client; wherein the probe table to another table in addition to the configuration table.

[0052] 在本实施例中,根据哈希函数对相应的构造表进行扫描,生成哈希表对应的多哈希节点之后,数据库服务器开始读取探测表,针对探测表中每一条数据,都在做连接的列上使用哈希函数,以定位对应的哈希节点,找到相应的哈希节点之后,便进行查询是否存在与探测表匹配的连接条件的记录。 After [0052] In the present embodiment, a hash function Duoha Xi node scan, generating a hash table corresponding to the respective configuration table, a database server table starts reading probe for detecting each of the data table, in after done using a hash function on a column connected to node location corresponding to the hash, the hash find the corresponding node, it is connected to the recording conditions and detecting whether the query has a matching table. 若查询到符合连接条件的相关记录,则将该记录发送到客户端,以供用户进行查看。 If the query to the relevant records that meet the join condition, the record is sent to the client for the user to view.

[0053] 举例来说,当连接条件包含有OR算子时的查询语句为: [0053] For example, when a query is connected with OR condition of neutrons counted:

[0054] “select*from tl,t2where tl · cl = t2 · clor tl · c2 = t2 · c2” [0054] "select * from tl, t2where tl · cl = t2 · clor tl · c2 = t2 · c2"

[0055] 具体的,在现有技术中,对该查询语句通常采用嵌套查询连接的方式进行的一种具体实现方式为: [0055] Specifically, in the prior art, the query statement is usually connected nested queries performed by a specific implementation is:

Figure CN104504114BD00081

[0057] 由此可见,在现有技术中,需要对表tl和表t2进行多次扫描,使得查询性能较低。 [0057] Thus, in the prior art, it is necessary for the table and table t2 tl multiple scans, such that the lower the query performance. 而在本实施例中,将表作为构造表,根据连接条件tl.cl = t2.cl or tl.c2 = t2.c2,为构造表t2选择两个哈希函数,以生成对应的两个哈希表,并将表tl作为探测表,根据哈希函数,将探测表tl在生成的两个哈希表中进行数据的匹配,其中,对该查询语句的一种执行计划的具体实现方式为: In the present embodiment, the table configured as a table, tl.cl = t2.cl or tl.c2 = t2.c2, configured to select two table t2 hash function according to the connection conditions to generate the corresponding two ha Xi table and table probe as tl table, a hash function, the probe table tl two matching data generated in the hash table, wherein the specific implementation of the query execution plan is a :

[0058] [0058]

Figure CN104504114BD00082

[0059] 由此可见,本实施例中不需要对表tl和表t2进行多次扫描,只需要对表t2顺序扫描一次,并为表t2生成多哈希节点,再对表tl顺序扫描一次,生成扫描节点之后,对多哈希节点和扫描节点做多哈希连接即可,可以极大地提高查询性能。 [0059] Thus, the present embodiment does not require table table t2 and tl multiple scans, only sequential scan of table t2, and generates Duoha Xi node table t2, then a sequential scan of table tl, after generating the scan nodes, the nodes to Duoha Xi and scanning nodes connected to do Duoha Xi can greatly improve query performance.

[0060] 当连接条件包含有UNION算子时的查询语句为: [0060] When the connection condition includes a query count neutrons as UNION:

[0061] “select氺from a join b on a. cl =b. cl union select氺from a join c on B. c2 — c. c2 [0061] "select Shui from a join b on a cl = b cl union select Shui from a join c on B. c2 -... C c2

[0062] 具体的,在现有技术中,通常需要对表a做两次扫描,在完成哈希连接后,还需要将各结果集进行顺序追加合并,最后进行去重操作,其中,对该查询语句的一种执行计划的具体实现方式为: [0062] Specifically, in the prior art, generally need to do a table scans, after completion of the hash join, but also the result of each set are appended sequentially, and finally to re-operation, wherein the a method of performing a query plan specific implementation of the statement is:

Figure CN104504114BD00083

Figure CN104504114BD00091

[0065] 由此可见,在现有技术中,针对包含有UNION算子的连接条件的运算较为复杂,使得查询性能较低。 [0065] Thus, in the prior art, the conditions for operation connected with UNION operator complicated, so that lower query performance. 而在本实施例中,只需要对表a进行一次扫描,并执行多哈希连接即可,其中,对该查询语句的一种执行计划的具体实现方式为: In the present embodiment, only a single scan table, and performs the connection to Duoha Xi, wherein the specific implementation plan for executing the query statement is:

[0066] [0066]

Figure CN104504114BD00092

[0067] 由此可见,本实施例中通过顺序扫描表b和表c,并根据哈希函数对表b和表c生成对应的哈希表,通过对表a进行顺序扫描,并进行多哈希连接,由此可以大大提高查询性能。 [0067] Thus, by scanning the table sequentially embodiment b and c tables, and generates a hash function table b and c corresponding table hash table, a sequential scan of the table by a, and the present embodiment Duo Haxi connection, which can greatly improve query performance.

[0068] 本发明实施例提供的基于多哈希表的关系操作优化方法,通过接收客户端发送的查询语句,解析查询语句以判断该查询语句中是否存在连接条件;其中,连接条件包括OR或UNION;若存在连接条件,则根据连接条件,在关系表中选择N个表作为构造表,并分别为N个构造表中的每一个构造表选择至少一个哈希函数,对于每个哈希函数,对相应的构造表进行扫描,以获取与哈希表对应的多哈希节点;对于每个哈希函数,根据哈希函数,在与哈希函数对应的多哈希节点中,查询是否存在与探测表匹配的连接条件的记录,若存在,则将记录发送到客户端;其中,探测表为除构造表之外的其它关系表。 [0068] The embodiment of the present invention is to optimize the operating method Duoha Xi relationship table based on the query transmitted by the receiving client, provided resolve the query statement to determine whether there is a connection condition of the query statement; wherein the connection condition includes an OR or UNION ; If the connection condition exists, according to the connection condition table selected in the table as the N configuration table, and each table is configured for each of the N configuration table selecting at least one hash function for each hash function, the corresponding configuration table is scanned to acquire the hash table corresponding to the node Duoha Xi; for each hash function, a hash function, the hash Duoha Xi node corresponding to the function, and the probe table queries whether there connector matching condition, if present, will be sent to the client record; wherein the probe table to another table in addition to the configuration table. 由于在OR或UNION的连接条件中,根据连接条件对构造表选择至少一个哈希函数,以生成与哈希函数对应的多哈希节点,并根据哈希函数,在与哈希函数对应的多哈希节点中,查询是否存在与探测表匹配的连接条件的记录,避免了现有技术中对涉及的关系表进行多次扫描,以及采用嵌套循环的方式进行连接操作的方式,提高了查询的性能。 Since the join condition or OR UNION, the connection conditions are selected according to a hash function for at least the construction table, a hash function to generate a corresponding Duoha Xi node, and hash function, the hash function corresponding to the Duo Haxi node, check whether there is a record with the connection table matching condition detection, avoiding the prior art embodiment of the table according to multiple scans, and by way of nested loops connecting operation, improves the performance of the query .

[0069] 图2为本发明基于多哈希表的关系操作优化方法实施例二的流程示意图,本实施例在基于多哈希表的关系操作优化方法实施例一的基础上,对选取最优路径的实施例,做详细说明。 [0069] FIG. 2 is a schematic diagram of the process according to the second embodiment of the operation optimization method Duoha Xi relationship table based on the invention, embodiments of the present embodiment based on operation optimization method Duoha Xi relationship table based on one of the optimal path selection Example embodiments, detailed description. 如图2所示,本实施例的方法可以包括: The method of the present embodiment shown in Figure 2 may include:

[0070] 步骤201、对探测表进行扫描,获得与探测表对应的扫描节点。 [0070] Step 201, the detection table scans, obtained with a scanning probe table corresponding to the node.

[0071] 在本实施例中,根据哈希函数对构造表进行扫描,获得与哈希函数对应的多哈希节点之后,数据库服务器对探测表也要进行扫描,以获得扫描节点。 After [0071] In the present embodiment, the hash function is configured to scan the table, the hash function is obtained Duoha Xi corresponding to the node, a database server table probe must also be scanned to obtain scanned node.

[0072] 步骤202、对于每个哈希函数,将扫描节点与哈希函数对应的多哈希节点进行多哈希连接,生成对应的多哈希连接节点。 [0072] Step 202, for each hash function, the hash function and a scanning node Duoha Xi corresponding connection node Duoha Xi, Duoha Xi generates a corresponding connection node.

[0073] 在本实施例中,由于数据库服务器为N个构造表中的每一个构造表选择至少一个哈希函数,因此,对于每一个哈希函数来说,数据库服务器根据该哈希函数对探测表进行扫描,获得与探测表对应的扫描节点之后,将扫描节点与该哈希函数对应的多哈希节点进行多哈希连接,以生成对应的多哈希连接节点。 [0073] In the present embodiment, since the configuration of each of the N table configuration table selecting at least one database server hash function, therefore, for each hash function, the hash function based on the database server sounding after the scan table, obtained with a scanning probe node table corresponding to the scan Duoha Xi nodes connected to the node hash function Duoha Xi corresponding to generate a corresponding connection node Duoha Xi.

[0074] 步骤203、对于每个哈希函数,判断哈希函数对应的多哈希连接节点对应的执行路径是否满足查询条件。 [0074] Step 203, for each hash function, determines Duoha Xi hash function corresponding to the connection node corresponding execution path satisfies the query condition. 若满足,则执行步骤204,否则,执行步骤205。 If satisfied, step 204 is performed, otherwise, step 205.

[0075] 在本实施例中,由于执行路径有多条,例如:循环嵌套路径、多哈希路径等,其中, 由于哈希函数的构造方式有多种,因此,多哈希路径也可以有多条。 [0075] In the present embodiment, since a plurality of execution paths, for example: nested loop path, path, etc. Duoha Xi, wherein due to the configuration of the embodiment has a variety of hash functions, therefore, may be multiple paths Duo Haxi article. 在具体的实现过程中, 可以通过判断所有路径的执行代价,通过比较获得执行代价最小的一条路径作为最优路径。 In a specific implementation process, the cost can be performed by determining all the paths, performed by comparing the obtained minimum cost path as the best path. 具体地,可以通过确定哈希函数对应的多哈希连接节点对应的执行路径,通过获取执行路径上的各多哈希连接节点的权值,并将各权值相加,以获得执行路径的执行代价,其中, 该权值用于表示相邻的两个多哈希连接节点之间的执行代价,通过判断该哈希函数对应的执行路径的执行代价是否为所有的执行路径的执行代价中的最小值,若是,则哈希函数对应的多哈希连接节点对应的执行路径满足查询条件,且该哈希函数对应的执行路径为所有执行路径中的最优路径。 In particular, the connection may be performed by the path Duoha Xi corresponding to the nodes corresponding to the determined hash function, by obtaining the connection node weights on each Duoha Xi execution path, and the sum of their weight, to obtain the execution path of the execution cost wherein the weight is used to indicate the execution cost Duoha Xi between two adjacent nodes are connected, by determining the cost of execution of the execution path of the hash function is the minimum value corresponding to the execution cost for all execution paths in if yes, the connection node Duoha Xi corresponding execution path corresponding to the hash functions that satisfy the query, and the execution path corresponding to a hash function for all execution paths in the optimum path. 例如:循环嵌套路径中第一个节点的权值为3,第二个节点的权值为4.5,多哈希路径1中多哈希节点的权值为1,多哈希连接节点的权值为2.5,多哈希路径2 中多哈希节点的权值为1.5,多哈希连接节点的权值为3,则进行最优路径比较之后,获知多哈希路径1满足查询条件,即为最优路径。 For example: Right nested loop path 3 is the first node, the second node weights was 4.5, 1 Duoha Xi path weight value Duoha Xi node 1, connection node Duoha Xi weight of 2.5 Thereafter, the weights of the nodes 2 Duo Haxi Duoha Xi path is 1.5, the node connection weights Duoha Xi is 3, comparing the optimal path, the path 1 is known Duoha Xi satisfies the query condition is the optimal path. 对于获取最优路径的方式,本实施例在此不作特另IJ限制。 For obtaining optimal path embodiment, the present embodiment and will not be limiting Laid another IJ.

[0076] 步骤204、根据哈希函数,在与哈希函数对应的多哈希节点中,查询是否存在与探测表匹配的连接条件的记录。 [0076] Step 204, based on a hash function, the hash function Duoha Xi corresponding to the node, the query whether there is a record of the connection condition table matched probe.

[0077] 在本实施例中,当判断哈希函数对应的多哈希连接节点对应的执行路径满足查询条件获知多哈希路径为最优路径之后,会则根据该哈希函数,通过利用探测表在与哈希函数对应的多哈希节点中,查询与探测表匹配符合的连接条件的记录,若查询到,则并将该符合连接条件的记录通过选择确定的最优路径发送到客户端。 After [0077] In the present embodiment, when the execution path connecting nodes corresponding to the determined Duoha Xi hash function corresponding to satisfy the query path is the best path is known Duoha Xi will be the basis of the hash function table by using detection Duoha Xi node record corresponding to a hash function, the recording condition is connected with the probe query matching matching table, if the query, and then connected to the coincidence condition is transmitted to the client through the determined optimal path selection.

[0078] 步骤205、根据其它的执行路径,在关系表中查询是否存在符合连接条件的记录。 [0078] Step 205, according to other execution path, check whether there is a record of compliance with the conditions in the connection relation table.

[0079] 在本实施例中,若哈希函数对应的执行路径并不是最优路径,可以通过其它的执行路径,例如可以是循环嵌套路径等,在关系表中查询是否存在符合连接条件的记录,若存在,则将该符合连接条件的记录通过选择的路径发送到客户端。 [0079] In the present embodiment, if the hash function corresponding to the execution path is not the optimal path, the path may be performed by another, for example, a nested loop paths, etc., connected to the query whether there is compliance with the conditions in the relationship table record, if present, is connected to the records that meet the criteria to the client through a selected path.

[0080] 本发明实施例提供的基于多哈希表的关系操作优化方法,通过接收客户端发送的查询语句,解析查询语句以判断该查询语句中是否存在连接条件;其中,连接条件包括OR或UNION;若存在连接条件,则根据连接条件,在关系表中选择N个表作为构造表,并分别为N个构造表中的每一个构造表选择至少一个哈希函数,对于每个哈希函数,对相应的构造表进行扫描,以获取与哈希表对应的多哈希节点;对于每个哈希函数,根据哈希函数,在与哈希函数对应的多哈希节点中,查询是否存在与探测表匹配的连接条件的记录,若存在,则将记录发送到客户端;其中,探测表为除构造表之外的其它关系表。 [0080] The embodiment of the present invention is to optimize the operating method Duoha Xi relationship table based on the query transmitted by the receiving client, provided resolve the query statement to determine whether there is a connection condition of the query statement; wherein the connection condition includes an OR or UNION ; If the connection condition exists, according to the connection condition table selected in the table as the N configuration table, and each table is configured for each of the N configuration table selecting at least one hash function for each hash function, the corresponding configuration table is scanned to acquire the hash table corresponding to the node Duoha Xi; for each hash function, a hash function, the hash Duoha Xi node corresponding to the function, and the probe table queries whether there connector matching condition, if present, will be sent to the client record; wherein the probe table to another table in addition to the configuration table. 由于在OR或UNION的连接条件中,根据连接条件对构造表选择至少一个哈希函数,以生成与哈希函数对应的多哈希节点,并根据哈希函数,在与哈希函数对应的多哈希节点中,查询是否存在与探测表匹配的连接条件的记录,避免了现有技术中对涉及的关系表进行多次扫描,以及采用嵌套循环的方式进行连接操作的方式,提高了查询的性能。 Since the join condition or OR UNION, the connection conditions are selected according to a hash function for at least the construction table, a hash function to generate a corresponding Duoha Xi node, and hash function, the hash function corresponding to the Duo Haxi node, check whether there is a record with the connection table matching condition detection, avoiding the prior art embodiment of the table according to multiple scans, and by way of nested loops connecting operation, improves the performance of the query . 另外,通过在多条路径中选择一条最优路径进行查询,可以极大地提高查询效率和查询性能。 Further, by selecting an optimal path in the plurality of query paths, can greatly improve the query performance and query efficiency.

[0081] 图3为本发明基于多哈希表的关系操作优化装置实施例一的结构示意图,如图3所示,本发明实施例提供的基于多哈希表的关系操作优化装置包括收发模块11、判断模块12、 处理模块13和扫描模块14。 [0081] FIG. 3 is a schematic structural diagram of the operation optimization based relationship embodiment Duoha Xi table apparatus shown in Figure 3 of the present invention, an embodiment based on the operation optimization means Duoha Xi relation table includes a transceiver module 11 of the present invention, determining module 12, processing module 13 and the scanner module 14.

[0082] 其中,收发模块11用于接收客户端发送的查询语句;判断模块12用于解析所述查询语句以判断所述查询语句中是否存在连接条件;其中,所述连接条件包括OR或UNION;处理模块13用于在所述判断模块12判断出存在所述连接条件时,根据所述连接条件,在关系表中选择N个表作为构造表,并分别为所述N个构造表中的每一个构造表选择至少一个哈希函数;其中,N为整数,且大于0;扫描模块14用于对于每个哈希函数,对相应的构造表进行扫描,以获取与所述哈希表对应的多哈希节点;所述判断模块12还用于对于每个哈希函数,根据所述哈希函数,在与所述哈希函数对应的所述多哈希节点中,查询是否存在与探测表匹配的连接条件的记录;所述收发模块11还用于在所述判断模块12判断出存在与探测表匹配的连接条件的记录时,将所述记录发送到所述客户端;其中,所 [0082] wherein the transceiver module 11 for receiving the query sent by a client; determining module 12 is configured to parse the query to determine whether there is a connection condition of the query statement; wherein the connection condition includes an OR or UNION ; the processing module 13 for determining module 12 determines that the connection condition exists, according to the connection condition, select N tables in relational tables as the table structure, and each of the N configuration table each of the at least one configuration table selecting a hash function; wherein, N is an integer and is greater than 0; a scanning module 14 for each hash function, the corresponding configuration table are scanned to obtain the hash table corresponding to the the Duoha Xi node; the module 12 for determining, for each hash function, based on the hash function, the hash function Duoha Xi node and the corresponding query whether there is a match with the probe table connected to the recording conditions; for the transceiver module 11 is further connected to the recording module 12 determines that the condition exists that matches with the probe in the determination table, the record is sent to the client; wherein the 探测表为除构造表之外的其它关系表。 Detecting relational table to another table in addition to the configuration table.

[0083] 本发明实施例提供的基于多哈希表的关系操作优化装置,通过接收客户端发送的查询语句,解析查询语句以判断该查询语句中是否存在连接条件;其中,连接条件包括OR或UNION;若存在连接条件,则根据连接条件,在关系表中选择N个表作为构造表,并分别为N个构造表中的每一个构造表选择至少一个哈希函数,对于每个哈希函数,对相应的构造表进行扫描,以获取与哈希表对应的多哈希节点;对于每个哈希函数,根据哈希函数,在与哈希函数对应的多哈希节点中,查询是否存在与探测表匹配的连接条件的记录,若存在,则将记录发送到客户端;其中,探测表为除构造表之外的其它关系表。 [0083] The present invention is based on the operation optimization means Duoha Xi relation table, the query transmitted by the receiving client, parse the query provided by the connection conditions to determine whether the query statement is present; and wherein the connection condition includes an OR or UNION ; If the connection condition exists, according to the connection condition table selected in the table as the N configuration table, and each table is configured for each of the N configuration table selecting at least one hash function for each hash function, the corresponding configuration table is scanned to acquire the hash table corresponding to the node Duoha Xi; for each hash function, a hash function, the hash Duoha Xi node corresponding to the function, and the probe table queries whether there connector matching condition, if present, will be sent to the client record; wherein the probe table to another table in addition to the configuration table. 由于在OR或UNION的连接条件中,根据连接条件对构造表选择至少一个哈希函数,以生成与哈希函数对应的多哈希节点,并根据哈希函数,在与哈希函数对应的多哈希节点中,查询是否存在与探测表匹配的连接条件的记录,避免了现有技术中对涉及的关系表进行多次扫描,以及采用嵌套循环的方式进行连接操作的方式,提高了查询的性能。 Since the join condition or OR UNION, the connection conditions are selected according to a hash function for at least the construction table, a hash function to generate a corresponding Duoha Xi node, and hash function, the hash function corresponding to the Duo Haxi node, check whether there is a record with the connection table matching condition detection, avoiding the prior art embodiment of the table according to multiple scans, and by way of nested loops connecting operation, improves the performance of the query .

[0084] 可选地,所述扫描模块14还用于对所述探测表进行扫描,获得与所述探测表对应的扫描节点;所述处理模块13还用于对于每个哈希函数,将所述扫描节点与所述哈希函数对应的多哈希节点进行多哈希连接,生成对应的多哈希连接节点;所述判断模块12还用于对于每个哈希函数,判断所述哈希函数对应的多哈希连接节点对应的执行路径是否满足查询条件;则所述判断模块12具体用于若所述哈希函数对应的多哈希连接节点对应的执行路径满足所述查询条件,则根据所述哈希函数,在与所述哈希函数对应的所述多哈希节点中, 查询是否存在与探测表匹配的连接条件的记录。 [0084] Alternatively, the scanning module 14 is further configured to scan the probe table, obtained with a scanning node table corresponding to the probe; the processing module 13 is further configured for each hash function, the scan node and the hash function Duoha Xi corresponding connection node Duoha Xi, Duoha Xi generates a corresponding connection node; the determination module 12 is further configured to correspond to each hash function, the hash function is determined Duoha Xi corresponding to the node of the connection path is performed to satisfy the query; the determining module 12 is configured to connect the node corresponding to Duoha Xi execution path if the corresponding hash function satisfies the query condition, according to the Ha Xi function, the Duoha Xi node and the corresponding hash function, check whether there is a record of the connection condition table matched probe.

[0085] 本实施例的基于多哈希表的关系操作优化装置,可以用于执行本发明任意实施例所提供的基于多哈希表的关系操作优化方法的技术方案,其实现原理和技术效果类似,此处不再赘述。 Optimization means operating relationship table based Duoha Xi [0085] embodiment of the present embodiment may be used to perform optimization based on an operation table of the relational approach Duoha Xi technical solution provided in any embodiment of the present invention that achieve a similar principle and technical effects, not repeat them here.

[0086] 图4为本发明基于多哈希表的关系操作优化装置实施例二的结构示意图,如图4所示,本实施例在图3所示实施例的基础上,所述判断模块还包括:确定单元121、获取单元122 和判断单元123。 Module further comprises a structural diagram according to a second embodiment based on the operation of the optimization apparatus relation table Duoha Xi [0086] FIG. 4 of the present invention, shown in Figure 4, in this embodiment, the embodiment shown in FIG. 3 based on the determination : determination unit 121, acquisition unit 122 and the determination unit 123.

[0087] 其中,所述确定单元121用于对于每个哈希函数,确定所述哈希函数对应的多哈希连接节点对应的执行路径;所述获取单元122用于获取所述执行路径上的各多哈希连接节点的权值,并将各所述权值相加,获得所述执行路径的执行代价;其中,所述权值用于表示对应的多哈希连接节点与其相邻的多哈希连接节点之间的执行代价;所述判断单元123用于判断所述哈希函数对应的执行路径的所述执行代价,是否为所有的执行路径的执行代价中的最小值;若是,则所述哈希函数对应的多哈希连接节点对应的执行路径满足查询条件。 [0087] wherein, the determining unit 121 is configured for each hash function, the hash function is determined execution path corresponding Duoha Xi corresponding connection node; on the acquisition unit 122 for acquiring the execution path Duoha Xi weights of the connection node values, and adds each of the weighting values ​​to obtain the execution cost of the execution path; wherein the weight is used to indicate the corresponding Duoha Xi connection node connecting adjacent Duo Haxi execution cost between the nodes; the judging unit 123 for performing the determining the cost of execution path corresponding hash function, the execution cost is the minimum value of all of the execution paths; if yes, the Ha Duoha Xi Xi corresponding to the connection node corresponding to the function execution paths that satisfy the query.

[0088] 本实施例的基于多哈希表的关系操作优化装置,可以用于执行本发明任意实施例所提供的基于多哈希表的关系操作优化方法的技术方案,其实现原理和技术效果类似,此处不再赘述。 [0088] The embodiment according to the present embodiment based on the operation optimization means Duoha Xi relationship table may be used to perform optimization based on an operation table of the relational approach Duoha Xi technical solution provided in any embodiment of the present invention that achieve a similar principle and technical effects, not repeat them here.

[0089] 本发明还提供一种基于多哈希表的关系操作优化系统,包括:客户端和基于多哈希表的关系操作优化装置,其中,基于多哈希表的关系操作优化装置可以采用图3或图4所示的报文转发装置实施例中提供的装置,其具体结构和功能此处不再赘述。 [0089] The present invention also provides a system to optimize the relationship between the operating table based Duoha Xi, comprising: optimizing the relationship between the client and the operating means based Duoha Xi table, wherein, based on the operation optimization means Duoha Xi relationship table may be employed in FIG. 3 or FIG packet forwarding means 4 shown embodiment provided in the Examples, which will not be repeated herein, specific structural and functional.

[0090] 图5为本发明提供的服务器实施例一的结构示意图。 Schematic diagram of a structure of [0090] FIG. 5 of the present invention provides a server implementation. 如图5所示,本发明实施例提供的服务器包括接收器21、处理器22和发送器23。 As shown in FIG. 5, a server provided in the embodiment of the present invention includes a receiver 21, a processor 22 and a transmitter 23.

[0091] 其中,接收器21用于接收客户端发送的查询语句;处理器22用于解析所述查询语句以判断所述查询语句中是否存在连接条件;其中,所述连接条件包括OR或UNION;所述处理器22还用于若存在所述连接条件,则根据所述连接条件,在关系表中选择N个表作为构造表,并分别为所述N个构造表中的每一个构造表选择至少一个哈希函数;其中,N为整数,且大于〇;所述处理器22还用于对于每个哈希函数,对相应的构造表进行扫描,以获取与所述哈希表对应的多哈希节点;所述处理器22还用于对于每个哈希函数,根据所述哈希函数,在与所述哈希函数对应的所述多哈希节点中,查询是否存在与探测表匹配的连接条件的记录,所述发送器23用于在所述处理器22判断出存在与探测表匹配的连接条件的记录时,将所述记录发送到所述客户端;其中,所述探测表为除构造表之外 [0091] wherein the receiver 21 for receiving the query sent by a client; a processor 22 configured to parse the query to determine whether there is a connection condition of the query statement; wherein the connection condition includes an OR or UNION ; the processor 22 is further configured to, if the connection condition exists, according to the connection condition, select N relationship table as in table configuration table, and each table is configured for each of the N configuration table selecting at least one hash function; wherein, N is an integer and greater than a square; the processor 22 is further configured to, for each hash function, the corresponding configuration table are scanned to obtain the hash table correspond to the Duoha Xi node; the processor 22 is further configured to, for each hash function, based on the hash function, the hash function Duoha Xi node and the corresponding, check whether there is a match with the probe table connecting the recording condition, the transmitter 23 is connected to the recording condition when the processor 22 determines that there is matching the probe table, the record is sent to the client; wherein said detection table In addition to the construction table 其它关系表。 Other relational tables.

[0092] 本实施例的服务器,可以用于执行本发明任意实施例所提供的基于多哈希表的关系操作优化方法的技术方案,其实现原理和技术效果类似,此处不再赘述。 [0092] server according to the present embodiment, the present invention may be used to perform any operation based on the optimization of the relationship between the method table Duoha Xi technical solutions provided in the embodiments, principles and techniques which achieve a similar effect, are not repeated herein.

[0093] 可选地,所述处理器22还用于对所述探测表进行扫描,获得与所述探测表对应的扫描节点;所述处理器22还用于对于每个哈希函数,将所述扫描节点与所述哈希函数对应的多哈希节点进行多哈希连接,生成对应的多哈希连接节点;所述处理器22还用于对于每个哈希函数,判断所述哈希函数对应的多哈希连接节点对应的执行路径是否满足查询条件;所述处理器22还用于若判断所述哈希函数对应的多哈希连接节点对应的执行路径满足所述查询条件,则根据所述哈希函数,在与所述哈希函数对应的所述多哈希节点中,查询是否存在与探测表匹配的连接条件的记录。 [0093] Alternatively, the processor 22 is further configured to scan the probe table, obtained with a scanning node table corresponding to the probe; the processor 22 is further configured for each hash function, the the scan Duoha Xi node connected to the node hash function corresponding Duoha Xi, Duoha Xi generates a corresponding connection node; the processor 22 is further configured for each hash function, the hash function is determined corresponding to Duoha Xi corresponding to the node of the connection path is performed to satisfy the query; the processor 22 is also connected to Duoha Xi corresponding to the node determines if the execution path of the corresponding hash function satisfies the query condition, according to the Ha Xi function, the Duoha Xi node and the corresponding hash function, check whether there is a record of the connection condition table matched probe.

[0094] 可选地,所述处理器22还用于对于每个哈希函数,确定所述哈希函数对应的多哈希连接节点对应的执行路径;所述处理器22还用于获取所述执行路径上的各多哈希连接节点的权值,并将各所述权值相加,获得所述执行路径的执行代价;其中,所述权值用于表示对应的多哈希连接节点与其相邻的多哈希连接节点之间的执行代价;所述处理器22还用于判断所述哈希函数对应的执行路径的所述执行代价,是否为所有的执行路径的执行代价中的最小值;若是,则所述哈希函数对应的多哈希连接节点对应的执行路径满足查询条件。 [0094] Alternatively, the processor 22 is further configured for each hash function, determines the execution path Duoha Xi corresponding to the node connected to the corresponding hash function; the processor is further configured to obtain the 22 weight of each connection node value Duoha Xi execution path, and each of said weight values ​​are added to obtain the execution cost of the execution path; wherein the weight is used to indicate the corresponding connection node adjacent Duo Haxi execution cost of a connection node between the Duoha Xi; the cost of execution of said further processor 22 for determining the execution path corresponding hash function, the execution cost is the minimum value of all of the execution paths; if Duoha Xi corresponding execution path connecting node, then the hash function corresponding to satisfy the query.

[0095] 本实施例的服务器,可以用于执行本发明任意实施例所提供的基于多哈希表的关系操作优化方法的技术方案,其实现原理和技术效果类似,此处不再赘述。 [0095] server according to the present embodiment, the present invention may be used to perform any operation based on the optimization of the relationship between the method table Duoha Xi technical solutions provided in the embodiments, principles and techniques which achieve a similar effect, are not repeated herein.

[0096] 本领域普通技术人员可以理解:实现上述各方法实施例的全部或部分步骤可以通过程序指令相关的硬件来完成。 [0096] Those of ordinary skill in the art will be appreciated that: each of the foregoing methods to complete all or part of the hardware can step through the program instructions relating to the implementation. 前述的程序可以存储于一计算机可读取存储介质中。 The program may be stored in a computer readable storage medium. 该程序在执行时,执行包括上述各方法实施例的步骤;而前述的存储介质包括:R〇M、RAM、磁碟或者光盘等各种可以存储程序代码的介质。 When the program is executed, comprising the step of performing the above-described method of the embodiment; and the storage medium comprising: a variety of medium may store program codes R〇M, RAM, magnetic disk, or optical disk.

[0097] 最后应说明的是:以上各实施例仅用以说明本发明的技术方案,而非对其限制;尽管参照前述各实施例对本发明进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分或者全部技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本发明各实施例技术方案的范围。 [0097] Finally, it should be noted that: the above embodiments only describe the technical solutions in embodiments of the present invention, rather than limiting;. Although the embodiments of the present invention has been described in detail, those of ordinary skill in the art should appreciated: it still may be made to the technical solutions described embodiments modifications, or to some or all of the technical features equivalents; as such modifications or replacements do not cause the essence of corresponding technical solutions to depart from embodiments of the present invention range of technical solutions.

Claims (7)

1. 一种基于多哈希表的关系操作优化方法,其特征在于,包括: 接收客户端发送的查询语句,解析所述查询语句以判断所述查询语句中是否存在连接条件;其中,所述连接条件包括OR或UNION; 若存在所述连接条件,则根据所述连接条件,在关系表中选择N个表作为构造表,并分别为所述N个构造表中的每一个构造表选择至少一个哈希函数;其中,N为整数,且大于0; 对于每个哈希函数,对相应的构造表进行扫描,以获取与所述哈希表对应的多哈希节占. 对于每个哈希函数,根据所述哈希函数,在与所述哈希函数对应的所述多哈希节点中, 查询是否存在与探测表匹配的连接条件的记录,若存在,则将所述记录发送到所述客户端; 其中,所述探测表为除构造表之外的其它关系表。 1. A method of operating table Duoha Xi optimization method based on the relationship, which is characterized in that, comprising: receiving a query sent by the client, parse the query to determine whether the query statement there is a connection condition; wherein the connecting or oR conditions include the UNION; if the connection condition exists, according to the connection condition table selected in the table as the N configuration table, and each table is configured for each of the N selected at least one configuration table a hash function; wherein, N is an integer and is greater than 0; for each hash function, the corresponding configuration table are scanned to obtain the hash table corresponding to the account section Duoha Xi for each hash function. based on the hash function, the hash function Duoha Xi node and the corresponding query whether there is a connection condition detection record matching table, if present, then the record is sent to the client end; wherein the other table is a table detection in addition to the configuration table.
2. 根据权利要求1所述的方法,其特征在于,在所述对于每个哈希函数,对相应的构造表进行扫描,以获取与所述哈希表对应的多哈希节点之后,所述方法还包括: 对所述探测表进行扫描,获得与所述探测表对应的扫描节点; 对于每个哈希函数,将所述扫描节点与所述哈希函数对应的多哈希节点进行多哈希连接,生成对应的多哈希连接节点; 对于每个哈希函数,判断所述哈希函数对应的多哈希连接节点对应的执行路径是否满足查询条件; 则所述根据所述哈希函数,在与所述哈希函数对应的所述多哈希节点中,查询是否存在与探测表匹配的连接条件的记录,具体包括: 若判断所述哈希函数对应的多哈希连接节点对应的执行路径满足所述查询条件,则根据所述哈希函数,在与所述哈希函数对应的所述多哈希节点中,查询是否存在与探测表匹配的连接 2. The method according to claim 1, characterized in that, for each hash function, the corresponding structure in the scan table, to obtain the corresponding Duoha Xi after the node and the hash table, the the method further comprises: scanning the probe table, obtained with a scanning node table corresponding to the probe; for each hash function, the scan Duoha Xi node connected to the node hash function corresponding to the Duo Haxi , Duoha Xi generates a corresponding connection node; for each hash function, Duoha Xi is connected to the node corresponding to the determined hash function corresponding to the execution path satisfies the query condition; is the basis of the hash function with the the Duoha Xi node corresponding to said hash function, check whether there is a record with the connection condition detection matching table comprises: determining if said corresponding node is connected Duoha Xi execution path corresponding hash function satisfies the query condition, according to the hash function, the hash function Duoha Xi node and the corresponding query whether there is a table match with the probe connector 件的记录。 Piece records.
3. 根据权利要求2所述的方法,其特征在于,所述对于每个哈希函数,判断所述哈希函数对应的多哈希连接节点对应的执行路径是否满足查询条件,具体包括: 对于每个哈希函数,确定所述哈希函数对应的多哈希连接节点对应的执行路径; 获取所述执行路径上的各多哈希连接节点的权值,并将各所述权值相加,获得所述执行路径的执行代价;其中,所述权值用于表示对应的多哈希连接节点与其相邻的多哈希连接节点之间的执行代价; 判断所述哈希函数对应的执行路径的所述执行代价,是否为所有的执行路径的执行代价中的最小值;若是,则所述哈希函数对应的多哈希连接节点对应的执行路径满足查询条件。 3. The method according to claim 2, characterized in that, for each of the hash function, Duoha Xi corresponding execution path connecting node determines whether the hash function corresponding to satisfy the query, comprises: for each hash functions, determining Duoha Xi corresponding to the connecting node performs a hash function corresponding to the path; Duoha Xi obtain weight of each connection node on the execution path, and each of said weight values ​​are added to give the said execution cost path; wherein the weighting values ​​used to represent the corresponding execution cost Duoha Xi between the connection node connecting node Duoha Xi adjacent thereto; the execution path corresponding to the determined hash function execution consideration, the execution cost is the minimum value of all of the execution paths; query if yes, the connecting node Duoha Xi corresponding to a hash function corresponding to the execution path meet.
4. 一种基于多哈希表的关系操作优化装置,其特征在于,包括: 收发模块,用于接收客户端发送的查询语句; 判断模块,用于解析所述查询语句以判断所述查询语句中是否存在连接条件;其中,所述连接条件包括OR或UNION; 处理模块,用于在所述判断模块判断出存在所述连接条件时,根据所述连接条件,在关系表中选择N个表作为构造表,并分别为所述N个构造表中的每一个构造表选择至少一个哈希函数;其中,N为整数,且大于0; 扫描模块,用于对于每个哈希函数,对相应的构造表进行扫描,以获取与所述哈希表对应的多哈希节点; 所述判断模块还用于对于每个哈希函数,根据所述哈希函数,在与所述哈希函数对应的所述多哈希节点中,查询是否存在与探测表匹配的连接条件的记录; 所述收发模块还用于在所述判断模块判断出存在与探测表匹配的连接 A relationship based on the operation optimization means Duoha Xi table, wherein, comprising: a transceiver module for receiving a query sent by a client; determining module, configured to parse the query to determine whether the query statement whether there is a connection condition; wherein the connection condition includes the UNION or oR; a processing module, the judging module determines that the connection condition exists, according to the connection condition, select N relationship table as in table construction table, and each table is configured for each of the N configuration table selecting at least one hash function; wherein, N is an integer and is greater than 0; a scanning module for, for each hash function, the corresponding construction table are scanned to acquire Duoha Xi corresponding node of the hash table; the determination module is further configured, for each hash function, based on the hash function, the hash function in the corresponding Duoha Xi said node, check whether there is a record in the connection condition table matched probe; the transceiver module is further used in the determination means determines that there is a matching connector of the probe table 件的记录时, 将所述记录发送到所述客户端;其中,所述探测表为除构造表之外的其它关系表。 When the recording member, the recording is sent to the client; wherein the other table is a table detection in addition to the configuration table.
5. 根据权利要求4所述的装置,其特征在于, 所述扫描模块,还用于对所述探测表进行扫描,获得与所述探测表对应的扫描节点; 所述处理模块还用于对于每个哈希函数,将所述扫描节点与所述哈希函数对应的多哈希节点进行多哈希连接,生成对应的多哈希连接节点; 所述判断模块还用于对于每个哈希函数,判断所述哈希函数对应的多哈希连接节点对应的执行路径是否满足查询条件; 则所述判断模块具体用于若所述哈希函数对应的多哈希连接节点对应的执行路径满足所述查询条件,则根据所述哈希函数,在与所述哈希函数对应的所述多哈希节点中,查询是否存在与探测表匹配的连接条件的记录。 5. The apparatus as claimed in claim 4, wherein said scan module is further configured to scan the probe table, obtained with a scanning node table corresponding to the probe; the processing module is further configured for each hash function, the hash function scan node and the corresponding node Duoha Xi Duoha Xi connected Duoha Xi generates a corresponding connection node; the determination module is further configured for each hash function, determines the hash corresponding connecting node Duoha Xi corresponding to the function execution path satisfies the query condition; the determining module is connected to the node corresponding to Duoha Xi execution path if the corresponding hash function satisfies the query condition, it is based on the hash function, the hash function Duoha Xi node and the corresponding, check whether there is a record in the connection condition table matched probe.
6. 根据权利要求5所述的装置,其特征在于,所述判断模块还包括:确定单元、获取单元和判断单元; 其中,所述确定单元用于对于每个哈希函数,确定所述哈希函数对应的多哈希连接节点对应的执行路径; 所述获取单元,用于获取所述执行路径上的各多哈希连接节点的权值,并将各所述权值相加,获得所述执行路径的执行代价;其中,所述权值用于表示对应的多哈希连接节点与其相邻的多哈希连接节点之间的执行代价; 所述判断单元,用于判断所述哈希函数对应的执行路径的所述执行代价,是否为所有的执行路径的执行代价中的最小值;若是,则所述哈希函数对应的多哈希连接节点对应的执行路径满足查询条件。 6. The apparatus as claimed in claim 5, wherein the determining module further comprises: a determination unit, the acquisition unit and judging means; wherein the means for determining, for each hash function, determining the Ha Duoha Xi corresponding to the connecting node performs a function corresponding to the Greek path; the obtaining unit, configured to obtain the weights of each execution Duoha Xi connection node on the path, and each of said weight values ​​are added to obtain the execution execution cost of the path; wherein the weighting values ​​used to represent the corresponding execution cost Duoha Xi between the connection node connecting adjacent nodes Duoha Xi; Analyzing hash function execution corresponding to the determination means for the the execution cost path, the execution cost is the minimum value of all of the execution paths; query if yes, the connecting node Duoha Xi corresponding to a hash function corresponding to the execution path meet.
7. —种基于多哈希表的关系操作优化系统,其特征在于,包括:客户端和如权利要求4-6任一项所述的基于多哈希表的关系操作优化装置。 7. - species relationship Duoha Xi operating table based optimization system, characterized by comprising: based on an operation optimization means Duoha Xi relation table according to any one of claims 4-6 and claim client.
CN201410844188.8A 2014-12-30 2014-12-30 Optimization method based on the operation relationship table Duoha Xi, apparatus and system CN104504114B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201410844188.8A CN104504114B (en) 2014-12-30 2014-12-30 Optimization method based on the operation relationship table Duoha Xi, apparatus and system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201410844188.8A CN104504114B (en) 2014-12-30 2014-12-30 Optimization method based on the operation relationship table Duoha Xi, apparatus and system

Publications (2)

Publication Number Publication Date
CN104504114A CN104504114A (en) 2015-04-08
CN104504114B true CN104504114B (en) 2018-05-04

Family

ID=52945511

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201410844188.8A CN104504114B (en) 2014-12-30 2014-12-30 Optimization method based on the operation relationship table Duoha Xi, apparatus and system

Country Status (1)

Country Link
CN (1) CN104504114B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107153643A (en) * 2016-03-02 2017-09-12 阿里巴巴集团控股有限公司 Data table connection method and device
CN107229692B (en) * 2017-05-19 2018-05-01 哈工大大数据产业有限公司 Based on the distributed pipeline method and system for multi-table join

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP2350879A1 (en) * 2008-09-19 2011-08-03 Oracle International Corporation Hash join using collaborative parallel filtering in intelligent storage with offloaded bloom filters
CN103823834A (en) * 2013-12-03 2014-05-28 华为技术有限公司 Device and method for data transmission among Hash join operators
CN103942343A (en) * 2014-05-12 2014-07-23 中国人民大学 Data storage optimization method for hash joint

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20130013585A1 (en) * 2011-07-08 2013-01-10 Goetz Graefe Hash join and hash aggregation integration system

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP2350879A1 (en) * 2008-09-19 2011-08-03 Oracle International Corporation Hash join using collaborative parallel filtering in intelligent storage with offloaded bloom filters
CN103823834A (en) * 2013-12-03 2014-05-28 华为技术有限公司 Device and method for data transmission among Hash join operators
CN103942343A (en) * 2014-05-12 2014-07-23 中国人民大学 Data storage optimization method for hash joint

Also Published As

Publication number Publication date
CN104504114A (en) 2015-04-08

Similar Documents

Publication Publication Date Title
US6957225B1 (en) Automatic discovery and use of column correlations in tables
US7805411B2 (en) Auto-tuning SQL statements
US9098587B2 (en) Variable duration non-event pattern matching
US20050114311A1 (en) Method, system, and program for query optimization with algebraic rules
US9361340B2 (en) Processing database queries using format conversion
US20040117359A1 (en) Adaptable query optimization and evaluation in temporal middleware
US7363289B2 (en) Method and apparatus for exploiting statistics on query expressions for optimization
Hayes et al. Helping analysts trace requirements: An objective look
EP1577796A1 (en) Improved Query Optimizer Using Implied Predicates
US7296011B2 (en) Efficient fuzzy match for evaluating data records
US6738782B2 (en) Method and mechanism for extending native optimization in a database system
US7359922B2 (en) Database system and methodology for generalized order optimization
US7685095B2 (en) Executing a parallel single cursor model
US7490110B2 (en) Predictable query execution through early materialization
US20090327208A1 (en) Discovering transformations applied to a source table to generate a target table
US20100161589A1 (en) Graphical Representation of Query Optimizer Search Space In A Database Management System
US20140172914A1 (en) Graph query processing using plurality of engines
US20090254522A1 (en) Detecting estimation errors in dictinct page counts
US20030172059A1 (en) Database system providing methodology for eager and opportunistic property enforcement
CN102043833B (en) Search method and device based on query word
US7966330B2 (en) Techniques for partition pruning
US20050010570A1 (en) System and method of query transformation
US20080071754A1 (en) Estimating a number of rows returned by a recursive query
US7933894B2 (en) Parameter-sensitive plans for structural scenarios
Chan et al. Fault-based testing of database application programs with conceptual data model

Legal Events

Date Code Title Description
C06 Publication
C10 Entry into substantive examination
GR01