今天早上在做一个删除冷数据的测试。
发现对某一个集合进行删除的时候,比如:
db.xxx.remove({'created_at': {'$lt': datetime(2012, 01, 01)}})
然后符合这个条件的记录数是:500000
在pymongo里执行remove之后
不断进行count(),记录条数下降到几千的时候就不动了。
之后再删除一次,这几千行的记录就被删掉不见。
请问有遇到过相同问题的嘛?
如何解决?
今天早上在做一个删除冷数据的测试。
发现对某一个集合进行删除的时候,比如:
db.xxx.remove({'created_at': {'$lt': datetime(2012, 01, 01)}})
然后符合这个条件的记录数是:500000
在pymongo里执行remove之后
不断进行count(),记录条数下降到几千的时候就不动了。
之后再删除一次,这几千行的记录就被删掉不见。
请问有遇到过相同问题的嘛?
如何解决?
''' v1.3+ supports concurrent operations while a remove runs. If a simultaneous update (on the same collection) grows an object which matched the remove criteria, the updated object may not be removed (as the operations are happening at approximately the same time, this may not even be surprising). In situations where this is undesireable, pass {$atomic : true} in your filter expression: db.videos.remove( { rating : { $lt : 3.0 }, $atomic : true } ) The remove operation is then isolated – however, it will also block other operations while executing. '''