Skip to content

Commit 6240853

Browse files
committed
Added a note about N+1 problem and form collections
1 parent 70ff9a3 commit 6240853

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

doctrine/associations.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,8 @@ to the given ``Category`` object via their ``category_id`` value.
355355
all at once (via a *join*), Doctrine will return the *true* ``Category``
356356
object, since nothing needs to be lazily loaded.
357357

358+
.. _doctrine-associations-join-query:
359+
358360
Joining Related Records
359361
-----------------------
360362

reference/forms/types/entity.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,13 @@ the `query_builder`_ option::
9999
'choice_label' => 'username',
100100
]);
101101

102+
.. note::
103+
104+
Using form collections may result in making too many database requests to
105+
fetch related entities. This is known as the *"N + 1 query problem"* and it
106+
can be solved by :ref:`joining related records <doctrine-associations-join-query>`
107+
when querying for Doctrine associations.
108+
102109
.. _reference-forms-entity-choices:
103110

104111
Using Choices

0 commit comments

Comments
 (0)