Peter Kleiweg
unread,Nov 9, 2012, 2:36:44 PM11/9/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to mongodb-user
I need to update about 400 million object.
I read, the quickest way to do this is to run the script on the
server. So I run this:
db.runCommand(
{
$eval:function() {
db.tweets.find(
{},
{_id:1, "META.date":1}
).forEach(
function(tweet) {
db.tweets.update(
{_id:tweet._id},
{$set:
{"META.day":parseInt(tweet.META.date.substring(8, 10), 10)}}
);
}
);
},
nolock: true
})
This updates about 2.7 object per second, so it will require about 4
years and 8 months.
I don't want to wait that long.
This data was entered in little over a month, and since I still have
the sources, I could just delete the databases, and start again.
But I have to ask: is there a better way?