title: SQL adding Order By clause causes the query to run significantly faster. Explanation needed
body: <p>So i have this query:</p>
  <pre><code>SELECT * 
  FROM ViewTechnicianStatus
  WHERE NotificationClass = 2 
      AND MachineID IN (SELECT ID FROM MachinesTable WHERE DepartmentID = 1 AND IsMachineActive &lt;&gt; 0)
  --ORDER BY ResponseDate DESC
  </code></pre>
  <p>The view is huge and complex with a lot of joins and subqueries. When i run this query it takes forever to finish, however if i add the ORDER BY it finishes instantly and returns 20 rows as intended. I don't understand how adding the ORDER BY could have such a huge positive impact on the performance. Would love if somebody could explain to me the phenomenon.</p>
  <p><strong>EDIT</strong>:
  Here is the rundown with <code>SET STATISTICS TIME, IO ON;</code> flags on. Sorry for the hidden table names but i don't think i can expose those.</p>
  <p>Without ORDER BY
  <a href="https://i.stack.imgur.com/ybPrE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ybPrE.png" alt="Without ORDER BY" /></a></p>
  <p>With Order BY
  <a href="https://i.stack.imgur.com/AryTr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/AryTr.png" alt="enter image description here" /></a></p>