Postgres is remarkably capable out of the box, but defaults are tuned for safety not performance. Here's what I changed to handle 50 M rows at low latency.
explain analyse first
Never optimise blind. EXPLAIN ANALYSE shows the query plan, actual row counts, and where time is spent...
index strategies
Covering indexes, partial indexes, and expression indexes each solve a different class of slow query...
connection pooling with pgbouncer
Postgres has a hard connection limit. PgBouncer multiplexes thousands of application connections over a small pool...
read replicas
Offloading reads to a streaming replica cuts primary load and reduces latency for geographically distributed users...
postgresql · performance · node.js