mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
Extra select query when association on entity with DiscriminatorMap #5686
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Seb33300 on GitHub (Sep 5, 2017).
Originally assigned to: @Ocramius on GitHub.
Hello,
On my Entity A, I have an association to an Entity B which is an abstract entity with a DiscriminatorMap.
Every time I do a getReference() on my Entity A, if I check the logs, I can see 2 queries:
This seems to only happen because entity B is an abstract Entity (who can be a different class from the discriminator).
If I change the association to force it to be one class of the discriminator (not an abstract), I do not have the extra select query.
Seb
@malukenho commented on GitHub (Sep 5, 2017):
Try to read about
n + 1problem. I think that is what you are referencing to.@Ocramius commented on GitHub (Sep 5, 2017):
This is normal, because there is no way to get a reference of the correct proxy type for
B. The association cannot be lazily loaded because there must be a query looking at least at the discriminator column value in order to decide what the runtime type of the reference is.See also: