0
votes

I am creating a Google App Engine app that has a kind of User-Timeline in it (as in Facebook or Twitter), which consists of series of events sorted chronologically, using the Datastore.
However, I'm unable to come up with some efficient way.
In present solution, i define an entity as:

Entity:Activities:-
- Id
- Details...
- ...
- Timestamp

Is this a way so that i can index and get the activities in some sorted order, according to Timestamp ?
I am working with Java and using Objectify for data access.

1

1 Answers

0
votes

The rule is : if you you want to query/order using a property, you need to index it. I think it's pretty straight forward, what you're doing works.

The question is : what else do you want ? is performance a major need ? (probably, since your app seems user oriented).

If you only need to log user activities and retrieve it, I might suggest that you put your "Activity" entity under a parent entity "User" or "UserActivity".

  • UserActivity (key name = user id)
    • Activity (id, details, timestamp [indexed])

That way you will be able to run ancestor queries using your user's ID to retrieve all his posts. The only drawback is that it will limit you to one write per second on this entity group (basically "all the user activity").