But the rand() would need to be performed on the entire dataset before
the limit is applied otherwise it wouldn't be random!

Anthony

On 2/21/08, Raul <[EMAIL PROTECTED]> wrote:
>
> @Anthony - Good catch.  I forgot about that.
>
> But with the LIMIT of 50 it shouldn't be that big of a deal. Maybe the
> generated SQL is not what we think it is? I guess you could also try
> replacing this with a find_by_sql statement and see if it performs any
> better.
>
> @records = Record.find_by_sql(SELECT * FROM records WHERE active=1 ORDER BY
> rand() LIMIT 50")
>
> Raul
>
>
> ----- Original Message -----
> From: "Anthony Richardson" <[EMAIL PROTECTED]>
> To: <rubyonrails-deployment@googlegroups.com>
> Sent: Wednesday, February 20, 2008 3:32 PM
> Subject: [Rails-deploy] Re: A lot of records running slow on Dreamhost - any
> suggestions
>
>
> >
> > On 2/21/08, Lee Munroe <[EMAIL PROTECTED]> wrote:
> >>    @records = Record.find_all_by_active(true, :order => 'rand()',
> >> :limit => 50)
> >
> > you might want to double check, but I recall something about the
> > rand() function of mySQL being a slow pig. What is the performance
> > like without the rand()
> >
> > >
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Deploying Rails" group.
To post to this group, send email to rubyonrails-deployment@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-deployment?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to