Home / Learn Secure SQL / Connection Pooling: a Brief Introduction

Connection Pooling: a Brief Introduction

Reusing database connections instead of opening a new one per request.

The short versionReusing database connections instead of opening a new one per request.

Theory in plain words

A pool in userequest arrivesborrow a connectionfrom the poolrun queriesreturn the connectionto the pool
A pool in use

What it is

A connection pool keeps a set of open database connections ready to reuse, since opening a brand-new connection for every request is slow.

Why it matters

Pooled connections are shared across requests, so code must never leave a connection holding session-level state (like a half-finished transaction) that could leak between unrelated users.

Mechanically speaking

Use your framework or driver's built-in pool; always close or return a connection when done, ideally with a try/finally or equivalent.

Shows up in

  • Web application code review
  • Backend development
  • Database administration

This is a driver/infrastructure concept rather than a SQL statement, so no runnable example is given; the "Secure schema and data design" part later covers connection pooling security specifically.

Check yourself

1. A connection pool mainly avoids...