Skip to content
cheerfulstoic edited this page Nov 3, 2014 · 1 revision

Finding in Batches

When you have many nodes to query but you don't want to load them all into memory at once, the find_in_batches and find_each methods are provided on the Query class.

query = Query.new.match(user: :User).return(:user)

query.find_in_batches(:user, :uuid, batch_size: 500) do |batch|
  puts "User batch names: #{batch.map(&:user).map(&:name)}"
end

query.find_each(:user, :uuid, :batch_size: 500) do |result|
  puts "User name: #{result.user.name}"
end

Both find_in_batches and find_each make queries for up to batch_size records at a time. The batch_size option is optional and the default is 1000

WARNING: Much of the information in this wiki is out of day. We are in the process of moving things to readthedocs

Api

Contribute

Clone this wiki locally