TLDR DevOps · MISCELLANEOUS
CAN YOUR POSTGRES SURVIVE A BAD QUERY?
Summary from the TLDR DevOps newsletter
Postgres memory limits such as work_mem apply per execution node and per worker rather than per query, allowing seemingly ordinary queries to consume many times the configured amount of memory. Recursive queries can be even more dangerous because some executor hash tables cannot spill to disk, creating workloads that can exhaust memory despite conservative configuration.