mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
LimitSubqueryWalker performance issue with DISTINCT #7114
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @goetas on GitHub (Mar 1, 2023).
Feature Request
Summary
\Doctrine\ORM\Tools\Pagination\LimitSubqueryWalkerAdds aDISTINCTkeyword to paginate with no side effects queries that potentially contain multiple occurrences because of a join table that adds additional rows...See
f82485e651/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryWalker.php (L69)The
DISTINCTmight be expensive in some cases.In some cases it is known (not by doctrine but by the developer writing the query) that despite having joins, they are not adding extra rows, thus
DISTINCTwill not remove any row.I would like to add a way into
LimitSubqueryWalkerto not use the distinct keyword.Would it be acceptable something as this:
in this way when writing the query, it would be possible to set the
opt_out_distinctto skip theDISTINCT.What do you think? is it acceptable?
A similar issue was reported in API platform in https://github.com/api-platform/api-platform/issues/792
If yes i can prepare a PR.
@nkrovex commented on GitHub (Sep 29, 2023):
This opportunity must be present. I came across a similar issue.
@beberlei commented on GitHub (Sep 30, 2023):
@goetas it would be fine to have this yes, a query hint would be a good way. Make sure to add it as constant on the paginator and prefix with paginate, paginate_disable_distinct for example
@goetas commented on GitHub (Oct 7, 2023):
Here you go https://github.com/doctrine/orm/pull/10970
@goetas commented on GitHub (Oct 9, 2023):
https://github.com/doctrine/orm/pull/10970 has been merged