2010-12-08 29 views

回答

2

這對於合併連接來說是不可能的。 Merge Join algorithm依賴於有兩個排序的輸入集,並繼續如下。

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 
       return (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 

如果輸入集是

input 1      input 2 
------      ------ 
    1       7 
    2       8 
    3       9 

然後加入input2.value > input1.value將返回9行(每種排列)。然而,對於通過每一組單遍的算法,這是不可能的。

相關問題