Skip to content

[12.x] use limit() in place of take() #56080

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

Merged
merged 3 commits into from
Jun 19, 2025

Conversation

browner12
Copy link
Contributor

in all of these changes, take() is a direct alias of the limit() method, and performs no additional logic. switching to directly calling the limit() method means less code execution (minimallly better performance) and reduces the call stack (nice for debugging).

a bit more subjective, but I would also argue that "limit" is a little clearer semantically about what it is doing to the query, whereas "take" has the implication that you're selecting everything and then taking a subset of that result.

in all of these changes, `take()` is a direct alias of the `limit()` method, and performs no additional logic.  switching to directly calling the `limit()` method means less code execution (minimallly better performance) and reduces the call stack (nice for debugging).

a bit more subjective, but I would also argue that "limit" is a little clearer semantically about what it is doing to the query, whereas "take" has the implication that you're selecting everything and then taking a subset of that result.
@taylorotwell taylorotwell merged commit 9f03dc6 into laravel:12.x Jun 19, 2025
59 of 60 checks passed
@browner12 browner12 deleted the AB-take-limit-optimization branch June 19, 2025 20:10
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.

2 participants