Datastore(Datastore 模式下的 Firestore)是否按 key/name 的顺序存储实体?

Does Datastore (Firestore in Datastore Mode) store entities in order by their key/name?

执行写入时,数据库是否按实体的键以某种顺序写入实体?

例如,如果我写了以下键(故意使 name (1, 7, 3) 乱序):

["A", "1"]
["A", "7"]
["A", "3"]

在没有过滤器或排序 return 的情况下对 A 类型的查询是否会得到如下结果:

["A", "1"]
["A", "3"]
["A", "7"]

如果我的密钥包含时间戳(名称为毫秒),可能更重要:

["UserSession", "e4facf67-969d-46f5-b922-390f61beac0a", "UserRecord", "1597872201000"]
["UserSession", "e4facf67-969d-46f5-b922-390f61beac0a", "UserRecord", "1597872207000"]
["UserSession", "e4facf67-969d-46f5-b922-390f61beac0a", "UserRecord", "1597872203000"]

会查询

("UserRecord").hasAncestor(["UserSession", "e4facf67-969d-46f5-b922-390f61beac0a"])

return 按名称排序的对象(又名时间戳,以毫秒为单位)?

是的,Datastore 模式下的 Cloud Firestore 确实按键顺序存储实体。您可以从 best practices 文档中看到:

If you assign your own manual numeric ID or custom name to the entities you create, do not use monotonically increasing values

If an application generates large traffic, such sequential numbering could lead to hotspots that impact Datastore mode latency.