You can construct a __key__ only query and count them up.
Then you don't have to construct all the A objects just for counting.

result = A.all(keys_only=True).filter('refprop =', b.key()).fetch(1000)
numA = len(result)

2009/6/22 Nick Johnson (Google) <nick.john...@google.com>:
> Hi johntray,
>
> On Sun, Jun 21, 2009 at 5:47 PM, johntray <john.tur...@gmail.com> wrote:
>>
>> Well yes I could add a count property to the B objects, but I'm really
>> trying to understand more about how ReferenceProperty works.
>
> ReferenceProperty's collection attributes are just syntactic sugar for
> creating and executing a query yourself. As such, all the same limitations
> apply. In the case where you call len() on it, I believe this will result in
> a count query being executed, which doesn't require Python to decode all the
> entities, but does require the datastore to fetch all the index rows.
> [snip]

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appengine@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to