When you use ActiveRecord::Base.connection.execute(sql_string), should you call clearfor the result to free memory?
At 7:09 p.m. in this podcast , the speaker (the Rails commander who worked a lot on Active Record) says that if we use ActiveRecord::Base.connection.execute, we must call clearthe result, or we must use the method ActiveRecord::Base.connection.execute_and_clearthat takes the block.
(Hes is a little confusing in method names. The method for the MySQL adapter is free, and the method for the Postgres adapter is clear. It also mentions release, but this method does not exist.)
I understand that he says we must change
result = ActiveRecord::Base.connection.execute(sql_string).to_a
process_result(result)
to
ActiveRecord::Base.connection.execute_and_clear(sql_string, "SCHEMA", []) do |result|
process_result(result)
end
or
result = ActiveRecord::Base.connection.execute(sql_string)
process_result(result)
result.clear
, , . Rails, , execute clear , , . , clear, , ?