Igor Kharin
unread,Dec 19, 2012, 2:38:20 AM12/19/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to google-a...@googlegroups.com
Best rule of thumb is "never form child-ancestor relationships if you
don't have a strong need to." (and understand why you need it)
They are not interchangeable. Use ReferenceProperty or better yet just
ID's as either strings or integers as they are shorter/smaller than
Keys and easier to use in case of schema migration.
What are benefits? Well, each entity in Datastore has it's own path,
or a Key. Path is roughly comprised of AppID/KindName/EntityID. What
we need to know here is that entities are obviously sharded across
different machines (based on its path), so your entities may be really
lying on different servers. When you put an entity with ID '1000' and
ancestor 'foo' its path would be:
AppID/KindName/foo+1000
Consequences are:
1. Entity's ID is no longer '1000' but '1000' with ancestor 'foo', so
you can't db.get() it solely by its ID--you have to know its ancestor.
2. All entities with ancestor 'foo' would end up saved somewhere near,
most likely on the same server.
That's why ancestors are used (or even useful) for transactions and
strong consistency across HR Datastore.
In terms of documentation, entities that share the same ancestor are
called entity group. Entity groups are useful for faster/parallizeable
writes, strong consistency and transactions, but you have to keep them
small. Also, ancestor may be anything really, not just some real
entity in the Datastore.