I am working on my first GAE project using java and the datastore. And this is my first try with noSQL database. Like a lot of people i have problems understanding the right model to use. So far I’ve figured out two models and I need help to choose the right one.
All the data is represented in two classes User.class and Word.class.
-
User: couple of string with user data (username, email…..)
-
Word: two strings
Which is better :
-
Search in 10 000 000 entities for the 100 i need. For instance every entity
Wordhave a string propertyownerand i query (owner = ‘John’). -
In
User.classi add propertyList<Word>and methodgetWords()that returns the list of words. So i query in 1000 users for the one i need and then call method likegetWords()that returnsList<Word>with that 100 i need.
Which one uses less resources ? Or am i going the wrong way with this ?
The answer is to use appstats and you can find out:
AppStats
Run some tests, try it both ways and see what appstats says.
But I’d say that your option 2) is better simply because you don’t need to search millions of entities. But who knows for sure? The trouble is that “resources” are a dozen different things in app engine – CPU, datastore reads, datastore writes etc etc etc.