ADO - ADO.NET Connection Pooling

Connection pooling is a built-in ADO.NET feature that reuses existing database connections instead of creating and destroying a new physical connection every time your code opens one.


Why it exists (core problem)

Opening a database connection is slow and expensive (network + authentication + server resources).
If every request opens a new connection, performance collapses.

Pooling fixes this by keeping connections alive and reusable.


How it actually works (step-by-step)

  1. Your code calls:

     
    SqlConnection conn = new SqlConnection(connectionString); conn.Open();
  2. ADO.NET checks the connection pool for that exact connection string.

  3. If a free connection exists → reuse it (no new DB connection).

  4. If none exist → create a new physical connection and add it to the pool.

  5. When you call:

     
    conn.Close();

    the connection is NOT closed.

    • It is returned to the pool for reuse.