花费太多时间来执行存储过程 [英] Taking too much time to execute stored procedure

查看:107
本文介绍了花费太多时间来执行存储过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我有一个存储过程,当我使用declare和set参数运行它时它会在38秒内给出结果但如果我使用(exec sp_procedurename parametervalue1,parametervalue2)语句则需要5分钟执行。







请帮帮我怎样才能解决这个问题。?

Hi I have a stored procedure and when i run it by using declare and set parameter it gives me result with in 38 seconds but if i use (exec sp_procedurename parametervalue1,parametervalue2) statement then it takes 5 minutes to execute.



Please help me how could i resolve this problem.?

推荐答案

如果您运行与存储过程完全相同的SQL并且时间不同,则您的存储过程可能依赖于过时的元数据。尝试更新统计信息或重新编译存储过程。



请参阅此链接:http://social.msdn.microsoft的.com /论坛/ SQLSERVER / EN-US / ba4b81cd-211C-4716-ba84-19ef2c8290e4 /存储过程,慢于运行查询功能于sqlserver的管理工作室[^] < br $> b $ b

http:/ /stackoverflow.com/questions/13750829/stored-procedure-runs-much-slower-than-query [ ^ ]
If you're running the same exact SQL as the stored procedure and the times are that different, your stored procedure is probably relying on metadata that is out of date. Try updating statistics or recompiling the stored procedure.

Please see this link: http://social.msdn.microsoft.com/Forums/sqlserver/en-US/ba4b81cd-211c-4716-ba84-19ef2c8290e4/stored-procedure-slower-than-running-query-in-sql-server-management-studio[^]

http://stackoverflow.com/questions/13750829/stored-procedure-runs-much-slower-than-query[^]


谢谢



现在我在更短的时间内得到结果。
Thanks

Now i am getting the result in less time.


这篇关于花费太多时间来执行存储过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆