2015-09-18 145 views
0

我的數據看起來像以下:爲什麼分區+分段花費的時間比從普通表查詢花費的時間更長?

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秒(CPU時間爲8秒)

任何人都可以解釋,我可能在這裏做錯了什麼?

回答

0

一種可能性是使用分區進行分區可能導致大量較小的文件。理想情況下,您的文件大小應至少爲塊大小以獲得良好的性能。

觀察兩種情況下排定的映射器的數量。在對分區情況進行分區時,您可能會注意到每個較小數據集的映射程序數量較多。

+0

因此,對於分區和分區,初始數據加載需要時間,是嗎? –

+0

是的它的數據轉換(完整複製)執行重新安排數據。 –