16 July 2017

Disable connection pooling when not used frequently

By default SQL connection pooling in enabled. That make sense given the below facts.

  • Opening and closing SQL connection is costly.
  • Usually established connections to database will be used frequently in most of the apps.

If a pooled connection is not used frequently, then you need to consider to disabling the connection pooling for that connection string alone.

When SQL connections are not used for a long time, the connection will be marked INACTIVE in database server and also there is connection IDLE TIME setting, post expiry the connection will be closed in database. So pooling logic has to open a new connection to the database when you try to open a new connection to that particular connection string. This essentially defeats the purpose of the SQL Connection pooling.

So consider disabling the connection pool for a given SQL connection string, if such connection is not used frequently.

You can refer stackoverflow post on how to disable connection pooling.