Hive 作业读取数据并插入分区排序分桶表的时间太长

问题描述

我们有一个作业,它从一个包含大约 30 亿行的 hive 表中读取数据,并插入到一个已排序的分桶表中。

源表和目标表中的文件均采用镶木地板格式。

这项工作需要很长时间才能完成。我们不得不在 3 天后停止工作。

我们最近迁移到了一个新集群。较旧的集群是 5.12,最新的集群是 6.3.1。 该作业过去在 5.12 集群中运行良好并在 6 小时内完成。但是,在新集群中花费的时间太长。

我们尝试了以下方法解决此问题,但没有任何结果:-

  1. 移除了减速器的盖子。删除了 set hive.exec.reducers.max=200;
  2. 设置 mapreduce.job.running.reduce.limit=100;
  3. 在源头合并文件以确保我们不会读取小文件。源表中的文件大小增加到每个 1G。
  4. 减少数量。源表中的行数以减少数据映射器正在读取的数据。
  5. 将最大拆分大小减少到 64MB 以增加数量。的映射器。
  6. 插入新表格。
  7. 插入未排序或分桶的新表。

我们试图运行的查询:-

set hive.exec.dynamic.partition=true;
set hive.exec.max.dynamic.partitions=100000;
set hive.exec.max.dynamic.partitions.pernode=100000;
set hive.exec.dynamic.partition.mode=nonstrict;
set hive.exec.max.created.files=900000;

set mapreduce.input.fileinputformat.split.maxsize=64000000;
set mapreduce.job.running.reduce.limit=100;

set hive.enforce.bucketing=true;
set hive.enforce.sorting=true;

INSERT OVERWRITE TABLE dbname.features_archive_new PARTITION (feature,ingestmonth)
Select mpn,mfr,partnum,source,ingestdate,max(value) as value,feature,ingestmonth
from dbname.features_archive_tmp
where feature = 'price'
and ingestmonth like '20%'
group by mpn,ingestmonth;

解决方法

我们发现 Cloudera 6.3 中的 hive 2.x 版正在使用矢量化,而旧 Cloudera 5.12 中的 hive 1.x 未使用它。

因此设置以下属性为我们解决了问题。我对此没有任何解释。矢量化应该加快查询速度,而不是让它变慢。

hive.vectorized.execution.enabled=false;