Reputation: 3563
I’m using the Npgsql driver in a .NET application to connect to a CockroachDB instance. I set Minimum Pool Size=100
in the connection string, expecting the pool to pre-open 100 connections at application startup.
However, connections are only opened when database operations occur. Is there a way to force the pool to open and maintain the minimum number of connections immediately, regardless of DB activity?
Environment:
.Net Framework 4.8.1
8.6
24.3.0
Upvotes: 0
Views: 34
Reputation: 16722
I’m using the Npgsql driver in a .NET application to connect to a CockroachDB instance. I set Minimum Pool Size=100 in the connection string, expecting the pool to pre-open 100 connections at application startup.
What's your expectation here exactly with regards to "application startup"? Opening a connection is a heavy, asynchronous operation, when exactly are you expecting that to occur?
Because there's no natural, implicit place for such a startup operation, as @UtlaMincykun wrote you can simply do a quick for loop and open the connections yourself wherever is suitable for you.
Upvotes: 0
Reputation: 1
The behavior you're observing with the Npgsql driver is expected. The Minimum Pool Size setting in the connection string specifies the minimum number of connections that the pool will maintain, but it does not force the pool to open these connections immediately at application startup. See more in https://www.cockroachlabs.com/docs/stable/connection-pooling.
To achieve the behavior you want, you might have to manually open connections up to the minimum pool size at application startup.
Upvotes: 0