Should I care about locality of entities on the Google App Engine datastore?
Should I use custom entity key names for that?
For example, I could use
"$article_uuid,$comment_id"
as the key name of a Comment entity.
Will it improve the speed of fetching all comments for an article?
Or is it better to use shorter keys?
Is it a good practice to use the key in this way?
我可以使用
"$article_uuid,$comment_id"
key name also instead of an index:
def get_comments(article_uuid, limit=1000):
key_prefix=db.Key.from_path('Comment', article_uuid)
q = Comment.gql("where __key__ > :key_prefix and __key__ < :range_end",
key_prefix=key_prefix, range_end=key_prefix+chr(ord(',')+1))
return q.fetch(limit)