diff --git a/core/pagination.md b/core/pagination.md index fe2413d8e57..7c95a6b0406 100644 --- a/core/pagination.md +++ b/core/pagination.md @@ -320,31 +320,67 @@ class Book } ``` -## Avoiding double SQL requests on Doctrine ORM +## Controlling the behavior of the Doctrine ORM Paginator -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). +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: -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. +- `$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. -That's why this behavior can be configured with the `pagination_fetch_join_collection` parameter on a resource: + You can configure this using the `pagination_fetch_join_collection` attribute on a resource or on a per-operation basis: -```php -