title: SELECT query in chunks using PostgreSQL
body: <p>I have a table with well over a million entries. I'm putting all this data into perl and storing it into a variable ($query = "SELECT * FROM table1". The problem now is that I'm using a lot of resources (mostly memory). Given my novice state with perl and postgres, How would I transform that query into chunks or parts?</p>
  
  <p>For example, </p>
  
  <pre><code>$query = "SELECT * FROM table1 LIMIT 100000";
  </code></pre>
  
  <p>Would put 100K results into $query. table1 is 10M records in size. How would I transform it so that only 100K results are stored into $query at a time until the query is finished?</p>