til
til copied to clipboard
Memory cost of connection in PostgreSQL
Each of these “backend” processes starts out at around 5 MB in size, but may grow to be much larger depending on the data they’re accessing 1.
https://brandur.org/postgres-connections
Client users need to create a connection to a web service before they can perform CRUD operations. Most web services are backed by relational database servers such as Postgres or MySQL. With PostgreSQL, each new connection can take up to 1.3MB in memory
https://stackoverflow.blog/2020/10/14/improve-database-performance-with-connection-pooling/
How to measure
# create a connection with psql
> psql
> SELECT pg_backend_pid();
pg_backend_pid
----------------
1161650
(1 row)
> ps -q 1161650 -eo pid,rss
PID RSS
1161650 x