views:

25

answers:

2

My profiler trace shows that exec sp_reset_connection is being called between every sql batch or procedure call. There are reasons for it, but can I prevent it from being called, if I'm confident that it's unnecessary, to improve performance?

UPDATE: The reason I imagine this could improve performance is twofold:

  1. SQL Server doesn't need to reset the connection state. I think this would be a relatively negligible improvement.
  2. Reduced network latency because the client doesn't need to send down an exec sp_reset_connection, wait for response, then send whatever sql it really wants to execute.

The second benefit is the one I'm interested in, because in my architecture the clients are sometimes some distance from the database. If every sql batch or rpc requires a double round-trip this doubles the impact of any network latency. Eliminating such double calls could potentially improve performance.

Yes there are lots of other things I could do to improve performance like re-architect the app, and I'm a big fan of solving the root cause of problems, but in this case I just want to know if it's possible to prevent sp_reset_connection to be called. Then I can test if there is any performance improvement and properly assess the risks of not calling this.

This prompts another question: does the network communication with sp_reset_connection really occur like I outlined above? i.e. Does the client send exec sp_reset_connection, wait for a response, then send the real sql? Or does it all go in one chunk?

A: 

Just keep the connection open instead of returning it to the pool, and execute all commands on that one connection.

Lucero
This would be a good solution, but would require significant reengineering of my code so isn't currently an option.
Rory
A: 

Personally, I'd leave it.

Given what it does, I want to make sure I have no temp tables in scope or transactions left open.

To be fair, you will gain a bigger performance boost by not running profiler against your production database. And do you have any numbers or articles or recommendations about what you can gain from this please?

gbn
No, I don't have any numbers. I want to turn it off so I can measure performance and get some :) If there's a reason it would definitely not improve performance that'd be good to know too. Any thoughts?
Rory