-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
[8.x] Document the query builder's new lazy()
method
#6943
Conversation
6f95f48
to
0e89ed2
Compare
0e89ed2
to
4342d6d
Compare
Thank you ❤️ |
|
||
foreach (Flight::lazy() as $flight) { | ||
// | ||
} |
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.
@JosephSilber I'm wondering if $flight
is an instance of Eloquent or a chunk set of Eloquent?
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.
instead of passing each chunk into a callback, the
lazy()
method returns [...] results as a single stream
So $flight
is a single Eloquent model.
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.
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.
ability to pass chunkCount
throws me off there. Understood now
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 $chunkCount
determines how many records should be requested per chunk behind the scenes.
Bigger chunks use more memory, while smaller chunks means more queries (potentially exacerbated by eager loading relationships).
Ref laravel/framework#36699
I'll let you rewrite it in your own voice, but this should give you a good starting point.