A faster alternative to the custom use of `in_batches` with `pluck`
08-Jun-2023 755
ActiveRecord comes with find_each / find_in_batches / in_batches methods to batch process records from a database. ActiveRecord also has the pluck method which allows the selection of a set of fields without pulling the entire record into memory.This gem combines these ideas and provides pluck_each and pluck_in_batches methods to allow batch processing of plucked fields from the database.It performs half of the number of SQL queries, allocates up to half of the memory and is up to 2x faster (or more, depending on how far is your database from the application) than the available alternative:.
A faster alternative to the custom use of `in_batches` with `pluck` #ruby #rubydeveloper #rubyonrails #faster #alternative #custom #`in_batches` #`pluck` https://rubyonrails.ba/link/a-faster-alternative-to-the-custom-use-of-in_batches-with-pluck