Skip to content

Loading…

DDC-2076: Optimization for MEMBER OF #2758

Open
doctrinebot opened this Issue · 1 comment

2 participants

@doctrinebot

Jira issue originally created by user stof:

Currently, using MEMBER OF for a ManyToMany collection does a join on the table of the related entity, whereas all it needs is in the join table.

Using the following DQL:

SELECT p FROM Player p
WHERE NOT :team MEMBER OF p.targetedBy

Here is the current generated SQL:

WHERE NOT EXISTS (SELECT 1 FROM player*team p1_ INNER JOIN Team t2_ ON p1_.team_id = t2_.id WHERE p1_.player_id = p0_.id AND t2*.id = ?)

whereas it could drop the join:

WHERE NOT EXISTS (SELECT 1 FROM player*team p1_ WHERE p1_.player_id = p0_.id AND p1_.team*id = ?)
@doctrinebot

Comment created by stof:

[~guilhermeblanco] is there any case where the CollectionMemberExpression would really need to join the target entity table rather than just using the join table ? I don't see any

@beberlei beberlei was assigned by doctrinebot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.