Npgsql.FSharp
Npgsql.FSharp copied to clipboard
question: is it bad idea to keep connection open?
ATM our DB has restricted mount of connections (20) but is going to be used intense by many users. |> Sql.connect
seems to create new connection each time it;s used so we're risking to reach the limit at the moment we release the feature. Alternatively, we can open a connection by let connection = new NpgsqlConnection(getConnectionString)
and keep it open, but is it a good idea? What will happen if users use the same connection?
No need to worry. Npgsql uses connection pools under the hood. It's enabled by default. https://www.npgsql.org/doc/connection-string-parameters.html#pooling
No need to worry. Npgsql uses connection pools under the hood. It's enabled by default. https://www.npgsql.org/doc/connection-string-parameters.html#pooling
So, if there's a restriction on DB end we should set maximum pool size, is that correct?