Data processing in Parallel (Hackathon project)

Do not insert 500 records in a loop. Maybe just remove the Stream.chunk_every and Enum.map calls and and just insert records one by one. I think the way you’re doing it now increases contention for DB connections.

Working with batches of records in your scenario only makes sense if you’re going to use Repo.insert_all (without validation). If you need to validate and thus insert records one by one then there’s no point in working with batches.