liveBook · Manning

Database connection

As explained in PostgreSQL Mistakes and How to Avoid Them

A database connection is an active communication session between a client and a database server.

A database connection is an active communication session between a client and a PostgreSQL server. More allowed connections do not automatically improve application performance: excessive concurrency can overload a modest server, increasing latency while throughput stagnates. section 6.3

The 2,000-connection mistake

A configuration with max_connections = 2000 may appear generous, but a pgbench run with 2,000 clients processed 352.1 transactions per second at 5,535 ms average latency. With 32 clients, latency fell to 55.9 ms, showing that the high-concurrency workload traded responsiveness for a throughput plateau. section 6.3

Use connection limits as an operational control, not as a capacity contest:

  • Test client counts against both throughput and latency; throughput alone can hide an overloaded server. section 6.3

How PostgreSQL Mistakes and How to Avoid Them covers it

How deep it goes
Benchmarks concurrency through TPS and latency, but stops short of connection-pool design or session internals.
Examples
Uses PostgreSQL configuration values, pgbench commands, and a client-count comparison table.
What it assumes
Assumes PostgreSQL configuration and benchmarking familiarity while explaining the performance cost of excessive connections.
What you can do after
Diagnose excessive concurrency by comparing pgbench throughput and latency across client counts.
How it connects
Connects database connections with concurrency, throughput, latency, shared_buffers, work_mem, and max_connections.

Also explained in

Compare how 6 books explain database connection →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of PostgreSQL Mistakes and How to Avoid Them. The section links point to the parts of the book it draws on.