Method: Dynamoid::Criteria::Chain#batch
- Defined in:
- lib/dynamoid/criteria/chain.rb
#batch(batch_size) ⇒ Dynamoid::Criteria::Chain
Set the batch size.
The batch size is a number of items which will be lazily loaded one by one. When the batch size is set then items will be loaded batch by batch of the specified size instead of relying on the default paging mechanism of DynamoDB.
Post.where(links_count: 2).batch(1000).all.each do |post|
# process a post
end
It’s useful to limit memory usage or throughput consumption
313 314 315 316 |
# File 'lib/dynamoid/criteria/chain.rb', line 313 def batch(batch_size) @batch_size = batch_size self end |