Schedule - PGConf.DE 2025
PostgreSQL Connections Memory Usage: How Much, Why and When?
Date: 2025-05-09
Time: 11:10–11:55
Room: Ballsaal 2
Level: Intermediate
This talk explores the memory usage of PostgreSQL connections on Debian/Ubuntu running on x86–64 architecture. It gives an overview of memory management concepts, explaining key metrics like virtual, resident, and proportional memory sizes. It also covers various Linux tools for displaying memory usage.
The second part presents practical measurements of PostgreSQL memory usage, based on data from /proc/PID/smaps. It explains why RSS numbers for PostgreSQL connections appear so large after query execution and demonstrates that the actual unique memory usage is only a few dozen megabytes.
Finally, the talk examines how PostgreSQL connections allocate and release additional memory during query processing. It also clarifies where work_mem fits into these numbers and visualizes the process with plots.
Key Takeaways:
- The large RSS values in long-running sessions mostly come from linked shared_buffers
- A newly created connection consumes only up to 10 MB of physical memory, independent of the work_mem setting
- Additional memory is allocated and later released as queries execute
- Work_mem is a “soft maximum limit” — it may not be fully used, but it can also be exceeded