All Topics
All Topics
Technology
Technology
Design
Design
Programming
Programming
Science
Science
News
News
Gaming
Gaming
Entertainment
Entertainment
Business
Business
Finance
Finance
Sports
Sports
Health
Health
Food
Food
Travel
Travel
Art
Art
Music
Music
Books
Books
Education
Education
Politics
Politics
Personal
Personal
No algorithm. No AI slop. No ads. Just RSS. Pro-human. Indie writers. Real journalism. Open web. Chronological. Hand toasted.

PostgreSQL work_mem Configuration Pitfalls: How Low Memory Settings Can Cause Catastrophic Outages

By

enz

2mo ago· 6 min readenInsight

Summary

The article discusses a critical PostgreSQL database performance issue where a production cluster with 2 TB of RAM was killed by the OOM (Out of Memory) killer despite having work_mem set to only 2 MB. The author investigates this counterintuitive scenario where a seemingly low memory setting caused catastrophic failure, exploring how PostgreSQL's work_mem parameter interacts with query execution, sorting operations, and memory allocation. The piece serves as a technical analysis of database memory management pitfalls and provides insights for database administrators on properly configuring PostgreSQL memory settings to avoid production outages.

Key quotes

· 5 pulled
Her production cluster had just been killed by the OOM killer after eating 2 TB of RAM. work_mem was set to 2 MB.
Something didn't add up. Hetty, like me, likes playing with monster hardware. 2 TB of RAM is not unusual in her world.
But losing the whole cluster to a single query during peak operations is a very different kind of problem from a 3am outage.
The work_mem setting is a trap because it's not what you think it is. It's not a limit on how much memory a query can use.
When PostgreSQL needs to sort data, it can use work_mem for each sort operation, and if you have multiple sorts in a query, each can allocate work_mem separately.
Snippet from the RSS feed
My friend Henrietta Dombrovskaya pinged me on Telegram. Her production cluster had just been killed by the OOM killer after eating 2 TB of RAM. work_mem was set to 2 MB. Something didn’t add up. Hetty, like me, likes playing with monster hardware. 2 TB of

You might also wanna read