title: What is the alternative to cursors to retrieve large amounts of data from a database?
body: <p>Searching through stackoverflow I found a large number of answers condemning the use of cursors in database programming. However I don't really understand what the alternative is.</p>
  
  <p>I'm creating a program which reads a large number of rows (hundreds of thousands) from the database and keeps them in memory, for performance reasons. I can't really run a SELECT * FROM table and process all the results at once, can I?</p>
  
  <p>The best way I have found is to use cursors and retrieve the rows in increments, for example 10 at a time.</p>
  
  <p>Could someone enlighten me? I use PostgreSQL 9 on linux.</p>
  
  <p>Thanks</p>