Skip to content

Commit 83c024d

Browse files
committed
document Paginator::HINT_ENABLE_DISTINCT
1 parent a0c9614 commit 83c024d

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

docs/en/tutorials/pagination.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,18 @@ the future.
4343
.. note::
4444

4545
``fetchJoinCollection`` argument set to ``true`` might affect results if you use aggregations in your query.
46+
47+
By using the ``Paginator::HINT_ENABLE_DISTINCT`` you can instruct doctrine that the query to be executed
48+
will not produce "duplicate" rows (only to-one relations are joined), thus the SQL limit will work as expected.
49+
In this way the `DISTINCT` keyword will be omitted and can bing important performance improvements.
50+
51+
.. code-block:: php
52+
53+
<?php
54+
use Doctrine\ORM\Tools\Pagination\Paginator;
55+
56+
$dql = "SELECT u, p FROM User u JOIN u.mainPicture p";
57+
$query = $entityManager->createQuery($dql)
58+
->setHint(Paginator::HINT_ENABLE_DISTINCT, false)
59+
->setFirstResult(0)
60+
->setMaxResults(100);

0 commit comments

Comments
 (0)