PostgreSQL Server-Side Cursors: How to Stream Millions of Rows Without Running Out of Memory
A nightly export OOM-killed itself trying to load ten million rows into memory at once. The fix wasn't more RAM — it was telling PostgreSQL to hand the rows over a batch at a time with a server-side cursor.