[摘]连接算法伪代码

Nested Join算法:

for each row R1 in the outer table

  for each row R2 in the inner table

    if R1 joins with R2

      return (R1,R2)

 

Left Outer Join算法:

for each row R1 in the outer table

  begin

    for each row R2 in the inner table

      if R1 joins with R2

        output (R1,R2)

      if R1 did not join

        output (R1,NULL)

  end

 

Merge Join算法:

get first row R1 from input 1

get first row R2 from input 2

while not at the end of either input

  begin

    if R1 joins with R2

      begin

        output (R1,R2)

        get next row R2 from input 2

      end

    else if R1<R2

      get next row R1 from input 1

    else

      get next row R2 from input 2

  end

 

 

Hash Join算法:

for each row R1 in the build table

  begin

    calculate hash value on R1 join key(s)

    insert R1 into the appropriate hash bucket

  end

for each row R2 in the probe table

  begin

    calculate hash value on R2 join key(s)

    for each row R1 in the corresponding hash bucket

      if R1 join with R2

        output (R1,R2)

  end

 

 

 

Nested Join对于小的数据集很有用,Merge Join对于中型数据集很有用,Hash Join 对于大型数据集很有用.Hash Join在并行性和比例性方面优于其他的连接,并且对于数据仓库的查询请求反应很快.

hash Join和Merge Join有很多共同的特性.如同Merge Join,Hash Join需要至少一个等值连接谓词,支持剩余谓词,也支持所有的外连接和半连接.不同于Merge Join,Hash Join不需要排序的输入集,在支持Full Outer Join时需要一个等值连接谓词.

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值