我想加入两个表,它们有一个共同的列和相同数量的具有相同排序的存储桶。
除了设置属性之外,我还需要设置任何其他条件吗?
set hive.optimize.bucketmapjoin = true;
set hive.optimize.bucketmapjoin.sortedmerge = true;
set hive.input.format=org.apache.hadoop.hive.ql.io.BucketizedHiveInputFormat;
最佳答案
如果您有两个数据集对于 map 侧连接来说太大了,连接它们的一种有效技术是将两个数据集分类到存储桶中。
诀窍是通过相同的连接键进行聚类和排序。
CREATE TABLE order(int,price float,quantity int)
由(cid)聚集到 32 个桶中;
CREATE TABLE 客户(id int,第一个字符串,最后一个字符串)
由(id)聚集到 32 个桶中;
这提供了两个主要的优化好处:
Sorting by join key makes joins easy ,all possible matches value resides on the same area on disk
Hash bucketing a join key ensures all matching values reside on same node ,equi join can then run with no shuffle .
关于sorting - 如何实现Sort Merge Bucketing Map Join?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26269189/