Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
LopakaB
Starting Member
22 Posts |
Posted - 2013-02-12 : 17:35:26
|
I have a sp with many steps within it... I am baffled at the duration it takes to run for the following reason:I run the sql from beginning to end, it takes over an hour.I run the sql to a certain Insert Statement. Then run the insert statement by it self it runs in four minutes...Any help would be appreciated...Lopaka |
|
James K
Master Smack Fu Yak Hacker
3873 Posts |
Posted - 2013-02-12 : 17:47:46
|
When you run separately, they are run in two batches. It may be that when you run them together (which is in a single batch), the query plan is different.Examine the query plans in both cases and see if the combined plan is equivalent to the plans for the two-step execution stacked together. Also, in the single query plan, see which steps take long time. For those steps that consume long time, add a statement level recompilation hint. for example if it is an insert statementINSERT INTO TheTable (col1, col2) values (1,2) OPTION(RECOMPILE) |
|
|
|
|
|