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

[8.x] Document the query builder's new lazy() method #6943

Merged
merged 1 commit into from
Mar 24, 2021

Conversation

JosephSilber
Copy link
Member

Ref laravel/framework#36699


I'll let you rewrite it in your own voice, but this should give you a good starting point.

@JosephSilber JosephSilber force-pushed the builder-lazy branch 7 times, most recently from 6f95f48 to 0e89ed2 Compare March 24, 2021 03:55
@taylorotwell
Copy link
Member

Thank you ❤️

@JosephSilber JosephSilber deleted the builder-lazy branch March 25, 2021 00:44

foreach (Flight::lazy() as $flight) {
//
}
Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member Author

Choose a reason for hiding this comment

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

  1. I thought that was clear enough. Is it not?

  2. If it isn't, would this help?

    image

Copy link
Member

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

Copy link
Member Author

@JosephSilber JosephSilber Mar 25, 2021

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).

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.

3 participants