-
-
Notifications
You must be signed in to change notification settings - Fork 875
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
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
Useless queries on not displayed related entities #2866
Comments
Did you set up serialization groups? You could also disable eager loading for this resource. |
Already try disabling the eager loading, even with EXTRA_LAZY it's still doing the fetch :) |
As an aside, naming the entity in plural is really confusing! 🙈 |
Please see doctrine/orm#4389 (comment) and doctrine/orm#4389 (comment) It's how Doctrine works. |
So indeed, what we could do in API Platform is to always eager load such an association, even if it's not in the serializer group. Counter intuitive, I know! Doing an unnecessary join ends up saving us one query. |
The alternative is to enable partial loading, but that comes with its own problems... (Hence not enabled by default.) |
Hi @teohhanhui! Thanks for the feedback, indeed those plural entities need to be changed ;) |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
After taking a look at the SQL queries, I've just figured out Api platform was requesting useless queries from object not displayed in the JSON.
How to reproduce:
In the DB:
Then:
In the doctrine debug, you'll see:
The query on mum_locations seems to be useless, it shouldn't be hydrated by getOneOrNullResult
Am I missing something?
The text was updated successfully, but these errors were encountered: