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

Replace expensive count() with cheap exists() #478

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tuky
Copy link

@tuky tuky commented May 13, 2024

Heyo, hopefully an easy one. We are using model bakery in a setting where the DB can have millions of rows and counting the table just for checking, if any entry exists is overkill. The easy solution: only check for existence.

@tuky tuky changed the title Replace expansive count() with cheap exists() Replace expensive count() with cheap exists() May 13, 2024
Copy link
Member

@berinhard berinhard left a comment

Choose a reason for hiding this comment

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

Thanks for taking the time to open this PR, @tuky! This is definitely a significant improvement for large DBs.

@tuky
Copy link
Author

tuky commented May 14, 2024

Thx. Yeah, it's especially an improvement for MySQL InnoDB like we run 😏

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