Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top