【问题标题】:Hive - How to efficiently Create Table As Select?Hive - 如何有效地创建表作为选择?
【发布时间】:2016-09-01 13:29:38
【问题描述】:

我有一个配置单元表htable,它在foobar 上进行了分区。我想为实验创建这个表的一小部分,所以我认为要做的事情是

create table new_table like htable;

insert into new_table partition (foo, bar) select * from htable
where rand() < 0.01 and foo in (a,b)

这需要很长时间,但最终以java.lang.OutOfMemoryError: Java heap space 失败。有没有更好的办法?

【问题讨论】:

    标签: sql hive out-of-memory query-optimization hiveql


    【解决方案1】:

    添加distribute by foo, bar:

        insert into new_table partition (foo, bar) select * from htable
         where rand() < 0.01 and foo in (a,b) 
        distribute by foo, bar
    

    这将减少内存消耗。

    【讨论】:

    • 这实际上完成了。谢谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-12-03
    • 2017-06-06
    • 1970-01-01
    • 1970-01-01
    • 2011-08-07
    • 1970-01-01
    相关资源
    最近更新 更多