In the routine I'm developing, I make a simple SELECT in the database, just in a table:
Model.select("id").where(:tipo => 2).find_each do |registro|
puts registro.id
end
But this select returns around 160,000 records. Then the system gives the error:
pid 258 SIGKILL (signal 9)
If I comment on this line and follow my code, everything runs normally. I already researched this and started using the find_each
function instead of each
, but the error continued. If I limit the query, it also works normally.
As far as I understand, the error is only because of the volume of data that is larger than the memory can support. Analyzing link and link , I noticed that find_each
improves this situation, but it did not help. How do I resolve this?