GWT + JDO + GAE,如何安排我的数据以提高性能

发布于 2024-10-17 03:54:52 字数 396 浏览 0 评论 0原文

这是我希望存储在数据库

GrandFather->Father[]->Child[] 中的结构。祖父包含父亲列表,父亲包含孩子列表。

最好的安排方式是什么 ->嵌入的还是他们自己的表?

我将如何在客户端填充祖父[]。 (我已经看过 objectify、requestFactory 甚至编组为 DTO)。 目前我有2400个祖父,每个祖父有5个父亲,每个祖父有5个孩子。

我的查询有点多,这需要很长时间才能检索对象。 为了(祖父...) 查询Allfather 为了(父亲……) queryAllChildren

对于每个查询,它是 pm.newQuery(GrandFather.class); pm.执行。

这需要花费几分钟的时间。

Here is my structure that I wish to store in the database

GrandFather->Father[]->Child[]. Grandfather contains a list of father and father contains a list of Children.

What is the best way can this be arranged -> embbedded or their own tables?

And how would I populate a Grandfather[] on the client side. (I have looked thro objectify, requestFactory and even marshalling as DTO).
Currently I have 2400 grandfather each having 5 father and each having 5 child.

My queries are somewhat and this takes a long time to retrieve the objects.
for (grandfather ...)
queryAllfather
for (father ...)
queryAllChildren

For every query, it is pm.newQuery(GrandFather.class); pm.execute.

This is taking a long time order of minutes.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

旧伤还要旧人安 2024-10-24 03:54:52

首先,如果您使用高复制数据存储,请勿使用 JDO 或 JPA。
这是我惨痛的教训。它只是不是为此而设计的。

我没有使用 JDO 或 JPA,而是使用了一个更简单、更干净、更高效的库,称为 Objectify。

至于将数据存储在 HRD 中,您必须详细说明您的用例。如果您有一个祖先模型,那么您可以在 HRD 中保留它的分层结构。如果您的模型还包括“母系”线,您将不得不采取不同的做法。

让它分层(如果可能的话)可能会给你带来两个好处:
- 能够在层次结构上进行交易。
- 避免父对象的额外索引,因为按祖先获取不需要对父字段建立索引。

还有 2 个缺点:
- 你只能有一位父母。因此,您需要决定哪一个是最佳候选者。例如,如果你有母亲、祖母系,你必须选择父亲或母亲,但不能同时成为父母。
- 放置/获取具有较长层次键的对象时效率较低。例如,始终必须获取父密钥。我建议您在文档中阅读它,因为我可能会误导您。

重要的是要记住,您可能不需要这些好处,而缺点可能会严重影响您的项目。所以你原来的问题的答案是:只有你才能知道。 :)

First of all, if you're using High Replication Datastore, don't use JDO or JPA.
This is the lesson I've learned the hard way. It's just not designed for it.

Instead of using JDO or JPA I went with a much simpler, cleaner and more efficient library called Objectify.

As far as storing your data in HRD, you have to tell more about your use cases. If you have a single ancestor model, then you can keep it hierarchical in the HRD. If your model will also include "maternal" line, you will have to do it differently.

Having it hierarchical (if possible) may give you 2 benefits:
- Ability to make transactions on the hierarchy.
- Avoiding an extra index for the parent object because fetching by ancestor will not require the parent field to be indexed.

There are also 2 downsides:
- You can have only one parent. So you need to decide which one is the best candidate for that. For instance, if you have mother, grand mother line, you'll have to pick either father or mother, but not both to be parents.
- There are some inefficiencies with putting/getting objects with longer hierarchical keys. For instance, the parent key will always have to be fetched. I suggest you read about it in the docs, because I might be misinforming you.

It's important to remember that you may not need the benefits while downsides can seriously affect your project. So the answer to your original question is: Only you can tell. :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文