What happens to memory when iterating through bunch of documents using 'include_docs'?


Let’s say I have the following codes

blog = c.design_docs['blog']
blog.views   #=> ["recent_posts"]
recent_posts = blog.recent_posts(include_docs: true)
recent_posts.each do |post|
    puts post.id
    # Do something more...

If I have very large number of recent_posts (ex, 1GB in total), blog.recent_posts will put the whole 1GB of documents in memory?


Hi, it will instantiate them on demand. You can also use “per_page” in the params of your view object to paginate the results.


Does this mean I don’t have to worry about memory overflow?