No, IDs are not guaranteed contiguous. In my sample application, my IDs routinely jump from 1, 2, 3, 1000 for a lot of my kinds, so you can't count on continuity. I generally like the custom ID solution based on a sharded counter. This should guarantee continuity if you use a transaction... see http://code.google.com/appengine/articles/sharding_counters.html for details. Assuming you were able to guarantee unique IDs with this method, you could then generate a set of random keys and fetch all entities in a single batch, which should be pretty fast.
- Jason On Fri, Jul 10, 2009 at 12:51 PM, Aleem Mawani <[email protected]>wrote: > I'm not sure the ID's are guranteed continous nor do they start at some > starting point (0 or 1). > > Assigning my own id's seems to turn into a more difficult problem of > creating an IdGenerator. > - Aleem > > On Fri, Jul 10, 2009 at 3:32 PM, Julian Namaro <[email protected]>wrote: > >> >> You should try to generate a list of N random keys for your entity >> because you can fetch that with only one datastore call(and no index). >> Aren't google-generated numeric IDs guaranted continuous? >> If not you can yourself assign alphanumeric keys that are continuous >> (or generated by a formula that you pass on to the random generator). >> >> Julian >> >> >> On Jul 10, 1:33 am, aloo <[email protected]> wrote: >> > Hi all, >> > >> > I'm trying to write a GQL query that returns N random records of a >> > specific kind. My current implementation works but requires N calls to >> > the datastore. I'd like to make it 1 call to the datastore if >> > possible. >> > >> > I currently assign a random number to every kind that I put into the >> > datastore. When I query for a random record I generate another random >> > number and query for records > rand ORDER BY asc LIMIT 1. >> > >> > This works, however, it only returns 1 record so I need to do N >> > queries. Any ideas on how to make this one query? Thanks. >> >> > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google App Engine" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en -~----------~----~----~----~------~----~------~--~---
