views:

50

answers:

2

In c#.net when you open a connection to a database, in my case it's oracle, is there a lot of overhead involved? I'm guessing there isn't because of connection pooling. So am I correct in saying that everytime I open a connection it actually grabs an open connection out of the pool and if there are no available connections in the pool it will then open a new connection?

Thanks!

+3  A: 

You are correct. There are a lot of good articles explaining ADO connection pooling. For exmaple, MSDN - SQL Server Connection Pooling (ADO.NET), which says:

Connection pooling reduces the number of times that new connections must be opened. The pooler maintains ownership of the physical connection. It manages connections by keeping alive a set of active connections for each given connection configuration. Whenever a user calls Open on a connection, the pooler looks for an available connection in the pool. If a pooled connection is available, it returns it to the caller instead of opening a new connection. When the application calls Close on the connection, the pooler returns it to the pooled set of active connections instead of closing it. Once the connection is returned to the pool, it is ready to be reused on the next Open call.

jball
Thanks for the response! I just wanted to make sure there wasn't anything else going on.
Dan H
Glad to help! .
jball
+1  A: 

The first time you open the connection there will be a lot of overhead. If you are using connection pooling and you use the exact same connection string, the next time you open the connection it should use a connection from the connection pool and be a lot quicker.

TLiebe