DDC-4017: [GH-1569] Add EAGER_BATCHED fetchmode to OneToMany association #4903

Closed
opened 2026-01-22 14:51:44 +01:00 by admin · 2 comments
Owner

Originally created by @doctrinebot on GitHub (Nov 24, 2015).

Originally assigned to: @beberlei on GitHub.

Jira issue originally created by user @doctrinebot:

This issue is created automatically through a Github pull request on behalf of interpotential:

Url: https://github.com/doctrine/doctrine2/pull/1569

Message:

In regular EAGER mode, doctrine adds a JOIN for a OneToMany association
forcing the database to load more data in memory than essentially
needed. In a classic Article => Tag concept, each article would be
loaded one extra time for every addition tag.

LAZY mode issues a query for every article to load all associated tags,
also adding more overhead to the database than needed.

This new fetchmode addreses this issue by loading all tags associated to
an article into one additional query.

Originally created by @doctrinebot on GitHub (Nov 24, 2015). Originally assigned to: @beberlei on GitHub. Jira issue originally created by user @doctrinebot: This issue is created automatically through a Github pull request on behalf of interpotential: Url: https://github.com/doctrine/doctrine2/pull/1569 Message: In regular EAGER mode, doctrine adds a JOIN for a OneToMany association forcing the database to load more data in memory than essentially needed. In a classic Article => Tag concept, each article would be loaded one extra time for every addition tag. LAZY mode issues a query for every article to load all associated tags, also adding more overhead to the database than needed. This new fetchmode addreses this issue by loading all tags associated to an article into one additional query.
admin added the Improvement label 2026-01-22 14:51:44 +01:00
admin closed this issue 2026-01-22 14:51:46 +01:00
Author
Owner

@doctrinebot commented on GitHub (Nov 24, 2015):

Comment created by interpotential:

This is a feature I was very much looking for myself. After a lengthy conversation with Elias Van Ootegem on stackoverflow I decided to put the code into a PR to see what others in the Doctrine community think of it.

To be honest, I'm not fully convinced that a fetchmode is the best approach. But it seemed the most stable and predictable. As Elias pointed out, there may be situations where this behaviour is not desired for certain relations so just replacing the eager loading strategy seemed a bad idea.

@doctrinebot commented on GitHub (Nov 24, 2015): Comment created by interpotential: This is a feature I was very much looking for myself. After a lengthy conversation with Elias Van Ootegem on [stackoverflow](http://stackoverflow.com/questions/33038223/how-to-load-all-associations-for-a-result-set-in-a-single-query-in-doctrine2) I decided to put the code into a PR to see what others in the Doctrine community think of it. To be honest, I'm not fully convinced that a fetchmode is the best approach. But it seemed the most stable and predictable. As Elias pointed out, there may be situations where this behaviour is not desired for certain relations so just replacing the eager loading strategy seemed a bad idea.
Author
Owner

@Makapashev commented on GitHub (Jan 25, 2021):

That's a huge problem of this ORM, when do you plan to fix this issue? It seems that you decided to avoid creation of this feature.

@Makapashev commented on GitHub (Jan 25, 2021): That's a huge problem of this ORM, when do you plan to fix this issue? It seems that you decided to avoid creation of this feature.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#4903