带limit的hivesql排序

带limit的hivesql排序
 
select requestdomain,count(1) as cnt from ods_cndns_real_log where dt = 20160707 group by requestdomain order by cnt desc limit 1000;
生成两个mr:第一步先group by;第二步将数据放到一个reduce上执行。如果group by后的数据量超大,不可取。任务可能会失败。
 
select requestdomain,count(1) as cnt from ods_cndns_real_log where dt = 20160707 group by requestdomain sort by cnt desc limit 1000;
生成三个mr:第一步先group by:第二步将每个reduce上的数据按照cnt进行倒叙排列;第三步将第二步中每个reduce上倒序前10000个数据放入下一个任务中,即一个reduce上进行排序。
 
待更新。。。
原文地址:https://www.cnblogs.com/zhzhang/p/5733115.html