To use the spatial functions from MongoDB I need to update the Dataset. When I run the following code over 20million documents it is still not finished after 8h.

Is there a faster way to do this?

db.eval(function() { 
db.test.find({}).forEach(function(e) {
    e.geometry = {"type": "Point", "coordinates": [e.SA_X_COORD, e.SA_Y_COORD]}
    db.test.save(e);
});
},
{ nolock: true });
有帮助吗?

解决方案

was able to speed it up quite a bit by changing

db.test.save(e);
to 
db.test.update(e);
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top