Skip to content

Special case batch size 1 to avoid doing needless range lookups

Gregory Stark requested to merge each-batch-for-batch-size-one into master

Special case batch sizes of 1 so we don't do range lookups for large ranges of keyspace just for a single record after already verifying that that keyspace has precisely the one record in it.

I'm a bit nervous about this each_batch code in general. The ranges it constructs can be arbitrarily large and if they're very large the database is likely to decide a sequential scan is appropriate. Also, it's effectively doing a query over the rows that need to be processed, then doing a second query over the same rows, doing the work twice. What problem was it trying to solve in the in_batches code?

Merge request reports