-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
QuerySet count vs len #937
Labels
Comments
Feel free to throw up a Pull Request for updating the documentation. We are trying to clean up our back log of issues but we currently have a lot of issues and bugs to work through. Any help would be appreciated. :) |
marcoskv
added a commit
to marcoskv/mongoengine
that referenced
this issue
Jul 26, 2015
Current documentation does not consider performance issues in using len instead of count. MongoEngine#937
The documentation around this is better now, making it clear that |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The MongoEngine documentation recommends to use len to count results, because it is more Pythonic.
count() executes a server side count query, while len() retrieves the results, places them in cache, and then counts them.
If we compare the performance of the two operations, len() is super slow compared to count().
It would be better to explain that properly in the documentation.
The text was updated successfully, but these errors were encountered: