Skip to content

Commit

Permalink
document Paginator::HINT_ENABLE_DISTINCT
Browse files Browse the repository at this point in the history
  • Loading branch information
goetas committed Oct 8, 2023
1 parent bf73fe7 commit 54c38f3
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions docs/en/tutorials/pagination.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,18 @@ the future.
.. note::

``fetchJoinCollection`` argument set to ``true`` might affect results if you use aggregations in your query.

By using the ``Paginator::HINT_ENABLE_DISTINCT`` you can instruct doctrine that the query to be executed
will not produce "duplicate" rows (only to-one relations are joined), thus the SQL limit will work as expected.
In this way the `DISTINCT` keyword will be omitted and can bing important performance improvements.

.. code-block:: php
<?php
use Doctrine\ORM\Tools\Pagination\Paginator;
$dql = "SELECT u, p FROM User u JOIN u.mainPicture p";
$query = $entityManager->createQuery($dql)
->setHint(Paginator::HINT_ENABLE_DISTINCT, false)
->setFirstResult(0)
->setMaxResults(100);

0 comments on commit 54c38f3

Please sign in to comment.