# 5.2 The Private Desk (work_mem) ![The Private Desk](assets/arch_private_desk_spill.png) The **Shared Buffers** (Chapter 5.1) are for the whole group. But sometimes, a single soldier needs to do something messy—like sorting ten million names alphabetically. He can't use the communal Warming Rack for that; it would be like trying to organize your tax returns on the kitchen table while everyone is trying to eat dinner. So, every soldier is given a **Private Desk**. In Postgres, we call this **`work_mem`**. ## The Per-Task Desk Unlike the Shared Buffers, which are allocated once when the elephant wakes up, `work_mem` is given to *each individual operation* in a query plan. If your plan has three **[[Operations/Sort|Sort]]** nodes and two **[[Operations/HashJoin|Hash Joins]]**, the elephant might be trying to manage five different desks at the same time. ## The Danger of Too Many Desks (OOM) This is where things get dangerous. If you have 100 elephants (connections) each trying to run a query with 10 desks, and each desk is set to 64MB... suddenly you're trying to fit 64GB of desks into a 16GB room. The OS will eventually panic, reach into the room, and "terminate" the biggest elephant to save the building. This is the dreaded **Out of Memory (OOM)** event. ## The Spill to Disk If a soldier's desk is too small for his data, he doesn't just stop. He is a professional. He begins the grueling process of **Spilling to Disk**. He breaks his list into small chunks, writes them to the basement, clears his desk, and starts again. As we learned in **[[Chapter 6/6.5 - The Query Battle|The Query Battle]]**, this turns a 5-minute task into a 4-month-long winter expedition. --- [[Chapter 5/5.1 - The Warming Rack|← 5.1 - The Warming Rack]] | [[Chapter 5/5.0 - The Hunger of Resources|↑ 5.0 - The Hunger of Resources]] | [[Chapter 5/5.3 - The Housekeepers|5.3 - The Housekeepers →]]