From 54c38f3cd46e0c25a6ea67e574dd2a19b13713c1 Mon Sep 17 00:00:00 2001 From: Asmir Mustafic Date: Sun, 8 Oct 2023 20:52:51 +0200 Subject: [PATCH] document Paginator::HINT_ENABLE_DISTINCT --- docs/en/tutorials/pagination.rst | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/docs/en/tutorials/pagination.rst b/docs/en/tutorials/pagination.rst index dd584a4b2a8..ff367cf080f 100644 --- a/docs/en/tutorials/pagination.rst +++ b/docs/en/tutorials/pagination.rst @@ -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 + + createQuery($dql) + ->setHint(Paginator::HINT_ENABLE_DISTINCT, false) + ->setFirstResult(0) + ->setMaxResults(100);