Closed rammpeter closed 7 years ago
Thanks for providing a code, would you consider to open this change as a pull request including some tests.
+1 for this change. I just had a case where my code wanted to query about 20 million rows of about 5 columns; the process took about 32GB (!) of RAM before being killed by ulimit
. ;) @rammpeter, I'm using your monkey patch now, but can you please upload your change as pull request, as well?
I stumbled on this thread looking for a solution to a similar problem. I have a view I'm trying to import with 111 million rows. Obviously I can't fit that in memory on even the beefiest of machines. I managed to use 96GB ram and 47GB swap before the server just gave up. My server guy came in and said, _"That's all there is, and there ain't no more."_
Originally I wanted to use in_batches to process 1000 or so at a time. I couldn't however as my view doesn't have a primary ID.
Is there a way to retrofit in_batches
to use ROWNUM instead? It seems like that would be the more natural fit on Oracle in the first place.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This is pretty old, but you can use Model.connection.raw_connection.exec(sql, *binds)
which returns a cursor.
From there it's just fetch_hash
until the cursor is empty.
Hi Raimonds,
it would be great if there is a possibility to expand ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter with a method similar to exec_query, which returns an iterator instead of result array.
This way one will be able to process large results record by record without storing the complete result in memory. This works proper for large results normally ending in "out of memory" if processed by exec_query.
I use the following implementation of class SqlSelectIterator in production, may be it can fit in one of your next version.
Best regards Peter
p.s.: It would also be nice if query timeout be "statement.setQueryTimeout" can be set as high level option.