Hi All,
According to the docs:
http://code.google.com/appengine/docs/python/datastore/typesandpropertyclasses.html#ReferenceProperty
The example given looks like this:
===
class Author(db.Model):
name = db.StringProperty()
class Story(db.Model):
author = db.ReferenceProperty(Author)
story = db.get(story_key)
author_name = story.author.name
===
So am I assuming correctly that the above example would represent two
"get" requests from the database? The first would be when the db.get
is performed ... and the second in a lazy manner if story.author is
referenced?
So if i have multiple rows from db.get ... and all of the results
reference the same "parent" model, and if i use that field from the
result set it will end up doing n(o) operations, even if all stories
have the same author:
stories = db.GqlQuery("SELECT * FROM Story")
for story in stories:
author_name = story.author.name
1) get all stories
2) get story author for story 1
3) get story author for story 2
4) get story author for story n
Is this correct? Or does the DataStore do just 2 queries for the code
listed above (caching referenced data that is referenced by multiple
rows in a result set):
1) get all stories
2) get story author for story 1
3) reuse result from story 1 since story 2 uses same result
The answer to this question is very important to me in designing a
data structure. Appreciate any input I can get on this!
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---