Note that there are some explanatory texts on larger screens.

plurals
  1. POAre there any Ruby ORMs which use cursors or smart fetch?
    primarykey
    data
    text
    <p>I'm looking for a Ruby ORM to replace ActiveRecord. I've been looking at Sequel and DataMapper. They look pretty good however none of them seems to do the basic: not loading everything in memory when you don't need it.</p> <p>I mean I've tried the following (or equivalent) on ActiveRecord and Sequel on table with lots of rows:</p> <pre><code> posts.each { |p| puts p } </code></pre> <p>Both of them go crazy on memory. They seem to load everything in memory rather than fetching stuff when needed. I used the <code>find_in_batches</code> in ActiveRecord, but it's not an acceptable solution:</p> <ol> <li>ActiveRecord is not an acceptable solution because we had too many problems with it.</li> <li><p>Why should my code be aware of a paging mechanism? I'm happy to configure somewhere the size of the page but that's it. With <code>find_in_batches</code> you need to do something like:</p> <p>post.find_in_batches { |batch| batch.each { |p| puts p } }</p></li> </ol> <p>But that should be transparent.</p> <p>So is there somewhere a reliable Ruby ORM which does the fetch properly?</p> <hr> <p>Update:</p> <p>As Sergio mentioned, in Rails 3 you can use <code>find_each</code> which exactly what I want. However as ActiveRecord is not an option, except if someone can really convince me to use it, the questions are:</p> <ol> <li>Which ORMs support the equivalent of find_each?</li> <li>How to do it?</li> <li>Why do we need a <code>find_each</code>, while <code>find</code> should do it, shouldn't it?</li> </ol>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload