You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: core/pagination.md
+54-18Lines changed: 54 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -320,31 +320,67 @@ class Book
320
320
}
321
321
```
322
322
323
-
## Avoiding double SQL requests on Doctrine ORM
323
+
## Controlling the behavior of the Doctrine ORM Paginator
324
324
325
-
By default, the pagination assumes that there will be a collection fetched on a resource and thus will set `useFetchJoinCollection` to `true` on the Doctrine Paginator class. Having this option implies that 2 SQL requests will be executed (to avoid having less results than expected).
325
+
The [PaginationExtension](https://github.com/api-platform/core/blob/master/src/Bridge/Doctrine/Orm/Extension/PaginationExtension.php) of API Platform performs some checks on the `QueryBuilder` to guess, in most common cases, the correct values to use when configuring the Doctrine ORM Paginator:
326
326
327
-
In most cases, even without collection on the resource, this parameter has little impact on performance. However when fetching a lot of results per page it can be counter productive.
327
+
- `$fetchJoinCollection` argument: Whether there is a join to a collection-valued association. When set to `true`, the Doctrine ORM Paginator will perform an additional query, in order to get the correct number of results.
328
328
329
-
That's why this behavior can be configured with the `pagination_fetch_join_collection` parameter on a resource:
329
+
You can configure this using the `pagination_fetch_join_collection` attribute on a resource or on a per-operation basis:
- `setUseOutputWalkers` setter: Whether to use output walkers. When set to `true`, the Doctrine ORM Paginator will use output walkers, which are compulsory for some types of queries.
356
+
357
+
You can configure this using the `pagination_use_output_walkers` attribute on a resource or on a per-operation basis:
Please note that this parameter will always be forced to false when the resource has composite keys due to a [bug in Doctrine](https://github.com/doctrine/orm/issues/2910).
383
+
For more information, please see the [Pagination](https://www.doctrine-project.org/projects/doctrine-orm/en/current/tutorials/pagination.html) entry in the Doctrine ORM documentation.
0 commit comments