0

On a powerful machine the SQL Server query is running too slowly.

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.

How can I speed-up the query (machine resources are enough)?

Thanks in advance.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Alexander
  • 169
  • 1
  • 1
  • 9
  • 2
    **SHOW US** the query! And the execution plan, please. Thanks. Also: what do your tables look like (columns + their datatypes) and how are they related (foreign keys). How many rows do these tables have?? What indexes are in place?? – marc_s Oct 11 '14 at 12:41
  • 1
    Thanks for answer. Unfortunately, for reasons of confidentiality I cannot post the query. Overall, it's a trivial left join query between 3 tables (every table contains about 1 millions rows) and in the select list there are SUM calculations. In all indexes the JOIN and WHERe columns are specified. I'd just like to know the general ways to avoid the spooling or improving that. – Alexander Oct 11 '14 at 13:23
  • 1
    There is no general way to avoid spools that I know of. You have to figure out in your specific case why it is there and what to do about it. The reason it is there is because SQL Server thinks your query is faster using a spool. There is an undocumented way to test this by turning of the optimization that adds the spool. `DBCC RULEOFF ('BuildSpool');`. Don't do this in production and remember to turn it on when you are done. `DBCC RULEON ('BuildSpool');` – Mikael Eriksson Oct 11 '14 at 17:06

0 Answers0