何时使用GAE数据存储中的实体组 [英] When to use entity groups in GAE's Datastore

查看:88
本文介绍了何时使用GAE数据存储中的实体组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

继续阅读我之前关于GAE Datastore实体层次结构的问题( ,我仍然对何时使用 实体组 感到困惑。 以这个简单的例子:




  • 每个公司都有一个或多个 Employee 实体

  • 员工不能移动到另一个公司,处理一个公司的用户永远不会看到另一个员工公司



这看起来像是我可以让 Employee Company 的c $ c> a 子实体 ,但是实际后果是什么?这是否提高了可伸缩性,损害了可伸缩性,还是没有影响?
使用或不使用实体层次结构的其他优点/缺点是什么?



实体组 启用交易,但假设这个例子,我不需要交易)。

解决方案

尼克明确表示,你不应该大于必要的组,编写可伸缩应用程序的最佳做法有一些讨论一个原因。



当您需要交易时使用实体组。在您提供的示例中,员工会提供 ReferenceProperty 除了事务之外,实体组可以是有帮助的,因为可以将键提取和查询从父实体键入。不过,您可能需要考虑多租户这些类型的用例。

最终,大型实体组可能会损害可伸缩性,实体组中的实体存储在同一台平板电脑中。您挤入一个实体组的东西越多,您越能减少可以并行完成的工作量 - 它需要按顺序完成。


Following up on my earlier question regarding GAE Datastore entity hierarchies, I'm still confused about when to use entity groups.

Take this simple example:

  • Every Company has one or more Employee entities
  • An Employee cannot be moved to another Company, and users that deal with one Company can never see the Employees of another Company

This looks like a case where I could make Employee a child entity of Company, but what are the practical consequences? Does this improve scalability, hurt scalability, or have no impact? What are other advantages/disadvantages of using or not using an entity hierarchy?

(Entity groups enable transactions, but assume for this example that I do not need transactions).

解决方案

Nick stated clearly that you should not make the groups larger than necessary, the Best practices for writing scalable applications has some discussion one why.

Use entity groups when you need transactions. In the example you gave, a ReferenceProperty on employee will achieve a similar result.

Aside from transactions, entity groups can be helpful because key-fetches and queries can be keyed off of a parent entity. However, you might want to consider multitenancy for these types of use-cases.

Ultimately large entity groups might hurt scalability, entities within an entity group are stored in the same tablet. The more stuff you cram into one entity group, the more you reduce the amount of work that can be done in parallel -- it needs done serially instead.

这篇关于何时使用GAE数据存储中的实体组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆