Basically what I care about is how can I translate into php toArray()[0].x.length ? I know php has count but I don't care about that. I have other advanced queries and all of them reduce to this question.

I didn't follow what you mean by "I know php has count but I don't care about that." Unless you were referring to MongoCollection::count(), the basic count() is necessary to calculate the length of the array in the returned document.

I know I can do it like that but this is the only possibility to do it? I though maybe there is something that is returning the exact array I want, just for performance. Or doesn't really affect the performance?
–
CezarAug 24 '12 at 21:17

Field selection will still return everything within the context of the top-level document. You could theoretically use MongoDB to transform the results (e.g. aggregation framework or server-side JS), but that wouldn't be anywhere near as efficient.
–
jmikolaAug 26 '12 at 3:47