Opening a data connection

In C # .net, when you open a database connection, in my case it is an oracle, is there a lot of overhead? I assume this is not related to the connection pool. Am I rightly saying that every time I open a connection, it actually grabs an open connection from the pool, and if there are no connections available in the pool, will it open a new connection?

Thanks!

+4
source share
2 answers

You're right. There are many good articles explaining ADO pooling. For exmaple, MSDN is the SQL Server connection pool (ADO.NET) , which states:

The connection pool reduces the number of times when new connections need to be opened. The machine gun retains ownership of the physical connection. It manages connections, maintaining active connections for each given connection configuration. Whenever user calls are opened upon connection, the pool searches for an available connection in the pool. If a merged connection is available, it returns it to the caller instead of opening a new connection. When the application calls Close the connection, the pool returns it to the combined active set instead of closing it. As soon as the connection is returned to the pool, it is ready to be reused on the next Open call.

+4
source

The first time you open a connection, there will be a lot of overhead. If you use the connection pool and use the exact same connection string , the next time you open the connection, it should use the connection from the connection pool and will be much faster.

+2
source

Source: https://habr.com/ru/post/1305233/


All Articles