Tinker
Tinker

Reputation: 4525

Appengine: Query only a subset of the data?

My users can supply a start and end date and my server will return a list of points between those two dates.

However, there are too many points between each hour and I am interested to pick only one random point per every 15 minutes.

Is there an easy to do this in Appengine?

Upvotes: 0

Views: 40

Answers (1)

David
David

Reputation: 5519

You should add to each Datastore entity an indexed property to query one.

For example you could create an "hash" property that will contain the date (in ms since epoch) modulo 15 minutes (in ms).

Then you just have to query with a filter saying hash=0, or rather a random value between 0 and 15 min (in ms).

Upvotes: 1

Related Questions