Optimization of application key usage

Do I have to take care of the location of entities in the Google App Engine datastore? Should I use custom object name names for this?

For example, I could use "$ article_uuid, $ comment_id" as the key name of the Comment object. Will this improve the speed of getting all comments on the article? Or is it better to use shorter keys?

Is it good to use the key in this way? I could use the name "$ article_uuid, $ comment_id" also instead of the 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)
+3
source share
1 answer

key_name (ref, . 40) - key_name , .

key_name . , /. , Comment .

+1

Source: https://habr.com/ru/post/1751817/


All Articles