Query runs fast, but runs slow in stored procedure

后端 未结 6 406
遥遥无期
遥遥无期 2020-12-04 16:52

I am doing some tests using the SQL 2005 profiler.

I have a stored procedure which simply runs one SQL query.

When I run the stored procedure, it takes a lon

6条回答
  •  猫巷女王i
    2020-12-04 17:13

    The issue of why a batch takes forever to run inside a SQL stored procedure yet runs instantaneously in SSMS has to do with SQL parameter sniffing, especially with datetime parameters.

    There are several excellent articles on parameter sniffing out there.

    Here's one of them ( I didn't write it, just passing it on).

    http://www.sommarskog.se/query-plan-mysteries.html

提交回复
热议问题