-1

The execution plan is mentioned below. The SQL with this execution plan is running for over 16 minutes. SQL Server keeps on changing warning about what Indexes shall be built. Please advice.

https://www.brentozar.com/pastetheplan/?id=BkyR0DIVU

1 Answers1

0
  • You can consider updating statistics for the [TM].[dbo].[Tb] table because there is a huge difference between the actual and estimated the number of rows in your execution plan.

Executionplan1

SQL Server Statistics and how to perform Update Statistics in SQL

As a second phase, you can create a selective index for your #QM table. Indexing Temp Tables

In your Hash Match and Sort operator there is a warning "Operator used tempdb to spill data during execution with spill level 1, Operator used tempdb to spill data during execution with spill level 2"

enter image description here

Correct SQL Server TempDB Spills in Query Plans Caused by Outdated Statistics

Esat Erkec
  • 1,575
  • 7
  • 13