SNIReadSync executing between 120-500 ms for a sim

2019-07-23 09:50发布

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!

2条回答
劳资没心,怎么记你
2楼-- · 2019-07-23 10:33

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.

查看更多
趁早两清
3楼-- · 2019-07-23 10:34

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.

查看更多
登录 后发表回答