Quantcast
Channel: SQL Server Database Engine forum
Viewing all articles
Browse latest Browse all 15930

Why SQL Generate this execution Plan

$
0
0

Basically we have a stored procedure runs daily with less than a minute, but occasionally this will take 15 minutes to run.  Ran a trace and it turned out one of its insertion command causes this problem. On  a normal day (< 0.5 minute ) its execution plan is :-

On a problematic day ( = around 15 minutes) its execution plan is :-

The number of records to be processed do not vary too much ( +/- 2% ) . The tables in the query are all staging tables for one-off use. I understand that I may need to create index on them, but this is a concern later on.  I can see the long duration is down to SQL tries to spool records to tempdb, but why the number of records suddenly rocket from 4,947 to 4,071,381 (the black bold data flow).  Can anyone cast light on this ? This is SQL 2005 + SP3 and Win 2003 .


Viewing all articles
Browse latest Browse all 15930

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>