对于简单查询,SNIReadSync 的执行时间为 120-500 毫秒。我要寻找什么?
我正在对 SQL Server 2005 执行一个简单的查询:
protected static void InitConnection(IDbCommand cmd) {
cmd.CommandText = "set transaction isolation level read uncommitted ";
cmd.ExecuteNonQuery();
}
每当我使用 dotTrace 3.1 进行分析时,它都会声称 SNIReadSync 方法需要 100 - 500 毫秒。
为了缩短这个时间,我需要寻找什么样的东西?
谢谢!
I am executing a simple query against SQL Server 2005:
protected static void InitConnection(IDbCommand cmd) {
cmd.CommandText = "set transaction isolation level read uncommitted ";
cmd.ExecuteNonQuery();
}
Whenever I profile with dotTrace 3.1, it claims that SNIReadSync method is taking between 100 - 500 ms.
What sort of things do I need to be looking for in order to get this time down?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我没有测试过,但想知道如果您使用带有 IsolationLevel.ReadUncomfilled 选项的 TransactionScope 是否会遇到同样的问题。您必须封装完整的调用集,这样就不需要此语句了。我意识到这个说法不是你的基本关切,而是一般性的。
您可以做的另一件事是创建 DBConnectionScope 类(或利用可信供应商的类)并减少打开的连接总数。
I have not tested, but would wonder if you have the same issue if you used a TransactionScope with the options of IsolationLevel.ReadUncommitted. You would have to encapsulate your complete set of calls and that should negate the need for this statement. I realize that this statement is not your basic concern, but in general.
Another thing that you can do is to create a DBConnectionScope class (or leverage a trusted vendor's class) and cut down on the total number of connections that are opened.
确保启用连接池,否则每次打开连接时您都会受到重大损失。在连接字符串中设置 Pooling=True,或删除对池的任何引用。我相信默认已启用。
这为我解决了这个问题。希望它对您和其他人有所帮助。
Ensure that connection pooling is enabled or you will receive a significant penalty each time a connection is opened. In your connection string set Pooling=True, or remove any reference to pooling. I believe the default is enabled.
This fixed the issue for me. Hope it helps for you and others.