forked from rails/rails
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Fix rails#51242] Rework in_batches(use_ranges: true) to be more effi…
…cient When `use_ranges: true` option is used, we do not need to return the whole list of primary keys for each range. This wastes network resources and takes longer than necessary, as only the last primary key from the range would be needed. We can instead use OFFSET to peek at the last primary key of the next batch, instead of returning the whole list of pks from the range. There is a trade-off, however, as we need an additional query to confirm the size of the very last batch, and the value of the last last primary key. Unless we only have a handful of small batches, this strategy is a winner overall, as it reduces the time and network resources spent generating batches.
- Loading branch information
1 parent
4a7c86a
commit 58a0796
Showing
3 changed files
with
73 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters