簡體   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