Api-platform: Distinct killing performance

Created on 3 Aug 2018  路  3Comments  路  Source: api-platform/api-platform

Hi, not sure is this right place to ask, maybe this issue should be referenced to Doctrine project. Anyway maybe you can help solve this issue. When getting some resource collection from backend it seems that all queries a have DISTINCT in it.

For example when fetching articles collections api-platform/doctrine creates this kind of query:

SELECT DISTINCT a0_.id AS id_0, a0_.date_created AS date_created_1 FROM articles a0_ ORDER BY a0_.date_created DESC LIMIT 30

Where DISTINCT is totally unnecessary and killing all application performance. At this case query runs quite fast, but if eager loading is enabled, and there are some joins query may took more than 1 min because of DISTINCT.

question

All 3 comments

Indeed, this should be discussed on the Doctrine side because this behavior is the one of Doctrine Paginator. Except if we can find an API Platform-specific way of improving this query in some cases.
IIRC Doctrine implemented this query like this because it鈥檚 the only working implementation for the general case.

Use the partial pagination it won't do any distinct anymore :).

Thank you @soyuka this tip solved issue for me.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sverraest picture sverraest  路  3Comments

achref-riahi picture achref-riahi  路  3Comments

zspine picture zspine  路  3Comments

PierreNAPOLETANO picture PierreNAPOLETANO  路  3Comments

vatri picture vatri  路  3Comments