20

For SQL connection pool, why do we need to set up a min pool size? As connections will be saved in the connection pool and reused, why do we need to keep live connections specified by the min pool size? Thanks.

Helic
  • 907
  • 1
  • 10
  • 25

2 Answers2

23

Opening and maintaining connections is expensive, so if you know that you need multiple connections (always) it's better to specify the MinPoolSize because then it's ensured that these connections are available.

Also, from MSDN:

If MinPoolSize is either not specified in the connection string or is specified as zero, the connections in the pool will be closed after a period of inactivity. However, if the specified MinPoolSize is greater than zero, the connection pool is not destroyed until the AppDomain is unloaded and the process ends. Maintenance of inactive or empty pools involves minimal system overhead.

Tim Schmelter
  • 450,073
  • 74
  • 686
  • 939
4

why do we need to keep live connections specified by the min pool size

As you may know that connection creation is resource intensive job. So, you may chose to set this to a small number such as 5 if your application needs consistent response times even after it was idle for hours. In this case the first user requests won't have to wait for those database connections to establish. You can read the details of pooling here.

Ehsan
  • 31,833
  • 6
  • 56
  • 65
  • 4
    Thanks. So, if I turn the connection pooling on, but min pool size 0, connections can reuse after a short while, but will be closed after a long period. If I set min pool size to 5, so at least 5 connections will be kept open for ever? Am I right? Thanks – Helic Oct 07 '13 at 10:09