Hi,
so I have two fields in documents of string data type, now I want to change them to date data type
but I have 10 millions documents in that collection with 12 indexes .
On a production system I would try to throttle the operation by converting a limited number of documents directly into the database rather than using a temporary one. This should reduce the usage spike caused by both the conversion and the index rebuilding.
The first stage would be a $match for the $type of created_at and updated_at. I then would $limit to may be 100_000. You would then have to run the pipeline 10 times to convert all. Last stage would be a $merge.
Converting your string date to use the date data type is the smart thing to do. Kudos