I have a collection contains three hundred million documents. Each document has a "created_at" field that specifies the time in a string format like this 'Thu Feb 05 09:25:38 +0000 2015'
I want to change all the "created_at" field to a MongoDB supported time format. So I wrote a simple Ruby script:
collection.find.each do |document|
document[:created_at] = Time.parse document[:created_at]
collection.save(document)
end
It did change the time format as I wished, but my script has been running for 50 hours, and there is no signs of finishing.
Is there a better way to do this task? A MongoDB shell script or Python script is also doable to me.
By the way, this collection is not indexed since it's continuously inserting documents