title: UNION vs CROSS APPLY performance
body: <p>I asked a <a href="https://stackoverflow.com/questions/24899070/get-family-members">question</a> yesterday and one answer is making me think about performance.</p>
  
  <p>Resuming, I have a table which represents a parenthood relationship:</p>
  
  <pre><code>PARENT | CHILD
     1   |   2
     1   |   3
     2   |   4
  </code></pre>
  
  <p>Both fields are numbers that represents one person.</p>
  
  <p>I was needing to take the group of distinct persons of this table, not importing if child or parent. The query that came first in my mind was the most obvious one:</p>
  
  <pre><code> SELECT DISTINCT PARENT FROM TABLE1
   UNION SELECT DISTINCT CHILD FROM TABLE1
  </code></pre>
  
  <p>But the one bellow seems to perform much better (in my real data at least):</p>
  
  <pre><code> SELECT DISTINCT CASE WHEN N.n=1 THEN parent ELSE child END 
   FROM TABLE1
   CROSS APPLY(SELECT 1 UNION SELECT 2)N(n)
  </code></pre>
  
  <p><strong>My questions are:</strong> </p>
  
  <ul>
  <li>Is this second query really faster than the first I built always?</li>
  <li>Just for curious, is there a faster way to do it?</li>
  </ul>