core icon indicating copy to clipboard operation
core copied to clipboard

feat(pagination): provide a way to manually disable distinct on count

Open gquemener opened this issue 2 years ago • 2 comments

Using DISTINCT in a COUNT has a major impact on performance. This change pushes the existing fix forward by delegating the responsibility to disable the DISTINCT presence to the developers.

For instance, it is possible to safely remove the DISTINCT from a query that joins a "to one" association.

The existing optimization still exists for most cases.

Q A
Branch? main
Tickets
License MIT
Doc PR to write (depending on the output of the discussion)

TODO:

  • [ ] write doc (api-platform/docs)
  • [ ] Update CHANGELOG.md
  • [ ] Discuss alternatives

I'm not a big fan of this solution, given the amount of properties that already exist on the Operation class (including its inheritance tree).

An alternative would be to change the current detection behavior (which is only based on the number of aliases in the query), to take into account the type of the associations ("to one" association are ok, DISTINCT should be discardable). I could use the QueryChecker::hasJoinedToManyAssociation for instance.

Any suggestions on how to proceed are very welcome, Thanks.

gquemener avatar Dec 11 '23 16:12 gquemener

Hi @gquemener will you work this feature?

soyuka avatar Dec 29 '23 09:12 soyuka

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Feb 27 '24 16:02 stale[bot]

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jun 02 '24 16:06 stale[bot]