【问题标题】:why does partitioning+bucketing taking longer than querying from normal table?为什么分区+分桶比从普通表查询花费更长的时间?
【发布时间】:2015-09-18 16:08:14
【问题描述】:

我的数据如下所示:

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 时间)

谁能解释一下,我在这里可能做错了什么?

【问题讨论】:

    标签: hadoop mapreduce hive hbase apache-pig


    【解决方案1】:

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

    查看在这两种情况下安排的映射器数量。在分区和分桶的情况下,您可能会注意到每个较小数据集的映射器数量更多。

    【讨论】:

    • 那么对于分区和分桶,初始数据加载需要时间,是吗?
    • 是的,它是为重新排列数据而执行的数据转换(带有完整副本)。
    猜你喜欢
    • 2021-02-14
    • 1970-01-01
    • 2021-08-18
    • 2017-11-02
    • 1970-01-01
    • 1970-01-01
    • 2018-11-05
    • 2018-10-30
    • 1970-01-01
    相关资源
    最近更新 更多