Pokuri
Pokuri

Reputation: 3082

Can I retrieve datastore records in insertion order?

I want to read events happened in my system in the order. But there is a chance that thousands of events could happen at same time. So, I cannot sort based on event created time. Is there a way that can I read in insertion order. If I can read in insertion order I can store the cursor and retrieve the events in order.

Upvotes: 0

Views: 191

Answers (1)

Tim Hoffman
Tim Hoffman

Reputation: 12986

No. You only other option would be to pre-allocate/create sequential keys and use them in order, which would be hard to do in appengine datastore. There historically good reasons not to do this sort of thing for performance reasons. This will be slow. A sequential set of id's meant a pathological case for key distribution. Have a look at the other questions on this topic . e.g - How to implement "autoincrement" on Google AppEngine

Upvotes: 2

Related Questions