Symfony/doctrine: Optimize n+1 queries
问题 Context Imagine a set of proposals, where every user can vote up or down for a proposal. So I have 2 models: A Proposal , A Vote , related to a proposal , a user , and an opinion (up or down). Now I want to display all my proposals, including extra information for each proposal: How many upvotes ? How many downvotes ? Has the current user upvoted ? Has the current user downvoted ? Issue This is really easy to implement, but this implies 4 request per proposal display (called the n+1 query