google-app-engine - Google 应用引擎实体组

标签 google-app-engine

据我从 App Engine 教程中了解到,实体组的存在只是为了交易目的:

“仅在交易需要时才使用实体组”(来自教程)

同一个实体组的定义就是同根。那么,多于1个层级有什么用呢? 也就是说,为什么我要使用“A -> B -> C”(A 是根,B 他的儿子,C 他的孙子) 而不是“A -> B ; A -> C”? (A、B 和 C 仍然在同一个实体组中,因为 A 是它们的根)。

如果实体组的唯一目的是使实体之间的交易成为可能,为什么我应该使用超过 1 个层次结构级别(我从 Root -> Grandson 链接中获得什么)?

最佳答案

当你进行查询时,你可以使用ancestor()将查询限制为特定实体的子代 - 在您的示例中,您可以仅查找 B 的后代,如果它们都在顶层,您将无法执行此操作。

Programming Google App Engine 中有更多关于祖先查询的信息

Keys and Entity Groups医生还说:

Entity group relationships tell App Engine to store several entities in the same part of the distributed network ... All entities in a group are stored in the same datastore node

编辑:同一文档还列出了一些您不希望您的实体组变得太大的原因:

The more entity groups your application has—that is, the more root entities there are—the more efficiently the datastore can distribute the entity groups across datastore nodes. Better distribution improves the performance of creating and updating data. Also, multiple users attempting to update entities in the same entity group at the same time will cause some users to retry their transactions, possibly causing some to fail to commit changes. Do not put all of the application's entities under one root.

组中实体的任何事务都会导致对同一实体组的任何其他写入失败。如果您有一个包含大量写入的大型实体组,这会导致大量争用,然后您的应用程序必须处理预期的写入失败。 Avoiding datastore contention详细介绍了可以用来减少争用的策略。

关于google-app-engine - Google 应用引擎实体组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2002887/

相关文章:

google-app-engine - 谷歌应用程序引擎ndb : find the position of an order query list

java - 从ObjectName获取Google云存储文件

javascript - 如何在 Angular 应用程序中将字符串保存到 Cloud Storage 中的文本文件?

python - 将数据从应用程序引擎(python)发送到远程服务器(带 php 的 linux)

java - Appengine 无法从数据存储中检索实体

java - AppEngine Java 中的 Robots.txt

python - 谷歌应用程序引擎上的任务队列或多线程

python - GAE 错误 django.core.exception

java - 标准化索引/搜索的字符串

android - 测试 android webview html 5 应用程序