Your results wont be uniform anyway

http://groups.google.com/group/google-appengine/msg/a6b952a4b7a59562?hl=en



On 09/07/2009, aloo <aleem.maw...@gmail.com> wrote:
>
>  Because it won't be uniformly random.
>
>  If the random ordering is: A B C D E F G H I J K L M and I want to
>  select 5 random records, I'll always get similarly grouped records
>  (i.e. I'll never get A and M in the same query).
>
>
>  On Jul 9, 1:42 pm, Barry Hunter <barrybhun...@googlemail.com> wrote:
>  > 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-
>
> >
>


-- 
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to