title: Why an union is faster than a group by
body: <p>Well, maybe I am too old school and I would like to understand the following.</p>
  
  <p>query 1.</p>
  
  <pre><code>select count(*), gender from customer
  group by gender
  </code></pre>
  
  <p>query 2.</p>
  
  <pre><code>select count(*), 'M' from customer
  where gender ='M'
  union
  select count(*), 'F' from customer
  where gender ='F'
  </code></pre>
  
  <p>the 1st query is simpler, but for some reason in the profiler,when I execute both at the same time, it says that query 2 uses 39% of the time, and query 1, 61%.</p>
  
  <p>I would like to understand the reason, maybe I have to rewrite all my queries. </p>