How long (max characters) can a datastore entity key_name be? Is it bad to haver very long key_names?

前端 未结 2 1511
自闭症患者
自闭症患者 2020-12-17 09:22

What is the maximum number of characters that can be used to define the key_name of a datastore entity?

Is it bad to have very long key_names?

For example:

2条回答
  •  我在风中等你
    2020-12-17 09:41

    There's no hard maximum - the maximum length of a key name is the maximum length of a key, less some overhead, and keys can get pretty long.

    It is bad to have very long key names, however: Apart from storing and retrieving it, every index entry contains the key name it's referring to, so longer key names mean higher indexing overhead. If you want to ensure uniqueness over a large text, your best option is to make the key name the MD5 or SHA1 sum of the input, which ensures both uniqueness and a short(-ish) key name.

提交回复
热议问题