Inadequate work_mem causes query spill to disk
warningperformanceUpdated Feb 26, 2026
Technologies:
How to detect:
Default work_mem of 4MB is insufficient for sort/hash/join operations, causing queries to spill to disk and slow down
Recommended action:
For OLTP workloads, set work_mem to 16-64MB. For OLAP workloads, set to 128MB or higher. Monitor postgresql.temp_files and postgresql.temp_bytes to detect disk spills. Adjust per-session via SET work_mem if needed for specific queries.