Closed MargaretKrutikova closed 2 years ago
Npgsql and the other ADO.NET providers implement connection pooling so that connections with the same connection string are kept in a pool after you close them to prevent performance degradation. So no optimization should be necessary.
Yes, we investigated this deeper today and came to the same conclusion. Thanks for the response!
QueryContext
disposes database connection here when it is disposed, and it also takes care of transactions. Do we really want to dispose the connection once a transaction disposes? Our understanding ofQueryContext
is that it is a light-weight object that is created for every db operation, with transaction in case it is necessary, but it will be quite expensive to create a new db connection for each query context. Does it make sense to either remove connection disposal or maybe even require the connection to be send in each method instead? That way it is the consumer's responsibility to make sure the connection is properly disposed.