Why cant you do "> rand ORDER BY asc LIMIT 5" ??? Yes you will get consecutive records, but as the random number you meant to have stored is random, the records are not consecutive in reality (only in the index).
You might even find it not that much more expensive (but benchmark on live!) to say retreive 10 record and discard a random selection of 5, for even more randomness, but seems kinda pointless. On 09/07/2009, aloo <aleem.maw...@gmail.com> 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. > > > > -- Barry - www.nearby.org.uk - www.geograph.org.uk - --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google App Engine" group. To post to this group, send email to google-appengine@googlegroups.com To unsubscribe from this group, send email to google-appengine+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en -~----------~----~----~----~------~----~------~--~---