You could try use the $set
operator to empty the visitors array instead of removing all items by using the $pull
operator, which would be much faster as the $pull
will have to do calculations on arrays:
db.collection.update( {"date": date, "domain": domain}, { $set : {"visitors": [] }} , {multi: true} )
The equivalent $pull
operation would be
db.collection.update( {"date": date, "domain": domain}, { $pull : { "visitors": {} }}, {multi: true} )
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…