Impala分区查询运行缓慢

时间:2017-02-07 15:42:59

标签: database hadoop hive cloudera impala

因此,我尝试使用包含1500条不同记录的“文件”列对我的Impala表进行分区。这意味着1500个分区。我首先运行这样的查询来返回分区查询:

SELECT DISTINCT
  concat('insert into partitioned_table partition (year=',
    cast(year as string),', month=',cast(month as string),
    ') select c1, c2, c3 from raw_data where year=',
    cast(year as string),' and month=',cast(month as string),';') AS command
  FROM raw_data;

然后我有1500个查询要运行。

Here is the screenshot

现在有一个问题:由于每个查询可能需要3分钟才能完成。 1500次查询可能需要几天时间。这是一段很长的时间。为了节省时间,我已经做了一些调整:使用COMPUTE STATS获取静态,将表转换为Parquet。我的问题是,有没有办法可以加快这个过程?就像Hive可以做的最大执行者一样?

1 个答案:

答案 0 :(得分:2)

您可以使用dynamic partitioning

fill

演示

insert into partitioned_table partition (year,month) 
select c1, c2, c3, year, month
from raw_data
create table t (i int) partitioned by (year string,month string);

insert into t partition (year,month) values
    ( 1,'2015','02')
   ,( 2,'2017','01')
   ,( 3,'2016','02')
   ,( 4,'2013','09')
   ,( 5,'2015','07')
   ,( 6,'2012','03')
   ,( 7,'2012','12')
   ,( 8,'2017','12')
   ,( 9,'2015','11')
   ,(10,'2015','02') 
;   

select * from t order by year,month,i;
+----+------+-------+
| i  | year | month |
+----+------+-------+
| 6  | 2012 | 03    |
| 7  | 2012 | 12    |
| 4  | 2013 | 09    |
| 1  | 2015 | 02    |
| 10 | 2015 | 02    |
| 5  | 2015 | 07    |
| 9  | 2015 | 11    |
| 3  | 2016 | 02    |
| 2  | 2017 | 01    |
| 8  | 2017 | 12    |
+----+------+-------+
相关问题