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

Make auto generated relation tables accessible for queries #8351

Open
Jurek-Raben opened this issue Nov 27, 2020 · 0 comments
Open

Make auto generated relation tables accessible for queries #8351

Jurek-Raben opened this issue Nov 27, 2020 · 0 comments

Comments

@Jurek-Raben
Copy link

Doctrine currently seems to be blind for its own auto generated relation tables. This leads into several performance and other kind of problems.

For example, if you define a many-many-relation in the two Entities thru the annotations, and later have to access info thru this relation, it leads into several performance problems. Let's say you have a entity A and B, and now want to count the number of Bs related to A for each entry of A in an inner select, you currently have to use the sql command MEMBER OF:

(SELECT COUNT(at.id) FROM entityA at WHERE entityB MEMBER OF entityA.entitiesB)

It seems to happen often then, that Doctrine now converts this kind of simple information request to at least two additional subqueries, in addition to this one! In a complex query context, this will lead into drastical performance problems. Let's say that MEMBER OF seems to be a very costly function.

On the other hand, if you could access the relation table itself, you simply could do a:

(SELECT COUNT(rt.entity_a_id) FROM entityA_entityB rt WHERE rt.entity_b_id = entityB.id)

This one is a ton faster than the query above. So why are the relation tables invisible? It seems to me a unneccessary handicap for the programmer. Why is that?

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

1 participant