Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using ActiveRecord's pluck when possible #121

Open
hboisgibault opened this issue Aug 4, 2022 · 0 comments
Open

Using ActiveRecord's pluck when possible #121

hboisgibault opened this issue Aug 4, 2022 · 0 comments

Comments

@hboisgibault
Copy link

hboisgibault commented Aug 4, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant