It looks like you have a couple of problems.
# 1: $unset
As far as I can see, this should work fine. I got the following result in my test:
MongoDB shell version: 1.6.5 connecting to: test > db.foo.save( { _id : 1, status : { err : 'blah', y : 1 } } ) > db.foo.save( { _id : 2, status : { err : 'blahblah', y : 5 } } ) > db.foo.find() { "_id" : 1, "status" : { "err" : "blah", "y" : 1 } } { "_id" : 2, "status" : { "err" : "blahblah", "y" : 5 } } > db.foo.update( { }, { $unset : { "status.err" : 1 } }, false, true ) > db.foo.find() { "_id" : 1, "status" : { "y" : 1 } } { "_id" : 2, "status" : { "y" : 5 } }
# 2: using RAM
if I make the $ unset command for a column in a very large collection, mongodb uses all the ram on the server (as if it is trying to store the entire collection in memory)
What MongoDB is trying to do. MongoDB uses memory mapped files. MongoDB will pull out all the data in RAM and allow the operating system to manage virtual memory problems.
So, when you make a query without indexes, you basically ask MongoDB to go through each element of the collection. This is basically a gigantic loop that runs on all of your data, so you need to download everything from disk.
So far this is normal.
... then the server crashes
It is not normal. I ran this type of update command on hundreds of millions of documents without server crashes. Can you provide more details about this issue? Do you have log files?
If so, I would suggest taking your errors into Google groups so that they can help identify the source of the failure. http://groups.google.com/group/mongodb-user
Gates VP Feb. 15 2018-11-11T00: 00Z
source share