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

Performance: Fetching a relationship needlessly loads the whole resource #181

Open
carlbennettnz opened this issue Dec 23, 2018 · 1 comment

Comments

@carlbennettnz
Copy link
Contributor

As far as I can tell, the following requests are indistinguishable to the database adapter layer.

GET /schools/1
GET /schools/1/relationships/principal

In both cases, the full school resource is loaded. In the latter, everything except for the principal relationship is thrown out by query.returning(). This can get slow for the Knex adapter in cases where other relationships are expensive to load.

An optimisation should be fairly straightforward. I think just setting the select property on the query for relationship requests should do it.

@ethanresnick
Copy link
Owner

I think just setting the select property on the query for relationship requests should do it.

That works for me! Sounds like the right idea.

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

2 participants