views:

72

answers:

1

I'm using WCF, SQL Server and ADO.NET. I'm looking at two implementation options for the data access layer.

  1. The Enterprise Library that uses connection pooling
  2. A custom solution that does not use connection pooling. Every time the database is accessed a connection is created, used and then destroyed.

Option 2 looks like this:

using (var connection = new SqlConnection(...)){...}

What is the difference in performance between these two? When does it make sense to pool connections?

+5  A: 

Option 2 will have connection pooling as well unless you explicitly turn it off in the connection string. Pooling is provided at the provider level and marking a connection "closed" just tells the pool to reuse it. So there should be almost 0 perf difference between your 2 options.

Always.

DancesWithBamboo
Connection pooling can be turned off in the connection string and in that case option 2 will not use pooling and will create a new socket connection for every new database connection.
sipwiz
Good point. Is there a case where you would ever want to do that?
DancesWithBamboo