tvw wrote in post #1040336: > today I went into a problem, when I had to iterate over a big result > set. ActiveRecord produces a huge array of model instances, which > consumed 1GB of memory on my machine. A comparable perl DBI script > only used some KB for iterating over the result set.
It is well known that ActiveRecord objects are pretty heavy weight. My guess is that your Perl script is instead returning you something very light weight. Something that is little more than key value pairs for each database row. I'm also assuming that whatever you're doing with this large result set probably doesn't require "smart" heavy weight model objects. In the past I used a framework that had a similar issue. It, however, had a built-in mechanism for dealing with the issue. It had something called "raw row fetching." Rather than returning true model objects, with all the intelligence built into them, you could opt to fetch raw rows that were represented by an array of dictionaries (hashes). A raw row could then be transformed into a full fledged model object on demand. I don't know if ActiveRecord provides anything similar to this out-of-the-box. But, I'm sure someone must have developed something like this for Rails. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

