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

Avoid unnecessary data fetch for exists method #2692

Conversation

andersonls
Copy link
Contributor

The issue

The exists() method is fetching all document properties unnecessarily since we only want to know if a record exists.

The solution

Changed behaviour so it only fetches the _id property.

Copy link
Member

@GromNaN GromNaN left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch.
For reference, Laravel uses a specific SQL statement.

@GromNaN GromNaN merged commit b3779a1 into mongodb:4.1 Dec 11, 2023
15 checks passed
@GromNaN
Copy link
Member

GromNaN commented Dec 11, 2023

Thank you @andersonls

@andersonls andersonls deleted the improvement/avoid-unnecessary-data-fetch-for-exists branch December 11, 2023 11:36
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

Successfully merging this pull request may close these issues.

None yet

2 participants