-
Notifications
You must be signed in to change notification settings - Fork 821
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 Calculate threshold condition with SQL rather than PHP #8921
FIX Calculate threshold condition with SQL rather than PHP #8921
Conversation
81d3cc7
to
3b1c774
Compare
This is a performance fix. Modern SQL engines can avoid counting a whole result set (potentially thousands of records) when you are only interested if the count exceeds a threshold.
3b1c774
to
a48beac
Compare
static::$foreignListCache[$hasOneClass] = [ | ||
'count' => $list->count(), | ||
'overThreshold' => $overThreshold, |
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.
It's possible albeit incredibly unlikely that this is a breaking change if someone is relying on the existing count
cache in a subclass.
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'm not sure we'd consider that part of our API to be honest
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.
The changes look good to me in theory. The fact that the tests pass is a good sign as well.
static::$foreignListCache[$hasOneClass] = [ | ||
'count' => $list->count(), | ||
'overThreshold' => $overThreshold, |
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'm not sure we'd consider that part of our API to be honest
This is a performance fix. Modern SQL engines can avoid counting a whole result set (potentially thousands of records) when you are only interested if the count exceeds a threshold.
Split from #8915. This is now targeting 4.3 as a patch. Happy to retarget any other branch if requested 🙂
I am setting this query to not be
DISTINCT
which I think is an okay assumption. Feel free to close this PR if I'm wrong.