You have to have an index if you want to retrieve the "most recent" entities. There is no better way to do it.
Datastore performance does not depend on the number of entities that you store, only on the number of entities you retrieve.
Pergunta
What is the most efficient way of storing private user-specific data, such as their documents and images, using Objectify in Data Store?
I'm using Google's UserFactory to get the currently logged in user.
By default, the user only needs to see the most recent entries (say 30 entries), presented on the first page. They can see older entries by moving through pages. The number of entries is theoretically unbounded.
This seems to be a common scenario, but I'm a bit confused as to what's the best way to go about solving this in terms of designing the entities, so I can minimise data store operations.
So, here are the entities I came up with initially:
SubclassedUser (extends User, stored as entity)
UserDocuments
- @Parent SubclassedUser author
- String messageText
- @Index DateTime updatedDate
- DateTime createddDate
UserImages
- @Parent SubclassedUser uploader
- String imageUrl
- @Index DateTime createdDate
But here are my questions:
Thank you so much in advance!
Solução
You have to have an index if you want to retrieve the "most recent" entities. There is no better way to do it.
Datastore performance does not depend on the number of entities that you store, only on the number of entities you retrieve.