سؤال

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:

  • Is subclassing User an appropriate way of storing the User?
  • The index is for sorting, so I can get the most recent entries. The idea is to do a descending ORDER BY on the date with a LIMIT to display each page. Is there a more efficient way of doing this so I can avoid performing an index query, given that most of the time the user only wants to see the most recent data?
  • Would there be a performance issue with the query if the number of UserDocuments and UserImages continue to increase? What's the best way of mangaging this?

Thank you so much in advance!

هل كانت مفيدة؟

المحلول

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top