It's done in 2 queries, but this is because we use internally two different pipelines: one for entity fetches and one for other projections. The 'count' value obtained in the 'same' query, would then have to be returned somewhere, which isn't what's intended when you fetch the data. It's also not really what you want ->
This is often used in paging (otherwise, do a count on the entity collection
), and to calculate the full count you have to execute a different query than the paging query in many situations. This means that it has to be 2 queries anyway. The advantage of doing it separately is that you can do a count once, and every subsequential page you fetch doesn't need to obtain the count as well as it never obtains the count in the collection fetch.