-
Notifications
You must be signed in to change notification settings - Fork 130
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
fix(galleries): more efficient queries #1098
Conversation
@@ -26,7 +26,7 @@ | |||
</p> | |||
@endif | |||
<p>{!! $gallery->description !!}</p> | |||
@if (!$gallery->submissions->count() && $gallery->children->count() && $childSubmissions->count()) | |||
@if (!$gallery->submissions()->count() && $gallery->children->count() && $childSubmissions->count()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the reasoning here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without the parenthesis it's pulling all submissions into memory to count them instead of letting sql count them
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought it was the reverse? Or is there some particular nuance of relation-vs-query I'm missing here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, not the reverse:
https://laravel.com/docs/10.x/eloquent-relationships#querying-relations
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahhhh I see
…ase-to-dev * corowne/release/v3.0.0: fix(galleries): make some queries more efficient (corowne#1098) fix: improve user profile, character page row styling on smaller viewports/mobile (corowne#1099)
Making a couple more gallery related queries more efficient.