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


#1

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...
end
....

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?


#2

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


#3

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