Re: SqlConnection.ClearPool as best practice on command timeout? by William
William
Mon Mar 10 20:58:33 CDT 2008
If you haven't already uncovered this, in a client/server application, a
more viable strategy is to leave the connection open for the lifetime of the
application. Since the pool is not shared by any other processes, there is
very little utility in the Open, query, close strategy. IMHO this can
actually hurt performance when compared to a static open connection (or
two). The open connection can be really closed as necessary, can maintain
state like #tempdb cursors, server-side cursors or other manageable state. I
discuss this more completely in my book (chapter 9--it's devoted to
connecting).
So, in ASP you have so many application instances starting, opening
connections, running queries and closing connections (dozens at a time) it
makes sense to have a common pool of reusable connections. I brought up this
very issue in the initial design discussions decades ago. I got the
impression that MS thought it was too expensive to add the method to
"really" close the connection. They felt that the flush the pool was close
enough. It does the job with a canon when it needs to be done with a pin.
Consider that the mechanism is designed to be "generic" and implementable by
all of the .NET data access data providers.
hth
--
__________________________________________________________________________
William R. Vaughn
President and Founder Beta V Corporation
Author, Mentor, Dad, Grandpa
Microsoft MVP
(425) 556-9205 (Pacific time)
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
____________________________________________________________________________________________
"Ira Gladnick" <IraGladnick@yahoo.com> wrote in message
news:15ec4d4b-17f9-4932-bdd1-7b60568c857b@s19g2000prg.googlegroups.com...
> Mr. Vaughn,
>
> Always great to get your feedback--you are an internet treasure.
>
> I am dealing with both ASP.Net and Windows client/server applications.
>
> I was wondering if I get you to elaborate a bit on why pooling might
> not be needed for client/server. Wouldn't performance be negatively
> impacted in a client/server app if pooling was disabled? Also not
> clear about middle tier--isn't ASP.net effectively middle tier?
>
> It's quite amazing that there isn't a "real close" mechanism, or at
> least the equivalent of being able to do a SET XACT_ABORT from within
> ADO.Net.
>
> A workaround that occured to me this evening was possibly to start an
> ADO.Net transaction AFTER a timeout occurs on a connection, and then
> rollback the transaction. Will try that at work first thing on
> Monday..