From 5a2a77117384be8a9dfe1c6259fa8205496c5227 Mon Sep 17 00:00:00 2001 From: Matthias Pigulla Date: Thu, 15 Jun 2017 01:02:45 +0200 Subject: [PATCH 1/2] Clarify the impact of changing the fetch mode Seems to work for one-to-many as well, but with a negative performance impact. --- docs/en/reference/dql-doctrine-query-language.rst | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/docs/en/reference/dql-doctrine-query-language.rst b/docs/en/reference/dql-doctrine-query-language.rst index 8950c8d4c..ee2e2fa15 100644 --- a/docs/en/reference/dql-doctrine-query-language.rst +++ b/docs/en/reference/dql-doctrine-query-language.rst @@ -935,7 +935,8 @@ the Query class. Here they are: - ``Query#getResult()``: Retrieves a collection of objects. The result is either a plain collection of objects (pure) or an array - where the objects are nested in the result rows (mixed). + where the objects are nested in the result rows ( + ). - ``Query#getSingleResult()``: Retrieves a single object. If the result contains more than one object, an ``NonUniqueResultException`` is thrown. If the result contains no objects, an ``NoResultException`` @@ -1380,7 +1381,13 @@ Given that there are 10 users and corresponding addresses in the database the ex SELECT * FROM address WHERE id IN (1, 2, 3, 4, 5, 6, 7, 8, 9, 10); .. note:: - Changing the fetch mode during a query is only possible for one-to-one and many-to-one relations. + Changing the fetch mode during a query mostly makes sense for one-to-one and many-to-one relations. In that case, +   all the necessary IDs are available after the root entity (``user`` in the above example) has been loaded. So, one +   query per association can be executed to fetch all the referred-to entities (``address``). + + For one-to-many relations, changing the fetch mode to eager will cause to execute one query **for every root entity +   loaded**. This gives no improvement over the ``lazy`` fetch mode which will also initialize the associations on + a one-by-one basis once they are accessed. EBNF From 8f9f41ea89e72859bc8198777a929c382053b343 Mon Sep 17 00:00:00 2001 From: Matthias Pigulla Date: Thu, 15 Jun 2017 01:03:38 +0200 Subject: [PATCH 2/2] Fix typo --- docs/en/reference/dql-doctrine-query-language.rst | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/en/reference/dql-doctrine-query-language.rst b/docs/en/reference/dql-doctrine-query-language.rst index ee2e2fa15..2c2e23f9e 100644 --- a/docs/en/reference/dql-doctrine-query-language.rst +++ b/docs/en/reference/dql-doctrine-query-language.rst @@ -935,8 +935,7 @@ the Query class. Here they are: - ``Query#getResult()``: Retrieves a collection of objects. The result is either a plain collection of objects (pure) or an array - where the objects are nested in the result rows ( - ). + where the objects are nested in the result rows (mixed). - ``Query#getSingleResult()``: Retrieves a single object. If the result contains more than one object, an ``NonUniqueResultException`` is thrown. If the result contains no objects, an ``NoResultException``