【原创】大叔经验分享(33)hive select count为0

hive建表后直接将数据文件拷贝到table目录下,select * 可以查到数据,但是select count(1) 一直返回0,这个是因为hive中有个配置

hive.stats.autogather=true

Enables automated gathering of table-level statistics for newly created tables and table partitions, such as tables created with the INSERT OVERWRITE statement. The parameter does not produce column-level statistics, such as those generated by CBO. If disabled, administrators must manually generate the table-level statistics for newly generated tables and table partitions with the ANALYZE TABLE statement.

可以通过describe来查看table的统计信息

DESCRIBE EXTENDED $table_name;

有个配置控制是否使用talbe的统计信息

hive.compute.query.using.stats=true

Instructs Hive to use statistics when generating query plans

很多人建议的处理方法是

set hive.compute.query.using.stats=false;

正解应该是

ANALYZE TABLE $table_name COMPUTE STATISTICS;

ANALYZE TABLE $table_name partition(p=$1) COMPUTE STATISTICS;

即重新计算统计信息


参考:https://docs.hortonworks.com/HDPDocuments/HDP2/HDP-2.6.5/bk_hive-performance-tuning/content/ch_cost-based-optimizer.html

转载于:https://www.cnblogs.com/barneywill/p/10431323.html

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值