Mongodb - proper way to delete all elements in an array field?

mongodb

Solution

The `$set` variant will be faster as the `$pull` will have to do calculations on arrays. I am actually not even certain whether it will work, as you're not really removing any elements with your query.

Problem

I'm looking for the proper way to remove all elements from an array field (across all documents) in Mongodb - these appear to be equivalent, which is recommended: (or perhaps some other way?) ``` db.collection.update({}, { $pull : { 'myArray': {} }}, {multi:true} ) ``` or ``` db.collection.update({}, { $set : {'myArray': [] }} , {multi:true} ) ```

Original source