Endon.stream_where
You're seeing just the function
stream_where
, go back to Endon module for more information.
Specs
stream_where(where_conditions(), keyword()) :: Enumerable.t()
Create a Stream
that queries the data store in batches for matching records.
This is useful for paginating through a very large result set in chunks. The Stream
is a composable, lazy enumerable that allows you to iterate through what could be a
very large number of records efficiently.
The conditions
are anything accepted by where/2
(including a Ecto.Query.t/0
).
This function will only work for types that have a primary key that is an integer.
Options
:batch_size
- Specifies the size of the batch. Defaults to 1000.:start
- Specifies the primary key value to start from, inclusive of the value.:finish
- Specifies the primary key value to end at, inclusive of the value.
Examples
iex> Enum.each(User.stream_where(), &User.do_some_processing/1)
iex> query = from u in User, where: u.id > 100
iex> Enum.each(User.stream_where(query, batch_size: 10), fn user ->
iex> User.do_some_processing(user)
iex> end)