Delayed fetch eager #6982

Closed
opened 2026-01-22 15:42:34 +01:00 by admin · 3 comments
Owner

Originally created by @antman3351 on GitHub (May 20, 2022).

Feature Request

Q A
New Feature yes
BC Break no

Summary

Hi,

Would it be possible to implement a delayed fetch eager for a query ?
The idea is, for a result of a query all associations are eager loaded but only when accessed ( a mix between lazy and eager ).

I have some use cases where the used associations are read at runtime ( user defined exports / print templates ).

Because the data is being listed in a table format if the association is accessed once, it will be accessed for all the rows so eager loading the association would be best.

But because the templates are defined by the user, the association may also never be accessed, so eager loading all the associations is over-kill.

Also this would prevent the issue when in a "listing" view an associated column is added without adding FETCH_EAGER to the query possibly creating performance issues.

Originally created by @antman3351 on GitHub (May 20, 2022). ### Feature Request | Q | A | |------------ | ------| | New Feature | yes | | BC Break | no | #### Summary Hi, Would it be possible to implement a delayed fetch eager for a query ? The idea is, for a result of a query all associations are eager loaded but only when accessed ( a mix between lazy and eager ). I have some use cases where the used associations are read at runtime ( user defined exports / print templates ). Because the data is being listed in a table format if the association is accessed once, it will be accessed for all the rows so eager loading the association would be best. But because the templates are defined by the user, the association may also never be accessed, so eager loading all the associations is over-kill. Also this would prevent the issue when in a "listing" view an associated column is added without adding FETCH_EAGER to the query possibly creating performance issues.
admin added the New Feature label 2026-01-22 15:42:34 +01:00
admin closed this issue 2026-01-22 15:42:34 +01:00
Author
Owner

@derrabus commented on GitHub (May 20, 2022):

I believe this would be difficult to implement, but if you want to give it a shot, go ahead.

@derrabus commented on GitHub (May 20, 2022): I believe this would be difficult to implement, but if you want to give it a shot, go ahead.
Author
Owner

@beberlei commented on GitHub (May 27, 2022):

There is a PR for this called #8391 where I discuss that this could replace fetch eager.

@beberlei commented on GitHub (May 27, 2022): There is a PR for this called #8391 where I discuss that this could replace fetch eager.
Author
Owner

@antman3351 commented on GitHub (May 27, 2022):

Super! I'll close this then 👍

@antman3351 commented on GitHub (May 27, 2022): Super! I'll close this then 👍
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#6982