GAE in About splitting an entity into two for performance.(golang)

huangapple go评论76阅读模式
英文:

GAE in About splitting an entity into two for performance.(golang)

问题

我有一个实体账户(Account),主要包含两组信息。

账户 {
    a1 // 第一组信息很少更改
    a2
    a3
    a4
    ...
    b1 // 第二组信息经常更改
    b2
    b3
    b4
    ...
}

第一组是一般信息,不会经常更新,但第二组会经常更改。

我想知道是否应该将第二组提取为另一个实体,并将其键存储在账户中,这样当我更新第二组时,只需要将第二组的数据进行put()操作。

我的担忧是,几乎所有对服务器的操作都需要从第一组和第二组获取数据。如果我将账户拆分为两个实体,我需要进行两次get()操作来检索这两组数据。

我知道从数据存储中读取比写入廉价得多。但是拆分实体并不能减少对put()的调用。在这种情况下,我不知道应该将性能重点放在put()还是get()上。

谢谢。

英文:

I have an entity Account which Contain mainly two groups of information.

Account {
    a1 // Group 1 rarely change
    a2
    a3
    a4
    ...
    b1 // Group 2 change frequently
    b2
    b3
    b4
    ...
}

First group is general info which will not update too frequent but group two will be changing frequently.

I wonder if I should extract Group 2 into another entity and store the key in Account so when I update group 2, I only need to put() the data of group 2.

My concern is, almost all operation to server would mostly require data from both group 1+2. If I split Account into 2, I need to do two get() to retrieve both data.

I know that read form data store is much inexpensive than write. But splitting the entity don't reduce the call to put(). In this case, I don't know if I should focus performance on put() or get().

Thanks

答案1

得分: 1

如果第一组的数据不发生变化,索引就不会被更新,所以更新它们不会产生任何经济成本,而执行第二次获取操作则会产生成本。

你总是需要所有的数据,所以将它们拆分开来没有意义。

拆分的好处在于性能。获取/存储小实体所需的时间比大实体少。例如,如果第一组非常大(以字节为单位的总大小),而且你不需要这些数据,那么只获取/存储第二组实体可以提高性能。但这似乎不符合你的情况。

如果说第一组的大小为500KB,我会考虑将其拆分。不过,如果你必须始终获取第一组数据,那么这个好处就无效了。

英文:

If the data in group 1 doesn't change, indexes don't get updated, so there's no monetary cost involved with updating them, while there is a cost to doing the second fetch.

You always need all the data so it doesn't make sense for you to split them.

The benefit you would get from splitting would be in performance. Fetching/putting a small entity takes less time than a big entity. So, for example, if Group 1 was really big (as in total size in bytes) and you didn't need the data, you could improve your performance by only fetching/putting an entity with Group 2. This doesn't sound like your scenario.

If say group 1 was 500KB, I'd consider splitting it. Although if you have to fetch group 1 all the time anyways, that nullifies the benefit.

huangapple
  • 本文由 发表于 2013年8月16日 21:20:48
  • 转载请务必保留本文链接:https://go.coder-hub.com/18274339.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定