KnpPaginatorBundle
KnpPaginatorBundle copied to clipboard
Prevent extra sql queries from to-many and to-one ORM relations
Hi!
I'm running "knplabs/knp-paginator-bundle": "2.8.0" pagination results in a list view. I'd like to know if it's possible to prevent run extra sql queries from to-many and to-one ORM relations. I've tried to ->setHint(UsesPaginator::HINT_FETCH_JOIN_COLLECTION, false) with no success. For example: I have a entity Order that has one-to-one relation with Cart. When I run my list with orders the class Knp\Component\Pager\Event\Subscriber\Paginate\Doctrine\ORM\QuerySubscriber\UsesPaginator make a extra sql query for each relation of Order. Is there a way to prevent this extra queries?
You need to leftjoin (and to select). Anyway, I'm afraid that this unrelated to pagination
Thanks for the information @garak but if I'm not wrong when you use the fetchJoinCollection to false in Doctrine paginator this fetchs doesn't happen.
My previous suggestion still stands
Yeah, I already knew it, but when I start to do too much leftJoin the query starts to get very slow, I'm optimizing performance of a listing.
Anyway, you would get the very same problem with a normal list, without pagination. That's why I said that problem is unrelated