title: Query is extremely slow due to Lazy Index Spool
body: <p>On a powerful machine the SQL Server query is running too slowly. </p>
  
  <p>In the execution plan I can see that most of the time spent goes to a "Lazy Index Spooling" process. In the query some aggregate functions are being used for calculation of values. </p>
  
  <p>How can I speed-up the query (machine resources are enough)?</p>
  
  <p>Thanks in advance.</p>