Le 13/10/2014 dans symfony

Why is Doctrine2 making extra queries by itself!?

If you see a lot of useless and not desired queries in your logs while hydrating a collection with Doctrine2, you may be in this edge case: Inverse side of x-to-one can never be lazy.

That means you can’t just select the owning side of a X-To-One relasionship,
because if you do so, each record hydrated will throw a new query at your database, and there is no way around this, as you can see in the Doctrine2 code.

The only solution is to manualy add your LEFT JOIN and SELECT section.

As always, ORM are great, and such “bugs” / “features” are why we hate them…