继续进行本讨论:why pymongo count_documents is slower than count
如果我像这样在PyMongo中查询我的MongoDB数据库
cursor = mydb.mycollection.find( {'some_key' : 'some_val'} )
既然cursor.count()
将被弃用,如何有效地获取该查询的大小?
一种选择是使用:
mydb.mycollection.count_documents( {'some_key' : 'some_val'} )
但是,这涉及到重新运行查询,据我了解,该查询的效率低于当前解决方案。