SNIReadSync executing between 120-500 ms for a simple query. What do I look for?

醉酒当歌 提交于 2020-01-15 06:20:08

问题


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!


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/1610874/snireadsync-executing-between-120-500-ms-for-a-simple-query-what-do-i-look-for

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!