Hi Steven, Some responses inline. Robert
On Wed, Feb 8, 2012 at 11:26, steven <jobshif...@gmail.com> wrote: > Hi: > > Thank you in advance > > I have a question about Datastore API calls. > > Suppose I have a one-to-many relation ship, with two solutions as > below: > > 1) solution 1 > class A > { > set<key> keys_for_B > } > > the instance is a1 contains <b1, b2, b3> > > if I query for a1, and then I can get keys of b1, b2, b3; and then I > read the b1, b2, b3. > Does it mean there are 4 calls to datastore API calls? If you *query* for a1, then do a bulk get on those keys you'll have: query -> 1 scan + 1 fetch = 2 reads bulk get -> 3 reads So you'll have 5 reads. If you know A1's key, then you could do a get there too which would save 1 read. > > > 2) solution 2 > I build a "big-table" as > a1, b1 > a1, b2 > a1, b3 > > and then query as "select * from mytable where a_id = a1_id", to get 3 > rows > I guess there is just one call, to datastore. Generally, I would prefer the first design over introducing a third lookup table. Another solution here might be to include a1 as a property on your "B" entities, possibly as an indexed list property. Then you could do one query for Bs where a = 'a1'. This would give you 4 reads, 1 for the scan + 3 for the entities. > > comparing solution 1 and 2, does it mean Google will charge me 4 times > money for solution 1? > > thank you very much, > Sincerely, > Steven > > > > > > > > -- > 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. > -- 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.