Hi,
As described in the GAE document: "Every entity with a given root
entity as an ancestor is in the
same entity group. All entities in a group are stored in the same
datastore node." Imagine that I
have two model classes: Foo and CommentOnFoo:
class Foo(db.Model):
# some properties...
class CommentOnFoo(db.Model):
foo = db.ReferenceProperty(Foo)
# some other properties...
In my webapp, when I create a CommentOnFoo entity, I always associate
a Foo entity as its parent.
Now I have some questions about the ancestor relationship between Foo
and CommentOnFoo...
1. Does it mean that searching entities in the same datastore node is
faster? If yes, to make the
query faster, shall I always use the 'ANCESTOR IS' condition? For
example, given a Foo entity
"foo", to retrieve all the comments on it, I can use the following
GQLs:
#1: comments = CommentOnFoo.gql("WHERE foo=:foo", foo=foo)
#2: comments = CommentOnFoo.gql("WHERE ANCESTOR IS :foo AND foo=:foo,
foo=foo)
Will the #2 query be faster than #1 (since #2 will be run in a single
datastore node)?
2. Because the ancestor relationship also establishes a one-to-many
relationship, should I remove
CommentOnFoo's "foo" property (ReferenceProperty to Foo)? I think it's
redundant.
PS. I know that I should not use ancestor just to make one-to-many
relationship. I used ancestor as
it's a requirement of transaction.
BTW: I will greatly appreciate if Google could publish a "GAE best
practice" article...
Thanks & regards.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---