第十章 Hive调优 【count(distinct)】
1. count(distinct) 调优
说明 :
count(distinct) 会启用一个 ReduceTask 来完成,当数据量巨大时,单个ReduceTask 无法完成
在对大量数据做 count(distinct)操作时, 可以使用 group by 后,再 count ,将任务拆分
示例 :
-- 1. count(distinct)
select count(distinct id) from bigtable;
-- 单个job
-- 2. order by ,count()
select count(id) from (select id from bigtable group by id) a;
-- 2个job