优化一:hive.auto.convert.join

大表关联小表,把小表自动加载到内存中,需要确认以下配置为true,相当于写了一个mapjoin

set hive.auto.convert.join = true;
hive.mapjoin.smalltable.filesize 默认值是25mb

实例:

insert overwrite table ${dm_bas}.day_user_play_update
select 
a.datess,
a.device_id,
COALESCE(c.play_type_id,'01') as play_type_id,
from 
    ${dm_bas}.day_user_play a 
LEFT JOIN 
    ${dim}.cms_play_code c ON a.url_first=c.play_code;

查看url占比前十的数据

select url_first,count(1) as num from dm_bas.day_user_play group by url_first order by num desc limit 10;
http://hztmedia.jxa.bcs.ottcn.com   301002483
http://ltcucdn.hvs.fj.chinamobile.com   12086326
http://otttv.bj.chinamobile.com 9189452
http://117.169.120.98   7309174
http://127.0.0.1:8090   6819233
http://gslbserv.itv.cmvideo.cn  5980901
http://218.207.213.107:80   5509762
http://111.40.205.11    4412248
http://39.134.115.221   3914061
http://120.210.193.151:8006 3636822

基表总数据量为489268186,第一个url占了61.5%

select count(1) as num from dm_bas.day_user_play;

当day_user_play和cms_play_code做关联的时候排序第一个url最终会分发到一个reduce中去,所有的任务要等待这个reduce完成才会继续,把小的表加入内存,可以配置这个参数,是hive自动根据sql,选择使用common join或者map join
map join并不会涉及reduce操作。map端join的优势就是在于没有shuffle

关联参考

--是否自动转换为mapjoin
set hive.auto.convert.join = true;
--小表的最大文件大小,默认为25000000,即25M
set hive.mapjoin.smalltable.filesize = 25000000;
--是否将多个mapjoin合并为一个
set hive.auto.convert.join.noconditionaltask = true;
--多个mapjoin转换为1个时,所有小表的文件大小总和的最大值。
set hive.auto.convert.join.noconditionaltask.size = 10000000;

参考:http://blog.csdn.net/yycdaizi/article/details/50158573
https://m.aliyun.com/yunqi/articles/59635

    原文作者:AI_leef
    原文地址: https://www.jianshu.com/p/3f6991dc6baf
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞