为什么分区+分组比从普通表查询需要更长的时间?

时间:2015-09-18 16:08:15

标签: hadoop mapreduce hive hbase apache-pig

我的数据如下:

Wban Number, YearMonthDay, Time, Hourly Precip
03011,20060301,0050,0

现在这个文件有超过100万+行。所以我创建了一个包含两个分区(在wbannumber上)和桶(在yearmonthday)的表:

create table hpd_bkt
(
YearMonthDay INT,
Time INT, 
HourlyPrecip float
)
partitioned by (wbannum int)
clustered by (yearmonthday) sorted by (yearmonthday) into 31 buckets
row format delimited 
fields terminated by ','
lines terminated by '\n'
stored as textfile;

然后:

insert overwrite table hpd_bkt partition(wbannum)
Select  yearmonthday,time,hourlyprecip,wbannum from hpd;

现在我使用以下查询来获取不同的wbannumbers(用于分区+存储桶表):

select count(distinct wbannum) from hpd_bkt;

总共需要103秒才能处理(13秒CPU时间)

但是从普通数据表中查询时,总共需要21秒(8秒CPU时间)

任何人都能解释一下,我在这里做错了什么?

1 个答案:

答案 0 :(得分:0)

一种可能性是使用分区进行分区可能会导致许多较小的文件。理想情况下,您的文件大小应至少为块大小,以获得良好的性能。

观察两种情况下计划的映射器数量。在分区&对于较小的数据集,您可能会注意到更多的映射器。

相关问题