hive sql 优化 数据倾斜
2015-05-13 12:48
239 查看
此脚本运行速度慢,主要是reduce端数据倾斜导致的,了解到dw.fct_traffic_navpage_path_detl表是用来收集用户点击数据的,那么最终
购物车和下单的点击肯定极少,所以此表ordr_code字段为空和cart_prod_id字段为NULL的数据量极大,如下所示:
select ordr_code,count(*) as a from dw.fct_traffic_navpage_path_detl where ds = '2015-05-10' group by ordr_code having a>10000 ; 151722135select cart_prod_id,count(*) as a fromdw.fct_traffic_navpage_path_detl where ds = '2015-05-10' groupby cart_prod_id having a>10000 ;NULL 127233335
对于create table tmp_lifan_trfc_tpa as 这句SQL,BI加上如下配置,
set hive.mapjoin.smalltable.filesize = 120000000; //因为 dw.univ_parnt_tranx_comb_detl表最大不超过120MB,如果是hive on tez要用hive.auto.convert.join.noconditionaltask.size ,这样tez会生成BROADCASTsethive.auto.convert.join=true;同时修改SQL如下语句:from dw.fct_traffic_navpage_path_detl t left outer join dw.univ_parnt_tranx_comb_detl o //用mapjoin解决数据倾斜 on t.ordr_code = o.parnt_ordr_code and t.cart_prod_id = o.comb_prod_id and o.ds = '2015-05-10' left outer join bic.cust_first_ordr_tranx f on case when o.end_user_id is null then cast(rand(9)*100as bigint) else o.end_user_id end = f.end_user_id //join后数倾斜用随机数避免倾斜 ,红色为修改部分 and f.first_ordr_date_id = '2015-05-10'where t.ds = '2015-05-10';运行后SQL可以在可控时间内完成。
购物车和下单的点击肯定极少,所以此表ordr_code字段为空和cart_prod_id字段为NULL的数据量极大,如下所示:
select ordr_code,count(*) as a from dw.fct_traffic_navpage_path_detl where ds = '2015-05-10' group by ordr_code having a>10000 ; 151722135select cart_prod_id,count(*) as a fromdw.fct_traffic_navpage_path_detl where ds = '2015-05-10' groupby cart_prod_id having a>10000 ;NULL 127233335
对于create table tmp_lifan_trfc_tpa as 这句SQL,BI加上如下配置,
set hive.mapjoin.smalltable.filesize = 120000000; //因为 dw.univ_parnt_tranx_comb_detl表最大不超过120MB,如果是hive on tez要用hive.auto.convert.join.noconditionaltask.size ,这样tez会生成BROADCASTsethive.auto.convert.join=true;同时修改SQL如下语句:from dw.fct_traffic_navpage_path_detl t left outer join dw.univ_parnt_tranx_comb_detl o //用mapjoin解决数据倾斜 on t.ordr_code = o.parnt_ordr_code and t.cart_prod_id = o.comb_prod_id and o.ds = '2015-05-10' left outer join bic.cust_first_ordr_tranx f on case when o.end_user_id is null then cast(rand(9)*100as bigint) else o.end_user_id end = f.end_user_id //join后数倾斜用随机数避免倾斜 ,红色为修改部分 and f.first_ordr_date_id = '2015-05-10'where t.ds = '2015-05-10';运行后SQL可以在可控时间内完成。
相关文章推荐
- Hive SQL数据倾斜及优化
- hive优化(4)之mapjoin和union all避免数据倾斜
- 深入浅出数据仓库中SQL性能优化之Hive篇
- 深入浅出数据仓库中SQL性能优化之Hive篇
- 017-Hadoop Hive sql语法详解7-去重排序、数据倾斜
- 深入浅出数据仓库中SQL性能优化之Hive篇
- 大数据Spark “蘑菇云”行动第101课:Hive性能调优之企业级数据倾斜解决方案及对Job数目的优化
- Hive优化----利用随机数避免数据倾斜
- 深入浅出数据仓库中SQL性能优化之Hive篇
- 深入浅出数据仓库中SQL性能优化之Hive篇
- Hive优化---mapjoin和union all避免数据倾斜
- 深入浅出数据仓库中SQL性能优化之Hive篇
- 深入浅出数据仓库中SQL性能优化之Hive篇
- 深入浅出数据仓库中SQL性能优化之Hive篇
- 深入浅出数据仓库中SQL性能优化之Hive篇
- 深入浅出数据仓库中SQL性能优化之Hive篇
- hive语句优化-通过groupby实现distinct(数据量特别大的时候,使用distinct去重容易导致数据倾斜)
- 深入浅出数据仓库中SQL性能优化之Hive篇
- [置顶] hive数据倾斜优化