Remove pre-fetching for grant associations #77
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When finding grants, we were loading associations for some general convenience. However, we do not inspect the grants in detail for our current use cases -- we supply very specific join/where conditions and check for their existence as the implementation of the authorization rules.
This preloading would be useful for building an administrative interface, for example, but is unncessary now. The reason to remove it is to avoid complexity and a performance problem introduced by fetching the institution memberships: we were loading all of them for any matched institution and doing an in-memory join on the object graph. In production, that can be a giant list, consuming excessive time and memory.
This problem can be solved by "adjusting the combine", applying appropriate pieces of the filter conditions the association nodes, but it is not worth doing now. We would be doing extra work and extra queries to throw the data away.