hive-substr的group-by-cause-slow性能

zqdjd7g9  于 2021-06-02  发布在  Hadoop
关注(0)|答案(0)|浏览(187)

我有一个表,每个分区(ds)有大约300000条记录。
在配置单元中运行以下查询(使用substr选择)时,它将挂起在步骤:map=0%

select t0.stat_date,t0.plat,t0.soh,t0.page_name,t0.component_name ,count(*) as num,user_id,t0.other_info
from (
    select substr(stat_time,1,8) as stat_date,user_id,city_id,soh,dept_id,dph,plat,page_name,component_name,cookie_id,other_info
    from db.table
    where ds=20170221 and plat='abc'
)t0
group by stat_date,plat,soh,page_name,component_name,other_info,t0.user_id

但是,如果我将selectsubstr(stat\u time,1,8)中的内部查询替换为stat\u date,以选择stat\u time作为stat\u date,它将正常执行。
stat\u time的格式为yyyymmddhhmm=201702210900

select t0.stat_date,t0.plat,t0.soh,t0.page_name,t0.component_name ,count(*) as num,user_id,t0.other_info
from (
    select stat_time as stat_date,user_id,city_id,soh,dept_id,dph,plat,page_name,component_name,cookie_id,other_info
    from db.table
    where ds=20170221 and plat='abc'
)t0
group by stat_date,plat,soh,page_name,component_name,other_info,t0.user_id

那么为什么substr会导致性能下降呢?

编辑:
我将mapred-site.xml中的mapred.child.java.opts和hadoop-env.sh中的hadoop\u heapsize更改为4g。它成功了。
我想保存或计算所有的substr都会导致大量的堆。
如果有人知道为什么使用普通字段值比substr占用的内存少,请留下评论/答案。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题