蜂巢工作sql优化之CPU占有过高

  

最近有个SQL运行时长超过两个小时,所以准备优化下

首先查看蜂巢SQL产生工作的柜台数据发现

胺涑补ぷ鱏QL优化之CPU占有过高"


胺涑补ぷ鱏QL优化之CPU占有过高"


)

,,

,,,,



 1, Also 你should  use  class  level  privatete  members 用节省;提醒对象
  incantation 以及garbage 收集信息。
  
  2,你also  get  benefits  by  matching 从而args  with  what 你would 正常
  ,expect 得到上游只Hive  converts  text 用string  when 需要but  if 
  ,data  normally  coming  into 从而method  is  text 你could  try 以及match 
  ,argument 以及阅读if  it  is  any 更快。
  ,简单的:
  ,优化前:
  ,在在在在,import  org.apache.hadoop.hive.ql.exec.UDF;
  在祝辞祝辞祝辞,import  java.net.URLDecoder;
  在在在在
  在祝辞祝辞祝辞,public  final  class  urldecode  extends  UDF  {
  在在在在
  在在在在,,,,public  String 评估(final  String  s), {
  在在在在,,,,,,,,if  (s ==, null), {, return 零;,}
  在在在在,,,,,,,,return  getString(年代);
  在在在在,,,,}
  在在在在
  在在在在,,,,public  static  String  getString (String  s), {
  在在在在,,,,,,,,String ;
  在在在在,,,,,,,,try  {
  在在在在,,,,,,,,,,,,a =, URLDecoder.decode(年代);
  在在在在,,,,,,,,},catch  (, Exception  e), {
  在在在在,,,,,,,,,,,,a =,“”;
  在在在在,,,,,,,,}
  在在在在,,,,,,,,return ;
  在在在在,,,,}
  在在在在
  在在在在,,,,public  static  void 主要(String 参数[]),{
  在在在在,,,,,,,,String  t =,“% E5%A4%AA % E5 % 8 e % 9 f - % E4%B8 % 89% e4%ba % 9“;
  在在在在,,,,,,,,System.out.println (, getString (t));
  在在在在,,,,}
  祝辞祝辞祝辞祝辞,}

优化后:

 import  java.net.URLDecoder;
  
  public  final  class  urldecode  extends  UDF  {
  
  ,,,private  Text  t =, new 文本();
  
  ,,,public  Text 评估(Text  s), {
  ,,,,,,,if  (s ==, null), {, return 零,}
  ,,,,,,,try  {
  ,,,,,,,,,,,t.set (, URLDecoder.decode (, s.toString (),“utf - 8”,));
  ,,,,,,,,,,,return  t;
  ,,,,,,,},catch  (, Exception  e), {
  ,,,,,,,,,,,return 零;
  ,,,,,,,}
  ,,,}
  
  ,,,//public  static  void 主要(String 参数[]),{
  ,,,,,,,//String  t =,“% E5%A4%AA % E5 % 8 e % 9 f - % E4%B8 % 89% e4%ba % 9 a”;
  ,,,,,,,//System.out.println (, getString (t));
  ,,,//}
  }
<>前3,,继承实现GenericUDF

hive.cache.expr.evaluation , UDF缓存


蜂巢工作sql优化之CPU占有过高