Extremely slow updates

17 views
Skip to first unread message

Peter Kleiweg

unread,
Nov 9, 2012, 2:36:44 PM11/9/12
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?

Wes Freeman

unread,
Nov 9, 2012, 2:45:45 PM11/9/12
to mongod...@googlegroups.com
1. Dropping your indexes might help
2. If you plan to need to add a field again, you might consider pre-padding your documents: http://www.mongodb.org/display/DOCS/Padding+Factor#PaddingFactor-ManualPadding


--
You received this message because you are subscribed to the Google
Groups "mongodb-user" group.
To post to this group, send email to mongod...@googlegroups.com
To unsubscribe from this group, send email to
mongodb-user...@googlegroups.com
See also the IRC channel -- freenode.net#mongodb

Peter Kleiweg

unread,
Nov 9, 2012, 3:07:53 PM11/9/12
to mongodb-user
On 9 nov, 20:46, Wes Freeman <freeman....@gmail.com> wrote:
> 1. Dropping your indexes might help

That helps a lot. It looks like the updating can be done in a day or
so. Then a week to rebuild all the indexes...
Reply all
Reply to author
Forward
0 new messages