开发者

GWT + JDO + GAE, how to arrange my data for performance

开发者 https://www.devze.com 2023-02-10 12:00 出处:网络
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.

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.


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. :)

0

精彩评论

暂无评论...
验证码 换一张
取 消