繁体   English   中英

使用相似表优化 Hive 查询

[英]Optimize Hive query with similar tables

我有两个非常相似的大表,由 6 个左连接组成。 它们之间的唯一区别在于其他表连接到的第一个表,否则主选择子句和其余表相同。

一个简单的例子是:

Create table A as
Select a.attr, b.attr, ...
From 
   (Select attr
    From table a
    Where cond1, cond2, cond3) a
Left join 
   (Select attr
    From table) b
on a.whatever = b.whatever
Left join ...;


Create table B as
Select a.attr, b.attr ...
From 
   (Select attr
    From table a
    Where cond1) a
Left join 
   (Select attr
    From table) b
on a.whatever = b.whatever
Left join...;

我希望这很清楚。 唯一的区别是表 'a' 的 where 条件,其他所有内容都连接到该条件。 我怎样才能优化它,这样我就不必编写两个几乎相同的查询?

或许可以先摆脱table a的限制,得到结果,使用时添加

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM