List:General Discussion« Previous MessageNext Message »
From:Gerald Clark Date:June 15 2001 4:33pm
Subject:Re: order by rand() question
View as plain text  
You asked this earlier this week.
The answer has not changed.

Matt Heaton wrote:

> Hi all, trying to do something and have it be as efficient as possilble.  My 
> question is if I have a table with say 10,000 rows in it, and I issue
> a command like this
> select * from table where number=1 order by rand() limit 1;
> If 1000 rows would match this command does mysql first find all 1000 rows
> and THEN randomly select 1 of those to return, OR does it just randomly
> start somewhere and then stop when it finds one?  The first method would
> be really slow and inefficient, but I am afraid that is how it works?  Is 
> there anyone out there that knows FOR SURE how the order by rand() operation 
> works?  I can't find a specification out there for it.
> Thanks,
> Matt Heaton
> ---------------------------------------------------------------------
> Before posting, please check:
>   (the manual)
>           (the list archive)
> To request this thread, e-mail <mysql-thread76726@stripped>
> To unsubscribe, e-mail
> <>
> Trouble unsubscribing? Try:

Gerald L. Clark

order by rand() questionMatt Heaton15 Jun
  • Re: order by rand() questionGerald Clark15 Jun
    • Re: order by rand() questionChris Petersen15 Jun
      • RE: order by rand() questionChris Bolt15 Jun
        • Re: order by rand() questionChris Petersen16 Jun
          • RE: order by rand() questionChris Bolt16 Jun
RE: order by rand() questionJon Haworth15 Jun
  • RE: order by rand() questionChris Bolt15 Jun