Row-by-row streaming with server-side cursors
One of the most common mistakes when working with large datasets in PostgreSQL is fetching everything into memory at once. It is the path of least resistance: you write your query, call fetchall(), and iterate over the results. For small da…