Assuming standard simple models as following:
class User < ActiveRecord::Base
has_many :posts
end
class Post < ActiveRecord::Base
has_many :comments
end
class Comment < ActiveRecord::Base
end
And my queries:
includes = {:posts => [:comments]}
person = Person.where(:id => 5).includes(includes)
Is there some way I can fetch comments from posts in batches? Because in some cases, a one user
has thousands of posts
, so the query it constructs to fetch the comments
becomes very big and slow.