hadoop - Hive Tez reducer 运行速度超慢

标签 hadoop hive query-optimization hiveql apache-tez

我加入了多个表,总行数约为 250 亿行。最重要的是,我正在做聚合。下面是我的配置单元设置,我用它来生成最终输出。我不太确定如何调整查询并使其运行得更快。目前,我正在反复试验,看看是否能产生一些结果,但似乎没有用。Mappers 运行得更快,但 reducers 需要很长时间才能完成。谁能分享您对此的看法?谢谢。

    SET hive.execution.engine=tez;
    SET hive.exec.dynamic.partition.mode=nonstrict;
    SET hive.qubole.cleanup.partial.data.on.failure=true;
    SET hive.tez.container.size=8192;
    SET tez.task.resource.memory.mb=8192;
    SET tez.task.resource.cpu.vcores=2;
    SET hive.mapred.mode=nonstrict;
    SET hive.qubole.dynpart.use.prefix=true;
    SET hive.vectorized.execution.enabled=true;
    SET hive.vectorized.execution.reduce.enabled =true;
    SET hive.cbo.enable=true;
    SET hive.compute.query.using.stats=true;
    SET hive.stats.fetch.column.stats=true;
    SET hive.stats.fetch.partition.stats=true;
    SET mapred.reduce.tasks = -1;
    SET hive.auto.convert.join.noconditionaltask.size=2730;
    SET hive.auto.convert.join=true;
    SET hive.auto.convert.join.noconditionaltask=true;
    SET hive.auto.convert.join.noconditionaltask.size=8053063680;
    SET hive.compute.query.using.stats=true;
    SET hive.stats.fetch.column.stats=true;
    SET hive.stats.fetch.partition.stats=true;
    SET mapreduce.job.reduce.slowstart.completedmaps=0.8;
    set hive.tez.auto.reducer.parallelism = true;
    set hive.exec.reducers.max=100;
    set hive.exec.reducers.bytes.per.reducer=1024000000;

SQL:

SELECT D.d
      ,D.b
      ,COUNT(DISTINCT A.x)  AS cnt
      ,SUM(c)               AS sum
 FROM A
LEFT JOIN
       B
ON A.a = B.b
LEFT JOIN
       C 
ON B.b = C.c
JOIN
       D
 ON A.a >= D.d
AND A.a <= D.d
GROUP BY 1,2
CLUSTER BY D.d;

最佳答案

还没有查询计划,所以也许还有其他东西,但这些设置肯定会限制 reducer 的并行度:

set hive.exec.reducers.max=100;
set hive.exec.reducers.bytes.per.reducer=1024000000;

我建议增加允许的 reducer 数量并减少每个 reducer 的字节数,这将增加 reducer 的并行度:

set hive.exec.reducers.max=5000; 
set hive.exec.reducers.bytes.per.reducer=67108864;

Hive 1.2.0+ 还提供自动重写 optimization for count(distinct) .检查此设置,默认情况下应为 true:

hive.optimize.distinct.rewrite=true;

如果查询停留在最后一个 reducer 上,那么就会有一个 skew in join keys

关于hadoop - Hive Tez reducer 运行速度超慢,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54491233/

相关文章:

hadoop - Hue 不想为用户创建主目录 - MapR

java - 从Hive中以 block 的形式获取同一Hive查询的数据

mysql查询优化

sql-server - 如何优化表仅用于快速插入?

MySQL 行数

amazon-web-services - hadoop s3a中的Amazon s3Exception错误请求和位置约束

join - 如何使用 Pig 对基数为 0,1 且主要为 1,n 的 2 个 csv 文件进行非规范化?

hadoop - 如何在 Hive 中加载分布式数据?

hive - 将数据从 Hive 表复制到 Bigquery 的推荐方法是什么

apache-spark - 如何在spark sqlContext中为数据类型为double的列计算中位数