title: cross apply with order by performance issues
body: <p>I need to pick the correct row in a table where in rare cases an extra row exists.  I do that by replacing an inner join with a cross apply. It works fine until I add order by.</p>
  
  <pre><code>  cross apply (select top 1 * from b where a.id = order_id order by C1 desc, C2 desc) t
  </code></pre>
  
  <p>The execution plans shows that the estimated number of rows to be sorted are 1 but the actual number is 900 000. I agree with the estimate, there are only one line. My guess is that the order by is executed before the where.</p>
  
  <p>I have rebuilt all index more than > 30% fragmented.
  I have tried a number of variants but none is quick enough. The other strange thing is that it is quicker on the test server</p>