Skip to content

Conversation

@halaei
Copy link
Contributor

@halaei halaei commented Mar 26, 2019

Reopen #28015

eachById() is a more efficient alternative to each(), just like chunkById() is to chunk().
I really liked to call each() but not being skip-take based makes its runtime complexity quadratic.

I also wish chunk() and each() would do id based by default. Because, in my opinion, they reserve better names but they do worse.

Changes:

  • chunkById() functions in Query\Builder and Eloquent\Builder was mostly duplicate, so I removed them and move their main parts to BuildsQueries trait.
  • The different parts of chunkById() in the 2 classes are now moved to defaultKeyName() function.
  • The default value for $column in Query\Builder::chunkById() was 'id'. Now it is null. I guess the change is backward compatible. If it is not backward compatible this PR should be rejected.
  • I changed the description of chunkById() from "Chunk the results of a query by comparing numeric IDs." to "Chunk the results of a query by comparing IDs." because it handles non-numeric ids as well.

@taylorotwell
Copy link
Member

Probably better suited for 5.9.

@halaei halaei mentioned this pull request Mar 29, 2019
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