Some serializers or associations are simple enough to use ActiveRecord's pluck function to retrieve objects. pluck is much faster than retrieving objects with plain ActiveRecord.
I created a gem, Plucker Serializer, that uses this technique to improve performance. It also has built-in single object and collection caching.
Benchmarks show that plucking can improve memory consumption and throughput, especially for large collections.
Adding custom type casting and using Oj::StringWriter like Panko does in addition with this technique could really boost performance in my opinion.
Some serializers or associations are simple enough to use ActiveRecord's
pluck
function to retrieve objects.pluck
is much faster than retrieving objects with plain ActiveRecord.I created a gem, Plucker Serializer, that uses this technique to improve performance. It also has built-in single object and collection caching. Benchmarks show that plucking can improve memory consumption and throughput, especially for large collections.
Adding custom type casting and using Oj::StringWriter like Panko does in addition with this technique could really boost performance in my opinion.