title: Hive query takes longer than expected
body: <p>We are working on a collection of hive queries for our business users and noticed that this specific query takes a lot of time:</p>
  
  <pre><code>SELECT t.country, t.site, t.year, a.name, COUNT(t.*)
  from 
  (SELECT DISTINCT country, site, year, month FROM signals) t, 
  (SELECT DISTINCT site, country, name from master_data) a 
  WHERE t.site = a.site and t.country = a.country 
  GROUP BY t.country, t.site, t.year, a.name;
  </code></pre>
  
  <p>Each subselect by itself takes about 25 seconds.
  The query without grabbing the name takes 2 minutes, but as soon as 
  the join comes in time is exploding.</p>
  
  <p>Do you have an idea why the execution time increases that rapidly? </p>
  
  <p>P.S. <code>t</code> returns 90 entries and <code>a</code> returns 263</p>