I am trying o migrate data in MongoDB with mongock and stumbled upon an issue when I need to run migration across a big amount of data.
Is there a way to partition this data in any way? I didn't find support for that on documentation.
Problem is that it takes a lot of time to make queries on this data and to load all of it into memory at once also can cause problems.
UPD: Problem is that sample code can bring 1 or 1kk documents and it can take huge amount of time
mongoTemplate.findAll(User.class).stream()
.map(this::migrateUser)
.forEach(mongoTemplate::save);