Query runs fast, but runs slow in stored procedure

后端 未结 6 401
遥遥无期
遥遥无期 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条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-04 17:20

    As others have mentioned, this could be a 'parameter sniffing' problem. Try including the line:

    OPTION (RECOMPILE)
    

    at the end of your SQL query.

    There is an article here explaining what parameter sniffing is: http://blogs.technet.com/b/mdegre/archive/2012/03/19/what-is-parameter-sniffing.aspx

提交回复
热议问题