SP taking 15 minutes, but the same query when executed returns results in 1-2 minutes

前端 未结 11 1145
失恋的感觉
失恋的感觉 2021-02-01 03:22

So basically I have this relatively long stored procedure. The basic execution flow is that it SELECTS INTO some data into temp tables declared with he #

11条回答
  •  暖寄归人
    2021-02-01 04:07

    Try recompiling the sproc to ditch any stored query plan

    exec sp_recompile 'YourSproc'
    

    Then run your sproc taking care to use sensible paramters.

    Also compare the actual execution plans between the two methods of executing the query.

    It might also be worth recomputing any statistics.

提交回复
热议问题