New connection pooling in .NET’s SqlClient ADO.NET provider for SQL Server
Posted: (EET/GMT+2)
Good news for anybody working with SQL Server from .NET/C# applications: Microsoft has improved the connection pooling in the ADO.NET provider (aka SqlClient). This is called "V2 pooling" and was announced just yesterday.
You can enable the V2 pooling if you have at least Microsoft.Data.SqlClient NuGet package version 7.1.0 (or later). Then, you need to explicitly opt-in to the V2 pooling, or the old "V1" pooling behavior is kept.
Here's how:
AppContext.SetSwitch("Switch.Microsoft.Data.SqlClient.UseConnectionPoolV2", true);
This is what you get:
Microsoft.Data.SqlClient's new connection pool (Pool V2) is designed to address this problem by establishing new connections concurrently, allowing the pool to respond more quickly when multiple requests need new connections at the same time.
Very nice!