title: OR in WHERE statement slowing things down dramatically
body: <p>I have the following query that finds customers related to an order. I have a legacy ID on the customer so I have to check old id (legacy) and customer id hence the or statement</p>
  
  <pre><code>SELECT  
     c.Title, 
     c.Name   
    FROM productOrder po   
        INNER JOIN Employee e ON po.BookedBy = e.ID
        CROSS APPLY (
        SELECT TOP 1 *
        FROM Customer c 
        WHERE(po.CustID = c.OldID OR po.CustID = c.CustID)    
        ) c
  
    GROUP BY     
    c.CustomerId, c.Title, c.FirstName, c.LastName
  </code></pre>
  
  <p>if I remove the <code>OR</code> statement it runs fine for both situations. There is an index on customer id and legacy.</p>