【发布时间】:2020-05-13 06:40:44
【问题描述】:
有人告诉我 count(distinct ) 可能会导致数据倾斜,因为只使用了一个 reducer。
我使用一个包含 50 亿条数据和 2 个查询的表进行了测试,
查询 A:
select count(distinct columnA) from tableA
查询 B:
select count(columnA) from
(select columnA from tableA group by columnA) a
实际上,查询 A 大约需要 1000-1500 秒,而查询 B 需要 500-900 秒。结果似乎在意料之中。
但是,我意识到这两个查询都使用 370 mappers 和 1 reducers 并且几乎使用了 same cumulative CPU seconds。这意味着它们没有基因差异,并且时间差异可能是由集群负载引起的。
我很困惑为什么所有人都使用一个 1 减速器,我什至尝试过mapreduce.job.reduces,但它不起作用。顺便说一句,如果他们都使用 1 个减速器,为什么人们建议不要使用 count(distinct ) 并且似乎无法避免数据倾斜?
【问题讨论】:
标签: hadoop hive mapreduce hiveql hive-configuration