简体   繁体   English

SQL Azure间歇性变慢

[英]SQL Azure intermittently slow

I have a stored proc in an SQL Azure database. 我在SQL Azure数据库中存储了proc。 If I run this stored proc via SSMS it always takes around 1 second to run. 如果我通过SSMS运行此存储的proc,则总是需要大约1秒钟才能运行。 If I run from a web role application running on Azure with an SqlCommand object it often (not always) runs slowly and eventually times out. 如果我从运行在Azure上且带有SqlCommand对象的Web角色应用程序运行,则该应用程序经常(并非总是)运行缓慢,最终超时。 What would be the different from running via SSMS or a SqlCommand? 与通过SSMS或SqlCommand运行有什么不同?

SQL Server will choose and cache an execution plan for the stored procedure. SQL Server将为存储过程选择并缓存执行计划。 This plan may be optimized for a given set of parameters, and be a poor choice for others. 该计划可能针对给定的参数集进行了优化,而对于其他参数则是一个糟糕的选择。

You should review the execution plan it is choosing and assess whether it's adequate for your most common or most heavy queries. 您应该查看正在选择的执行计划,并评估它是否适合您最常见或最繁琐的查询。

Possible solutions include creating (or dropping) indexes as necessary, or using optimization hints. 可能的解决方案包括根据需要创建(或删除)索引,或使用优化提示。

Query optimization is more complex and subtle that it would seem at first. 查询优化比起初看起来更加复杂和微妙。 Some helpful references: 一些有用的参考:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM