title: Why is count(distinct) slower than group by in Hive?
body: <p>On Hive, I believe count(distinct) will be more likely than group-by to result in an unbalanced workload to reducers and end up with one sad reducer grinding away. Example query below.</p>
  
  <p>Why?</p>
  
  <p>Example query:</p>
  
  <pre><code>select count(distinct user)
  from some_table
  </code></pre>
  
  <p>Version with group-by (proposed as faster):</p>
  
  <pre><code>select count(*) from
  (select user
   from some_table
   group by user) q
  </code></pre>
  
  <p>Note: slide 26 of <a href="http://www.slideshare.net/oom65/optimize-hivequeriespptx" rel="noreferrer">this presentation</a> describes the problem.</p>