Re: [Rails] find_by_sql query running incredibly slow

2014-03-05 Thread Colin Law
On 5 March 2014 00:32, John Merlino stoici...@aol.com wrote: Initially, I was using this query: report_ids = [] if units.size 0 units.map(:id).uniq.each do |id| report_id = Report.select(:id).where(unit_id: id).order(time desc).first unless report_id.nil?

[Rails] find_by_sql query running incredibly slow

2014-03-04 Thread John Merlino
Initially, I was using this query: report_ids = [] if units.size 0 units.map(:id).uniq.each do |id| report_id = Report.select(:id).where(unit_id: id).order(time desc).first unless report_id.nil? report_ids report_id end end end