Repaso
EspaƱol
Databases & SQLIntermediateDB-21

Why use a database connection pool?

Options

  1. To encrypt the queries that are sent from the app to the database
  2. Opening connections is costly; a pool reuses a limited set of them (Correct option)
  3. To split the data of the application across several servers
  4. To cache the results of queries that are repeated often

Answer

Opening connections is expensive; a pool reuses a bounded set and protects the DB from too many connections

Why

Opening a database connection takes time (network handshake, authentication) and each open connection uses memory on the database server.

A pool keeps a fixed number of connections open and lends them to requests, which return them when done.

Size it so that all app instances together stay under the database's max connections.

Remember

Reuse connections with a pool; don't open one per query.

Key terms

Practice this question in Repaso