I am new to RoR. In my controller, I repeat all the tuples in the database. For each table for each column that I used to call
SomeOtherModel.find_by_sql("SELECT column FROM model").each {|x| #etc }
which worked well enough. When I later changed it to
Model.all(:select => "column").each {|x| #etc }
the cycle starts at about the same speed, but it slows down quickly to about 100 times slower than the find_by_sql command. These calls must be identical, so I really don't know what is going on.
I know that these challenges are not the most effective, but this is just an intermediate step, and I will optimize it more as soon as it works correctly.
So to clarify: why is the call to Model.all.each in the world much slower than using find_by_sql.each?
Thank!
source
share