Are there any Ruby ORMs which use cursors or smart fetch?

前端 未结 5 543
误落风尘
误落风尘 2021-02-05 07:36

I\'m looking for a Ruby ORM to replace ActiveRecord. I\'ve been looking at Sequel and DataMapper. They look pretty good however none of them seems to do the basic: not loading e

5条回答
  •  既然无缘
    2021-02-05 07:41

    This code works faster than find_in_batches in ActiveRecord

    id_max = table.get(:max[:id])
    id_min = table.get(:min[:id])
    n=1000
    (0..(id_max-id_min)/n).map.each do |i|
        table.filter(:id >= id_min+n*i, :id < id_min+n*(i+1)).each {|row|}
    end
    

提交回复
热议问题