title: Why is UNION faster than an OR statement
body: <p>I have a problem where I need to find records that either have a measurement that matches a value, <strong>or</strong> do not have that measurement at all. I solved that problem with three or four different approaches, using <code>JOIN</code>s, using <code>NOT IN</code> and using <code>NOT EXISTS</code>. However, the query ended up being extremely slow every time. I then tried splitting the query in two, and they both run very fast (three seconds). But combining the queries using <code>OR</code> takes more than five minutes.</p>
  
  <p>Reading on SO I tried <code>UNION</code>, which is very fast, but very inconvenient for the script I am using. </p>
  
  <p>So two questions:</p>
  
  <ol>
  <li>Why is <code>UNION</code> so much faster? (Or why is <code>OR</code> so slow)?</li>
  <li>Is there any way I can force <code>MSSQL</code> to use a different approach for the  <code>OR</code> statement that is fast?</li>
  </ol>