Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pymongo count() function deprecated. Use count_documents instead #165

Open
wfehrnstrom opened this issue Apr 9, 2020 · 2 comments
Open

Comments

@wfehrnstrom
Copy link
Collaborator

https://api.mongodb.com/python/current/api/pymongo/collection.html#pymongo.collection.Collection.count_documents

@insiyab
Copy link
Contributor

insiyab commented May 22, 2020

Just a note:
count_documents() is slower than count() as it's used in the codebase currently.
estimated_document_count() gives us the same behavior as count(), so I propose we use that instead.

The reason that count() was deprecated in the first place was because its behavior would be like the current count_documents() if it was given a query, and estimated_document_count() otherwise. In our codebase, we pretty much never give count() a query.
(https://stackoverflow.com/questions/52236594/why-is-pymongo-count-documents-is-slower-than-count)

@Kimeiga
Copy link
Contributor

Kimeiga commented May 23, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants