hive 参数调优

hive 参数调优
2017年04月23日 13:49:43 任乌拉 阅读数 5748
Map Reduce数量相关

数据分片大小 (分片的数量决定map的数量)
计算公式: splitSize = Math.max(minSize, Math.min(maxSize, blockSize))
1
2
set mapreduce.input.fileinputformat.split.maxsize=750000000;

单个reduce处理的数据量 (影响reduce的数量)
计算公式: Max(1, Min(hive.exec.reducers.max [1099], ReducerStage estimate/hive.exec.reducers.bytes.per.reducer)) x hive.tez.max.partition.factor
1
2
set hive.exec.reducers.bytes.per.reducer=629145600;

tez将会根据vertice的输出大小动态预估调整reduce的个数
1
set hive.tez.auto.reducer.parallelism = true;
执行计划相关

hive执行引擎 mr/tez/spark
1
set hive.execution.engine=mr;

调整Join顺序,让多次Join产生的中间数据尽可能小,选择不同的Join策略
1
set hive.cbo.enable=true;

如果数据已经根据相同的key做好聚合,那么去除掉多余的map/reduce作业
1
set hive.optimize.reducededuplication=true;

如果一个简单查询只包括一个group by和order by,此处可以设置为1或2
1
set hive.optimize.reducededuplication.min.reducer=4;

Map Join优化, 不太大的表直接通过map过程做join
1
set hive.auto.convert.join=true;
set hive.auto.convert.join.noconditionaltask=true;

Map Join任务HashMap中key对应value数量
1
set hive.smbjoin.cache.rows=10000;

可以被转化为HashMap放入内存的表的大小(官方推荐853M)
1
set hive.auto.convert.join.noconditionaltask.size=894435328;

map端聚合(跟group by有关), 如果开启, Hive将会在map端做第一级的聚合, 会用更多的内存
http://dmtolpeko.com/2014/10/13/map-side-aggregation-in-hive/

开启这个参数 sum(1)会有类型转换问题
1
2
3
4
set hive.map.aggr=false;

所有map任务可以用作Hashtable的内存百分比, 如果OOM, 调小这个参数(官方默认0.5)
1
set hive.map.aggr.hash.percentmemory=0.5;

将只有SELECT, FILTER, LIMIT转化为FETCH, 减少等待时间
1
set hive.fetch.task.conversion=more;
set hive.fetch.task.conversion.threshold=1073741824;

聚合查询是否转化为FETCH
1
set hive.fetch.task.aggr=false;

如果数据按照join的key分桶,hive将简单优化inner join(官方推荐关闭)
1
set hive.optimize.bucketmapjoin= false;
set hive.optimize.bucketmapjoin.sortedmerge=false;

向量化计算
https://cwiki.apache.org/confluence/display/Hive/Vectorized+Query+Execution
如果开启, sum(if(a=1,1,0))这样的语句跑不过
1
2
3
set hive.vectorized.execution.enabled=false;
set hive.vectorized.execution.reduce.enabled=false;
set hive.vectorized.groupby.checkinterval=4096;
set hive.vectorized.groupby.flush.percent=0.1;
动态分区相关

hive0.13有个bug, 开启这个配置会对所有字段排序
1
set hive.optimize.sort.dynamic.partition=false;

以下两个参数用于开启动态分区
1
set hive.exec.dynamic.partition=true;
set hive.exec.dynamic.partition.mode=nonstrict;

小文件相关

合并小文件
1
set hive.merge.mapfiles=true;
set hive.merge.mapredfiles=true;
set hive.merge.tezfiles=true;
set hive.merge.sparkfiles=false;
set hive.merge.size.per.task=536870912;
set hive.merge.smallfiles.avgsize=536870912;
set hive.merge.orcfile.stripe.level=true;
ORC相关

https://orc.apache.org/docs/hive-config.html

如果开启将会在ORC文件中记录metadata
1
set hive.orc.splits.include.file.footer=false;

ORC写缓冲大小
1
set hive.exec.orc.default.stripe.size=67108864;
统计相关

新创建的表/分区是否自动计算统计数据
1
set hive.stats.autogather=true;
set hive.compute.query.using.stats=true;
set hive.stats.fetch.column.stats=true;
set hive.stats.fetch.partition.stats=true;

手动统计已经存在的表
1
ANALYZE TABLE COMPUTE STATISTICS;
ANALYZE TABLE COMPUTE STATISTICS for COLUMNS;
ANALYZE TABLE partition (coll=”x”) COMPUTE STATISTICS for COLUMNS;
其他

在order by limit查询中分配给存储Top K的内存为10%
1
set hive.limit.pushdown.memory.usage=0.1;

是否开启自动使用索引
1
set hive.optimize.index.filter=true;

获取文件块路径的工作线程数
1
set mapreduce.input.fileinputformat.list-status.num-threads=5;

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值