开发者

Does anyone have any performance metrics of ADO.NET connection pooling vs. the create-and-destroy method?

开发者 https://www.devze.com 2022-12-09 14:10 出处:网络
I\'m using WCF, SQL Server and ADO.NET. I\'m looking at two implementation options for the data access layer.

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 connec开发者_如何学JAVAtion 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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号