【发布时间】:2017-02-26 22:50:33
【问题描述】:
我正在使用 map reduce 实现左连接功能。左侧有大约 6 亿条记录,右侧有大约 2300 万条记录。在映射器中,我使用左连接条件中使用的列来制作键,并将键值输出从映射器传递到减速器。 我遇到了性能问题,因为两个表中的值数量都很高(例如分别为 456789 和 78960)的映射器键很少。即使其他减速器完成了他们的工作,这些减速器也会继续运行更长的时间。 有什么方法可以让多个 reducer 并行处理 mapper 的相同键值输出以提高性能?
这是我要优化的 Hive 查询。
select distinct
a.sequence,
a.fr_nbr,
b.to_nbr,
a.fr_radius,
a.fr_zip,
a.latitude as fr_latitude,
a.longitude as fr_longitude,
a.to_zip,
b.latitude as to_latitude,
b.longitude as to_longitude,
((2 * asin( sqrt( cos(radians(a.latitude)) * cos(radians(b.latitude)) * pow(sin(radians((a.longitude - b.longitude)/2)), 2) + pow(sin(radians((a.latitude - b.latitude)/2)), 2) ) )) * 6371 * 0.621371) as distance,
a.load_year,
a.load_month
from common.sb_p1 a LEFT JOIN common.sb__temp0u b
on a.to_zip=b.zip
and a.load_year=b.load_year
and a.load_month=b.load_month
where b.correction = 0
and a.fr_nbr <> b.to_nbr
and ((2 * asin( sqrt( cos(radians(a.latitude)) * cos(radians(b.latitude)) * pow(sin(radians((a.longitude - b.longitude)/2)), 2) + pow(sin(radians((a.latitude - b.latitude)/2)), 2) ) )) * 6371 * 0.621371 <= a.fr_radius)
任何其他解决方案也将不胜感激。
【问题讨论】:
-
你在做什么类型的加入? Map-side (replicated) or reduce-side (repartition) ?
-
如果您知道您的密钥,您可以编写自定义分区以获得更好的性能。 Exp: If key.valuetutorialspoint.com/map_reduce/map_reduce_partitioner.htm
-
@Nicomak 我正在使用reduce side join。
标签: hadoop mapreduce reduce hadoop2 mapper