Does anyone have any performance metrics of ADO.NET connection pooling vs. the create-and-destroy method?
I'm using WCF, SQL Server and ADO.NET. I'm looking at two implementation options for the data access layer.
- The Enterprise Library that uses connec开发者_如何学JAVAtion pooling
- 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?
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.
精彩评论