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

Strategy for N+1 Queries #589

Open
tpendragon opened this Issue Aug 14, 2018 · 1 comment

Comments

Projects
None yet
1 participant
@tpendragon
Copy link
Collaborator

commented Aug 14, 2018

This finally showed up in Figgy!

We have two cases in production of the app running N+1 queries and causing measurable performance degradation - pulibrary/figgy#1658 and pulibrary/figgy#1656. What do we need to add in Valkyrie to deal with this?

My current thought is to provide another meta tag on attributes like attribute :loaded_queries, Valkyrie::Types::Set.optional.meta(virtual: true), where the virtual: true setting prevents the attribute from being persisted. That way custom queries could populate that value with whatever, allowing for custom queries like find_members_with_thumbnails.

@tpendragon

This comment has been minimized.

Copy link
Collaborator Author

commented Sep 28, 2018

We have a strategy we're prototyping in Figgy now that's working so far - we just added an attr_accessor :loaded to our resources and a custom query populates that hash with preloaded resources, then our decorators check to see if it's populated and only runs a query if it's empty.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.