从子查询/联接的结果中过滤分区时,Hive Query 将进行全表扫描

问题描述

与 Query2 相比,为什么 query1 的运行时间更长。

Hive 源表详细信息

Columns - 166
Partitions columns - 2 columns (all are int datatypes)
Number of Partitions - 3211 partitions
Total Records - 19374461064
File Format - ORC

-- 查询 1

create table temp1 as 
with temp_table1 as 
(select col1 from temp_table where col1 between <start_date> and <end_date>),-- these query would get me the dates and there are derived dynamically in the script

select f1.* from sourcetable f1 join temp_table1 f2 on f1.col1=f2.col1;

-- 上面的查询运行时间更长,其中一个步骤需要大约 1300 个映射器和大约 1000 个减速器。 -- 执行时间 - ~120 分钟

-- 查询 2

--如果我在 where 子句中将 temp table1 的结果作为值传递,那么查询会在大约 10 分钟内检索结果。

select f1.* from source_table where f1.col1 in (value1,value2,value3,value3... value30);

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)