【发布时间】:2017-09-18 17:55:16
【问题描述】:
我原来的查询 -
CREATE TABLE admin.FctPrfitAmt_rpt AS
SELECT rcn.* FROM
(SELECT t1.* FROM (SELECT * FROM admin.FctPrfitAmt t2 WHERE t2.scenario_id NOT IN(SELECT DISTINCT t3.scenario_id FROM admin.FctPrfitAmt_incr t3)
UNION ALL
SELECT * FROM admin.FctPrfitAmt_incr) t1) rcn;
问题是目前这个查询需要很多时间,因为涉及的记录数量很多。
有没有办法调整这个查询?
我尝试了这种方法,但它不起作用 -
CREATE TABLE admin.FctPrfitAmt_rpt AS
SELECT * FROM admin.FctPrfitAmt t2
WHERE t2.scenario_id NOT exists (SELECT 1 from admin.FctPrfitAmt_incr t3 where t2.scenario_id = t3.scenario_id)
UNION ALL
SELECT * FROM admin.FctPrfitAmt_incr
错误 - 我的 Hive 版本不支持“不存在”,所以对于我的方法,我收到以下错误:
编译语句时出错:FAILED: ParseException line 3:25 cannot identify input near 'NOT' 'exists' '(' in expression specification
【问题讨论】:
-
(1)
scenario_id在两个表中都是唯一的吗? (2) 表的大小(行/字节)是多少? -
是,但查询失败;有什么办法可以让“不存在”工作?
-
嗨,你能回答我第一条评论中的两个问题吗?
-
对不起,我错过了。 #-> hdfs dfs -du -h -s /user/admin/FctPrfitAmt 30.7 G 61.3 G /user/admin/FctPrfitAmt [root@itsusraedld05:/root]# #-> hdfs dfs -du -h -s /user/ admin/FctPrfitAmt_incr 2.2 G 4.3 G /user/admin/FctPrfitAmt_incr 方案 id 在两个表中都不是唯一的
-
您的数据可能存在偏差。请显示以下查询的结果:
select scenario_id,pa,pfa,pa*pfa as product from ( select scenario_id ,count(case when tab = 1 then 1 end) as pa ,count(case when tab = 2 then 1 end) as pfa from ( select 1 as tab,scenario_id from admin.FctPrfitAmt as pa union all select 2 as tab,scenario_id from admin.FctPrfitAmt_incr as pfa ) t group by scenario_id ) t order by product desc limit 10 ;
标签: performance hadoop hive bigdata