SQL优化:distribute by 小数据场景处理数据倾斜

distribute by rand()

distribute by :用来控制map输出结果的分发,即map端如何拆分数据给reduce端。 会根据distribute by 后边定义的列,根据reduce的个数进行数据分发,默认是采用hash算法。

 

使用方法:直接在sql结尾处加上 distribute by rand() 
举例:
select A ,B from  $table distribute by rand();

 

posted @ 2022-04-14 16:13  HANIEEE  Views(539)  Comments(0Edit  收藏  举报