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

前端 未结 11 1298
失恋的感觉
失恋的感觉 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:05

    I would guess it could possible be down to caching. If you run the stored procedure twice is it faster the second time?

    To investigate further you could run them both from management studio the stored procedure and the query version with the show query plan option turned on in management studio, then compare what area is taking longer in the stored procedure then when run as a query.

    Alternativly you could post the stored procedure here for people to suggest optimizations.

提交回复
热议问题