title: My Hive query is running for long time
body: <p>I ran the below query from hive CLI.
  The query is running for long time and failing after that.</p>
  
  <pre><code>SET hive.tez.container.size=10240; 
  SET hive.tez.java.opts=-Xmx8192m; 
  set tez.runtime.io.sort.mb=4096; 
  set tez.runtime.unordered.output.buffer.size-mb=1024; 
  set hive.exec.dynamic.partition=true; 
  set hive.exec.dynamic.partition.mode=nonstrict; 
  set hive.vectorized.execution.reduce.enabled; 
  set hive.execution.engine=tez;
  
  SELECT 
  cust_his.cname AS cname  
  ,cust_his.creg AS creg 
  ,Upper(Trim(cust_his.ccountry)) AS ccountry 
  ,Upper(Trim(cust_his.cloc)) AS cloc
  FROM  
  customer_history cust_his
  WHERE  
  cust_his.cust_d BETWEEN 20160501  AND 20160531
  AND Substr(Trim(cust_his.cloc), 1, Locate('|', cust_his.cloc, 1) - 1) &lt;&gt; ''
  AND Substr(Trim(cust_his.cloc), 1, Locate('|', cust_his.cloc, 1) - 1) IS NOT NULL
  AND cast(Trim(cust_his.cmfid) as int) NOT IN ( 1,2,3 )
  AND cust_his.cmat = '8';
  </code></pre>
  
  <p>The table is partitioned on cust_d column.
  The table is having 420TB of data.</p>
  
  <p>Please help me to resolve this.</p>
  
  <p>Thanks in Advance.</p>