Hi djidjadji, This will be less efficient than simply calling .count() on the collection property, which doesn't require fetching the keys at all.
-Nick Johnson On Tue, Jun 23, 2009 at 8:04 PM, djidjadji <[email protected]> wrote: > > 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) <[email protected]>: > > Hi johntray, > > > > On Sun, Jun 21, 2009 at 5:47 PM, johntray <[email protected]> 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] > > > > -- Nick Johnson, App Engine Developer Programs Engineer Google Ireland Ltd. :: Registered in Dublin, Ireland, Registration Number: 368047 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google App Engine" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en -~----------~----~----~----~------~----~------~--~---
