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.
Rework in_batches to be more network efficient
When `use_ranges: true` option is used, there is no need to return the whole list of ids for every range. This would waste to many network and time resources, as only the last id is needed. Instead we can use OFFSET to peek at the last id of the next batch, and return only this one. There's a trade-off though, since we need one additional query to confirm the size and last id for the very last batch. Unless you have only a handful of small batches, this is overall a winning strategy with less time and network resources spent to generate batches. There is a trade-off, however, as we need an additional query to confirm the size and last id of the very last batch. Unless you 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
5d528ba
commit 56ba355
Showing
2 changed files
with
29 additions
and
17 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