Infortunately I need to process the stream within the transaction. I’ll see if I can remove that constraint. But I do have a where clause, so there are not too many records (70k) and I can hold the transaction for quite a while, it’s on a task that is run periodically.
I do believe that Repo.stream is doing its own batches with the query, using a cursor, so I guess it’s not doing a SELECT for each user.
(If it’s not clear that query is the argument given to Repo.stream.)