hive job sql 优化 之CPU占有过高
发表于:2025-12-03 作者:千家信息网编辑
千家信息网最后更新 2025年12月03日,最近有个SQL运行时长超过两个小时,所以准备优化下首先查看hive sql 产生job的counter数据发现总的CPU time spent 过高估计100.4319973小时每个map的CPU t
千家信息网最后更新 2025年12月03日hive job sql 优化 之CPU占有过高
最近有个SQL运行时长超过两个小时,所以准备优化下
首先查看hive sql 产生job的counter数据发现
总的CPU time spent 过高估计100.4319973小时

每个map的CPU time spent
排第一的耗了2.0540889小时
建议设置如下参数:
1、mapreduce.input.fileinputformat.split.maxsize现在是256000000 往下调增加map数(此招立竿见影,我设为32000000产生了500+的map,最后任务由原先的2小时提速到47分钟就完成)
2、优化UDF getPageID getSiteId getPageValue (这几个方法用了很多正则表达式的文本匹配)
2.1 正则表达式处理优化可以参考
http://www.fasterj.com/articles/regex1.shtml
http://www.fasterj.com/articles/regex2.shtml
2.2 UDF优化见
1 Also you should use class level privatete members to save on object incantation and garbage collection.2 You also get benefits by matching the args with what you would normally expect from upstream. Hive converts text to string when needed, but if the data normally coming into the method is text you could try and match the argument and see if it is any faster. Exapmle: 优化前: >>>> import org.apache.hadoop.hive.ql.exec.UDF;>>>> import java.net.URLDecoder;>>>>>>>> public final class urldecode extends UDF {>>>>>>>> public String evaluate(final String s) {>>>> if (s == null) { return null; }>>>> return getString(s);>>>> }>>>>>>>> public static String getString(String s) {>>>> String a;>>>> try {>>>> a = URLDecoder.decode(s);>>>> } catch ( Exception e) {>>>> a = "";>>>> }>>>> return a;>>>> }>>>>>>>> public static void main(String args[]) {>>>> String t = "%E5%A4%AA%E5%8E%9F-%E4%B8%89%E4%BA%9A";>>>> System.out.println( getString(t) );>>>> }>>>> }优化后:
import java.net.URLDecoder;public final class urldecode extends UDF { private Text t = new Text(); public Text evaluate(Text s) { if (s == null) { return null; } try { t.set( URLDecoder.decode( s.toString(), "UTF-8" )); return t; } catch ( Exception e) { return null; } } //public static void main(String args[]) { //String t = "%E5%A4%AA%E5%8E%9F-%E4%B8%89%E4%BA%9A"; //System.out.println( getString(t) ); //}}3 继承实现GenericUDF
3、如果是Hive 0.14 + 可以开启hive.cache.expr.evaluation UDF Cache功能
小时
正则
表达式
立竿见影
两个
任务
功能
参数
建议
数据
文本
方法
时长
UTF-8
准备
参考
处理
提速
运行
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
sql数据库书籍哪个比较好
旅游网站用到的服务器技术
华为服务器没有响应
中国的服务器在美国吗
美国入侵网络安全事件
淄博专业软件开发
同方威视软件开发薪资
湖南衡阳软件开发学校
盐城网络技术开发
网络技术支持3000字报告
做软件开发白天很忙吗
wtl 数据库
港股网络安全股票有哪些
义乌市舍予网络技术服务部
sql如何对比数据库
数据库主键代码
国家网络安全无人驾驶公交
网络安全法歌谣30字
网络安全为何涨停
虚拟服务器 硬件配置
网络安全竞赛宣传大纲
手机如何打开服务器
电脑有地址连不上服务器
把类图写成数据库设计
数据库有左连接为什么还要右连接
软件开发刚入职会干什么
出国打工 软件开发
服务器集群管理技巧
软件开发FPA表
英雄联盟控数据库