title: Performance when Ordering By Computed Column
body: <p>I have to sort a fairly large set of data based on a computed column.
  Here is part of the query that does the sorting</p>
  
  <pre><code>Select Row_Number() over(Order By 
          CASE WHEN @sortBy Is Not Null AND @sortBy='relevance' 
          THEN 
              aRank*0.4+bRank*.2+cRank*.4 
          END DESC
          ,CASE WHEN @sortBy Is Not Null AND @sortBy='date' THEN CreateDate END DESC
          ) As rowNumber
  ......
  from X
  OUTER APPLY
      (
          Select SkillMatchRank...........
      ) SMR
  Where 
  SkillMatchRank&gt;0
  </code></pre>
  
  <p>Problem is this runs extremely slow.</p>
  
  <p>My Observation:<br>
  <code>SkillMatchRank &gt; 0</code> seem to be whats causing the problem.</p>
  
  <p>Any idea how we could improve this?</p>