How exactly an Ecto stream works?

As @al2o3cr said, it will retrieve chunks, according to the executed query. if there is no filtering/limiting factor on your Stream processing side of the thing, it will end up with all rows in memory at the endo f the stream execution.
functions like Stream.run/1, Stream.take/2, Stream.filter/2 and Stream.reject/2 should limit or avoid having all rows returned by the query in memory on your application.

edit: otherwise, it will protect the database of returning all rows at once with the cursor but will have all rows in the application memory.

2 Likes