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

[BUG] FindMany count ignores limit set #1010

Open
pschoen-itsc opened this issue Aug 29, 2024 · 0 comments
Open

[BUG] FindMany count ignores limit set #1010

pschoen-itsc opened this issue Aug 29, 2024 · 0 comments

Comments

@pschoen-itsc
Copy link

Describe the bug
When getting to count of a query with a limit applied before, the limit gets ignored. That is a problem, because so mongodb has to find all. documents matching the query to count them, instead of stopping after reaching the limit. In big collections (big documents, millions of them) this has a big performance impact.

To Reproduce

count = await MyDocument.find_many(MyDocument.foo == "bar").limit(1000).count()

does not return the count of all Documents with foo==bar, instead of maximum 1000.

Expected behavior
Returns 1000 if more documents than 1000 or found, otherwise the count lower than 1000.

Additional context
We moved from pure pymongo queries to beanie. With pymongo this worked as I described my expectation here. So it would be nice to have the same behaviour here.

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

1 participant