Search code examples
c#postgresqlnpgsql

What is the determinant for Npgsql (C#) to select a connection pool?


We are running out of connections and I can't tell if we have a bunch of 1 connection pools, if pooling is not running, or if the connection pool is set to an unreasonably high number.

How does Npgsql determine when to pull a connection from a pool?

I'm new to this project, and this code was written by the ancients who have long-since ascended:

var conbuild = new NpgsqlConnectionStringBuilder(connectionString);
conbuild.ApplicationName += string.Format(":Framework[{0}:{1}]{2}", Environment.MachineName, 
Environment.CurrentManagedThreadId,_configurationHandler.Purpose);
connection = new NpgsqlConnection(conbuild.ConnectionString);

I'm thinking I'm getting a ton of 1 connection pools.

Can anyone corroborate my hypothesis?


Solution

  • Yes, each connection string gets its own connection pool (barring some very specific exceptions).