A Ruby gem providing ActiveRecord batch methods for plucking columns, reducing SQL queries and memory usage by up to 50%.
PluckInBatches is a Ruby gem that adds `pluck_each` and `pluck_in_batches` methods to ActiveRecord for efficiently batch-processing selected database columns. It solves performance issues when iterating over large datasets by reducing SQL queries and memory usage by up to 50% compared to manual combinations of `in_batches` and `pluck`.
Ruby on Rails developers working with large ActiveRecord datasets who need to optimize memory usage and query performance during batch operations.
Developers choose PluckInBatches because it provides a clean, ActiveRecord-native API for efficient column plucking in batches, delivering measurable performance improvements without complex workarounds.
A faster alternative to the custom use of in_batches with pluck
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Reduces SQL queries by half and cuts memory allocation by up to 50% compared to manual in_batches with pluck, as benchmarked in the README, leading to faster batch processing.
Supports custom batch sizes, start/finish values, cursor columns, and ordering options, allowing fine-tuned control over iteration based on specific needs.
Enables plucking of multiple columns in a single batch iteration, and integrates with Arel for custom SQL expressions, facilitating advanced queries without full record loading.
Extends ActiveRecord with familiar methods like pluck_each and pluck_in_batches, providing a clean, expressive interface that aligns with Rails conventions.
Requires ActiveRecord 6+ and Ruby 2.7+, excluding legacy applications or projects using older Rails versions, as noted in the requirements section.
Focused solely on reading data via pluck; lacks built-in support for batch updates or deletions, requiring additional code for modification operations.
May raise errors if an order clause is present without configuring error_on_ignore, adding overhead for relations with custom sorting, as mentioned in the options.