views:

251

answers:

2

We have a query that takes 2 seconds to run in Sql Server Management Studio but it takes 13 seconds to be shown on a client screen. I used dotTrace to profile my source code and noticed there is this SNIReadSync method (part of ADO.net assemblies)that takes a lot of time to do its job(9 seconds).I ran my source over server so I could omit the network effects and the result was the same.

It doesn't matter if I'm using OleDBConnection or SqlConnection.

It doesn't matter if I'm using a DataReader or a DataSet.

Connection pooling does not solve this issue(as my result shows).

I googled this issue and I couldn't find an answer to the question that what this method is actually doing and how we can improve it.

here's what I found on StakOverFlow that's not helpful either: http://stackoverflow.com/questions/1610874/snireadsync-executing-between-120-500-ms-for-a-simple-query-what-do-i-look-for

A: 

Ignoring SNIReadSync for a moment (I think this might be a red herring).

The symptoms you are describing sound like an incorrectly cached query plan.

Please update your statistics (or rebuild indexes) and see if it still occurs.

Mitch Wheat
what i can't understand is that if that's the case why it's running so fast in Management Studio?
Beatles1692
Because SSMS emits preamble that causes a recompilation to be performed. Have you done as I suggested?
Mitch Wheat
A: 

Hi,

Did you get a solution to this issue? We are having a similar issue in our product. Thanks.

Aasia