标签:hive
[Author]: kwu
使用子查询优化hive的SQL
在1亿条数据中执行一条简单的语句,查询只访问主站一次的用户数量:
select count(*) as cnt from tracklog group by cookieid having cnt=1 ;查询反应很慢,半小时都未出结果
select count(t.cookieid) from (select count(cookieid) as cnt,cookieid from tracklog group by cookieid having cnt=1 ) t;
执行效率明显提高,同时Spark-SQL也完美支持这种子查询
标签:hive
原文地址:http://blog.csdn.net/bdchome/article/details/45665743