Connection Pooling


Connection Pooling

Connection Pooling : Is a technical concept, with which the connection to the database is done using the already created connection objects. When we say, already created connections means, the connections which are created and kept is a store called connection pool, from where the connection objects are easily accessed.



Why connection pooling ?
The use of connection pools allows us to access database faster, the cached connection objects are taken from the pool and the program can query the database faster.

1. Connection is a heavy resource, which utilizes more time. Thus reducing the overhead of creating connections connections and destroying connections all the time.


You may try running any sample SQL query and see.
1) SET profiling = 1;
2) Your Sql query
3) SHOW PROFILE FOR QUERY 1;





Advantages

  1. Performance: Creating connection to the database is slow, with connection pooling, it becomes much faster.
  2. Diagnostics & Maintainability If you have one sub-system responsible for connecting to the database, it becomes easier to diagnose and analyze database connection usage. And your code will be easier to maintain, in other way around each functionality connects to the database by itself.

When Not to Use Pooling

Connection pooling is for reusing the connection. Where you can use the existing connection, which is available in the pool. Therefore, if you are doing any operation of modifying the connection state, then it is not good to pool the previous connection.

No comments

Thanks for viewing the blog post. Follow the blog to receive the updates.. Powered by Blogger.