title: Ruby and PostgreSQL single row mode
body: <p>I am fetching rows from a PostgreSQL DB using Ruby. This is done in single row mode as described on the <code>pg</code> gem site (<a href="https://deveiate.org/code/pg/PG/Result.html" rel="nofollow noreferrer">https://deveiate.org/code/pg/PG/Result.html</a>)</p>
  
  <pre><code>conn.send_query( "first SQL query" )
  conn.set_single_row_mode
  conn.get_result.stream_each do |row|
      # do something with the received row of the first query
  end
  </code></pre>
  
  <p>I get all rows of the result set separately as expected. However for large result sets Ruby seems to keep them in memory. This makes the Ruby program terminate as it runs out of memory.</p>
  
  <p>Is there a way to free the space of already processed rows?
  I think I should use <code>clear()</code> or <code>autoclear?</code> but I am not sure how to use it and what exactly to clear.</p>